diff options
author | Michael Valenta | 2005-09-27 20:35:51 +0000 |
---|---|---|
committer | Michael Valenta | 2005-09-27 20:35:51 +0000 |
commit | 549f4f5e8670195bd4c8e4b27920ba2b8022b195 (patch) | |
tree | 00244ce945a9e9b8ce3698cd790367a509c15060 /bundles | |
parent | dce1e605fe1f1cb01ab6288f89f2ff28db021d3a (diff) | |
download | eclipse.platform.team-549f4f5e8670195bd4c8e4b27920ba2b8022b195.tar.gz eclipse.platform.team-549f4f5e8670195bd4c8e4b27920ba2b8022b195.tar.xz eclipse.platform.team-549f4f5e8670195bd4c8e4b27920ba2b8022b195.zip |
Added synchronization context
Diffstat (limited to 'bundles')
4 files changed, 261 insertions, 10 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSMergeContext.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSMergeContext.java index aa4e11bf5..71c5eb388 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSMergeContext.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSMergeContext.java @@ -11,8 +11,11 @@ package org.eclipse.team.internal.ccvs.ui.actions; import org.eclipse.core.internal.resources.mapping.ResourceMapping; +import org.eclipse.core.internal.resources.mapping.ResourceTraversal; import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.mapping.ModelProvider; +import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; @@ -58,4 +61,13 @@ public class CVSMergeContext extends MergeContext { super.dispose(); } + public SyncInfo getSyncInfo(IResource resource) throws CoreException { + return participant.getSubscriber().getSyncInfo(resource); + } + + public void refresh(ResourceTraversal[] traversals, int flags, IProgressMonitor monitor) throws CoreException { + IResource[] resources = new ResourceMappingScope("", getMappings(), traversals).getRoots(); + participant.refreshNow(resources, "TODO: CVS Merge Context Refresh", monitor); + } + } diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/IMergeContext.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/IMergeContext.java new file mode 100644 index 000000000..d395ef520 --- /dev/null +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/IMergeContext.java @@ -0,0 +1,97 @@ +/******************************************************************************* + * Copyright (c) 2000, 2005 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.ui.mapping; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.team.core.synchronize.SyncInfo; +import org.eclipse.team.core.synchronize.SyncInfoSet; + +/** + * Provides the context for an <code>IResourceMappingMerger</code> + * or a model specific synchronization view that supports merging. + * + * TODO: Need to have a story for folder merging + * + * @see IResourceMappingMerger + * @since 3.2 + */ +public interface IMergeContext extends ISynchronizationContext { + + /** + * Method that allows the model merger to signal that the file in question + * has been completely merged. Model mergers can call this method if they + * have transfered all changes from a remote file to a local file and wish + * to signal that the merge is done.This will allow repository providers to + * update the synchronization state of the file to reflect that the file is + * up-to-date with the repository. + * + * @param file the file that has been merged + * @param monitor a progress monitor + * @return a status indicating the results of the operation + */ + public abstract IStatus markAsMerged(IFile file, IProgressMonitor monitor); + + /** + * Method that can be called by the model merger to attempt a file-system + * level merge. This is useful for cases where the model merger does not + * need to do any special processing to perform the merge. By default, this + * method attempts to use an appropriate <code>IStreamMerger</code> to + * merge the files covered by the provided traversals. If a stream merger + * cannot be found, the text merger is used. If this behavior is not + * desired, sub-classes may override this method. + * <p> + * This method does a best-effort attempt to merge all the files covered + * by the provided traversals. Files that could not be merged will be + * indicated in the returned status. If the status returned has the code + * <code>MergeStatus.CONFLICTS</code>, the list of failed files can be + * obtained by calling the <code>MergeStatus#getConflictingFiles()</code> + * method. + * <p> + * Any resource changes triggered by this merge will be reported through the + * resource delta mechanism and the sync-info tree associated with this context. + * + * TODO: How do we handle folder removals generically? + * + * @see SyncInfoSet#addSyncSetChangedListener(ISyncInfoSetChangeListener) + * @see org.eclipse.core.resources.IWorkspace#addResourceChangeListener(IResourceChangeListener) + * + * @param infos + * the sync infos to be merged + * @param monitor + * a progress monitor + * @return a status indicating success or failure. A code of + * <code>MergeStatus.CONFLICTS</code> indicates that the file + * contain non-mergable conflicts and must be merged manually. + * @throws CoreException if an error occurs + */ + public IStatus merge(SyncInfoSet infos, IProgressMonitor monitor) throws CoreException; + + /** + * Method that can be called by the model merger to attempt a file level + * merge. This is useful for cases where the model merger does not need to + * do any special processing to perform the merge. By default, this method + * attempts to use an appropriate <code>IStreamMerger</code> to perform the + * merge. If a stream merger cannot be found, the text merger is used. If this behavior + * is not desired, sub-classes may override this method. + * + * @param file the file to be merged + * @param monitor a progress monitor + * @return a status indicating success or failure. A code of + * <code>MergeStatus.CONFLICTS</code> indicates that the file contain + * non-mergable conflicts and must be merged manually. + * @see org.eclipse.team.ui.mapping.MergeContext#merge(org.eclipse.core.resources.IFile, org.eclipse.core.runtime.IProgressMonitor) + */ + public IStatus merge(SyncInfo info, IProgressMonitor monitor); + +} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/ISynchronizationContext.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/ISynchronizationContext.java new file mode 100644 index 000000000..2c0de5274 --- /dev/null +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/ISynchronizationContext.java @@ -0,0 +1,144 @@ +/******************************************************************************* + * Copyright (c) 2000, 2005 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.ui.mapping; + +import org.eclipse.core.internal.resources.mapping.RemoteResourceMappingContext; +import org.eclipse.core.internal.resources.mapping.ResourceMapping; +import org.eclipse.core.internal.resources.mapping.ResourceTraversal; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.team.core.synchronize.SyncInfo; +import org.eclipse.team.core.synchronize.SyncInfoTree; + +/** + * Allows a model provider to build a view of their model that + * includes synchronization information with a remote location + * (usually a repository). + * + * TODO: + * How do we handle mapping addition/removal? + * - main case to consider is project addition/removal + * - is it OK to say context must be thrown away and re-obtained + * - or should we have API to support addition and removal of mappings + * How do we handle mapping changes (i.e. the set of resources covered by + * a mapping may change? + * - may be OK to say that context must be thrown away and re-obtained + * In general, how do define and maintain the input used to scope the context? + * + * @since 3.2 + */ +public interface ISynchronizationContext { + + /** + * Synchronization type constant that indicates that + * context is a two-way synchronization. + */ + public final static String TWO_WAY = "two-way"; //$NON-NLS-1$ + + /** + * Synchronization type constant that indicates that + * context is a three-way synchronization. + */ + public final static String THREE_WAY = "three-way"; //$NON-NLS-1$ + + /** + * Return the set of mappings for which this context applies. + * @return the set of mappings for which this context applies. + */ + public ResourceMapping[] getMappings(); + + /** + * Return a tree that contains <code>SyncInfo</code> nodes for resources + * that are out-of-sync. The tree will contain sync-info for any out-of-sync + * resources that are associated with the mappings of this context. The tree + * may include additional out-of-sync resources, which should be ignored by + * the client. + * + * @return a tree that contains a <code>SyncInfo</code> node for any + * resources that are out-of-sync. + */ + public SyncInfoTree getSyncInfoTree(); + + /** + * Returns synchronization info for the given resource, or <code>null</code> + * if there is no synchronization info because the resource is not a + * candidate for synchronization. + * <p> + * Note that sync info may be returned for non-existing or for resources + * which have no corresponding remote resource. + * </p> + * <p> + * This method will be quick. If synchronization calculation requires content from + * the server it must be cached when the context is created or refreshed. A client should + * call refresh before calling this method to ensure that the latest information + * is available for computing the sync state. + * </p> + * @param resource the resource of interest + * @return sync info + * @throws CoreException + */ + public SyncInfo getSyncInfo(IResource resource) throws CoreException; + + /** + * Return the synchronization type. A type of <code>TWO_WAY</code> + * indicates that the synchronization information (i.e. + * <code>SyncInfo</code>) associated with the context will also be + * two-way (i.e. there is only a remote but no base involved in the + * comparison used to determine the synchronization state of resources. A + * type of <code>THREE_WAY</code> indicates that the synchronization + * information will be three-way and include the local, base (or ancestor) + * and remote. + * + * @return the type of merge to take place + * + * @see org.eclipse.team.core.synchronize.SyncInfo + */ + public String getType(); + + /** + * Dispose of the synchronization context. This method should be + * invoked by clients when the context is no longer needed. + */ + public void dispose(); + + /** + * Refresh the context in order to update the sync-info to include the + * latest remote state. any changes will be reported through the change + * listeners registered with the sync-info tree of this context. Changes to + * the set may be triggered by a call to this method or by a refresh + * triggered by some other source. + * + * @see SyncInfoSet#addSyncSetChangedListener(ISyncInfoSetChangeListener) + * @see org.eclipse.team.core.synchronize.ISyncInfoTreeChangeEvent + * + * TODO: do we want this? + * @param traversals the resource traversals which indicate which resources + * are to be refreshed + * @param flags additional refresh behavior. For instance, if + * <code>RemoteResourceMappingContext.FILE_CONTENTS_REQUIRED</code> + * is one of the flags, this indicates that the client will be + * accessing the contents of the files covered by the traversals. + * <code>NONE</code> should be used when no additional behavior + * is required + * @param monitor a progress monitor, or <code>null</code> if progress + * reporting is not desired + * @throws CoreException if the refresh fails. Reasons include: + * <ul> + * <li>The server could not be contacted for some reason (e.g. + * the context in which the operation is being called must be + * short running). The status code will be + * SERVER_CONTACT_PROHIBITED. </li> + * </ul> + */ + public void refresh(ResourceTraversal[] traversals, int flags, IProgressMonitor monitor) throws CoreException; + +} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/MergeContext.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/MergeContext.java index 6aeaf3195..72e0f0a80 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/MergeContext.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/MergeContext.java @@ -30,7 +30,6 @@ import org.eclipse.compare.CompareUI; import org.eclipse.compare.IStreamMerger; import org.eclipse.compare.internal.merge.TextStreamMerger; import org.eclipse.core.internal.resources.mapping.ResourceMapping; -import org.eclipse.core.internal.resources.mapping.ResourceTraversal; import org.eclipse.core.resources.IEncodedStorage; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; @@ -41,7 +40,6 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.content.IContentDescription; import org.eclipse.osgi.util.NLS; -import org.eclipse.team.core.synchronize.FastSyncInfoFilter; import org.eclipse.team.core.synchronize.SyncInfo; import org.eclipse.team.core.synchronize.SyncInfoSet; import org.eclipse.team.core.synchronize.SyncInfoTree; @@ -61,13 +59,7 @@ import org.eclipse.team.internal.ui.TeamUIPlugin; * @see IResourceMappingMerger * @since 3.2 */ -public abstract class MergeContext { - - /** - * Comparison type constants - */ - public final static String TWO_WAY = "two-way"; //$NON-NLS-1$ - public final static String THREE_WAY = "three-way"; //$NON-NLS-1$ +public abstract class MergeContext implements IMergeContext { private final String type; private final SyncInfoTree tree; @@ -143,11 +135,17 @@ public abstract class MergeContext { * <code>MergeStatus.CONFLICTS</code>, the list of failed files can be * obtained by calling the <code>MergeStatus#getConflictingFiles()</code> * method. + * <p> + * Any resource changes triggered by this merge will be reported through the + * resource delta mechanism and the sync-info tree associated with this context. * * TODO: How do we handle folder removals generically? * + * @see SyncInfoSet#addSyncSetChangedListener(ISyncInfoSetChangeListener) + * @see org.eclipse.core.resources.IWorkspace#addResourceChangeListener(IResourceChangeListener) + * * @param infos - * the sync infos to be merged + * the array of sync info to be merged * @param monitor * a progress monitor * @return a status indicating success or failure. A code of |