Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2006-01-26 23:49:06 +0000
committerMichael Valenta2006-01-26 23:49:06 +0000
commit41105427159ec6a9a5187ecb2772a2246670a98f (patch)
tree69c0fed160fadc27f2fabc2ddd92d7e03aca580a
parent15a3c0a41e7bcf9fe290652d129ef1eeb06f26f8 (diff)
downloadeclipse.platform.team-41105427159ec6a9a5187ecb2772a2246670a98f.tar.gz
eclipse.platform.team-41105427159ec6a9a5187ecb2772a2246670a98f.tar.xz
eclipse.platform.team-41105427159ec6a9a5187ecb2772a2246670a98f.zip
Simplified API for persisting model syncs
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceModelParticipant.java67
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/operations/ModelSynchronizeParticipant.java51
2 files changed, 63 insertions, 55 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceModelParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceModelParticipant.java
index 0e20c6895..5a63e47b7 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceModelParticipant.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceModelParticipant.java
@@ -10,27 +10,23 @@
*******************************************************************************/
package org.eclipse.team.internal.ccvs.ui.mappings;
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.resources.mapping.*;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.*;
import org.eclipse.team.core.mapping.*;
import org.eclipse.team.core.mapping.provider.ScopeGenerator;
import org.eclipse.team.core.subscribers.SubscriberResourceMappingContext;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.team.internal.ccvs.ui.actions.*;
import org.eclipse.team.internal.ccvs.ui.subscriber.CVSActionDelegateWrapper;
-import org.eclipse.team.internal.core.mapping.CompoundResourceTraversal;
import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.ui.TeamUI;
import org.eclipse.team.ui.mapping.SynchronizationActionProvider;
-import org.eclipse.team.ui.operations.*;
+import org.eclipse.team.ui.operations.MergeActionGroup;
+import org.eclipse.team.ui.operations.ModelSynchronizeParticipant;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
-import org.eclipse.ui.PartInitException;
public class WorkspaceModelParticipant extends
ModelSynchronizeParticipant {
@@ -151,6 +147,9 @@ public class WorkspaceModelParticipant extends
setSecondaryId(Long.toString(System.currentTimeMillis()));
}
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.operations.ModelSynchronizeParticipant#initializeConfiguration(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration)
+ */
protected void initializeConfiguration(ISynchronizePageConfiguration configuration) {
configuration.setProperty(ISynchronizePageConfiguration.P_VIEWER_ID, VIEWER_ID);
super.initializeConfiguration(configuration);
@@ -163,46 +162,18 @@ public class WorkspaceModelParticipant extends
return new WorkspaceMergeActionGroup();
}
- protected void initializeContext(ResourceTraversal[] traversals) throws PartInitException {
- CompoundResourceTraversal traversal = new CompoundResourceTraversal();
- traversal.addTraversals(traversals);
- try {
- // When restoring, we can't do anything long running so we'll need to use the local content for everything
- NullProgressMonitor monitor = new NullProgressMonitor();
- ResourceMapping[] mappings = ScopeGenerator.getMappingsFromProviders(traversal.getRoots(), ResourceMappingContext.LOCAL_CONTEXT, monitor);
- IResourceMappingScope scope = createScope(mappings, monitor);
- IMergeContext context = WorkspaceSubscriberContext.createContext(scope, false /* refresh */, ISynchronizationContext.THREE_WAY, monitor);
- initializeContext(context);
- } catch (CoreException e) {
- CVSUIPlugin.log(e);
- throw new PartInitException(e.getStatus());
- }
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.operations.ModelSynchronizeParticipant#restoreContext(org.eclipse.team.core.mapping.IResourceMappingScope, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ protected IMergeContext restoreContext(IResourceMappingScope scope, IProgressMonitor monitor) throws CoreException {
+ return WorkspaceSubscriberContext.createContext(scope, false /* refresh */, ISynchronizationContext.THREE_WAY, monitor);
}
-
- private IResourceMappingScope createScope(ResourceMapping[] mappings, IProgressMonitor monitor) throws PartInitException {
- ModelOperation op = new ModelOperation(null, mappings) {
- protected void execute(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- // Do nothing, we just want to build the scope
- }
- protected void promptIfInputChange(IProgressMonitor monitor) {
- // Don't prompt
- }
- protected boolean isUseLocalContext() {
- return true;
- }
- protected ResourceMappingContext getResourceMappingContext() {
- return new SubscriberResourceMappingContext(CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber(), true);
- }
- };
- // Run the operatin in order to build the scope
- try {
- op.run(monitor);
- } catch (InvocationTargetException e) {
- CVSUIPlugin.log(IStatus.ERROR, "An error occurred", e.getTargetException());
- throw new PartInitException("Unexpected error during participant restore");
- } catch (InterruptedException e) {
- throw new PartInitException("Unexpected interrupt during participant restore");
- }
- return op.getScope();
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.operations.ModelSynchronizeParticipant#createScopeGenerator()
+ */
+ protected ScopeGenerator createScopeGenerator() {
+ return new ScopeGenerator(new SubscriberResourceMappingContext(CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber(), true), true);
}
+
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/operations/ModelSynchronizeParticipant.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/operations/ModelSynchronizeParticipant.java
index b4ef6b295..ee07783a8 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/operations/ModelSynchronizeParticipant.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/operations/ModelSynchronizeParticipant.java
@@ -16,12 +16,11 @@ import java.util.List;
import org.eclipse.compare.structuremergeviewer.ICompareInput;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.resources.mapping.ResourceMapping;
-import org.eclipse.core.resources.mapping.ResourceTraversal;
+import org.eclipse.core.resources.mapping.*;
import org.eclipse.core.runtime.*;
import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.core.mapping.IMergeContext;
-import org.eclipse.team.core.mapping.ISynchronizationContext;
+import org.eclipse.team.core.mapping.*;
+import org.eclipse.team.core.mapping.provider.ScopeGenerator;
import org.eclipse.team.internal.core.mapping.CompoundResourceTraversal;
import org.eclipse.team.internal.ui.*;
import org.eclipse.team.internal.ui.mapping.ModelSynchronizePage;
@@ -446,7 +445,7 @@ public class ModelSynchronizeParticipant extends
}
}
- /**
+ /*
* Initialize the content of this participant based on the provided traversals.
* This method is invoked when a persisted participant is restored. By default,
* a <code>PartInitException</code> si thrown. Subclasses that have indicated that
@@ -456,10 +455,48 @@ public class ModelSynchronizeParticipant extends
* @param traversals the saved traversals
* @throws PartInitException
*/
- protected void initializeContext(ResourceTraversal[] traversals) throws PartInitException {
- throw new PartInitException(NLS.bind("Participant {0} could not initialize its context from its persisted state", getId()));
+ private void initializeContext(ResourceTraversal[] traversals) throws PartInitException {
+ CompoundResourceTraversal traversal = new CompoundResourceTraversal();
+ traversal.addTraversals(traversals);
+ try {
+ // When restoring, we can't do anything long running so we'll need to use the local content for everything
+ NullProgressMonitor monitor = new NullProgressMonitor();
+ ResourceMapping[] mappings = ScopeGenerator.getMappingsFromProviders(traversal.getRoots(), ResourceMappingContext.LOCAL_CONTEXT, monitor);
+ IResourceMappingScope scope = createScopeGenerator().prepareScope(mappings, true, monitor);
+ IMergeContext context = restoreContext(scope, monitor);
+ initializeContext(context);
+ } catch (CoreException e) {
+ TeamUIPlugin.log(e);
+ throw new PartInitException(e.getStatus());
+ }
+ }
+
+ /**
+ * Recreate the context for this participant. This method is invoked when
+ * the participant is restored after a restart. Although it is provided
+ * with a progress monitor, long running operations should be avoided.
+ * @param scope the restored scope
+ * @param monitor a progress monitor
+ * @return the context for this participant
+ * @throws CoreException
+ */
+ protected IMergeContext restoreContext(IResourceMappingScope scope, IProgressMonitor monitor) throws CoreException {
+ throw new PartInitException(NLS.bind("Participant {0} is not capable of restoring its context", getId()));
}
+ /**
+ * Create a return a scope generator that can be used to build the scope of this
+ * participant when it is restored after a restart. By default, this method
+ * returns a scope generator that uses the local content.
+ * This method can be overridden by subclasses.
+ *
+ * @return a scope generator that can be used to build the scope of this
+ * participant when it is restored after a restart
+ */
+ protected ScopeGenerator createScopeGenerator() {
+ return new ScopeGenerator(ResourceMappingContext.LOCAL_CONTEXT, true);
+ }
+
/* private */ void setRefreshSchedule(SubscriberRefreshSchedule schedule) {
if (refreshSchedule != schedule) {
if (refreshSchedule != null) {

Back to the top