Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2006-05-18 21:06:55 +0000
committerMichael Valenta2006-05-18 21:06:55 +0000
commited8034df6db2ec727126f32dadb936a360352328 (patch)
treebad51910c804a19286a2b9fb7acd3814a5b1496b /examples
parent187c7c9f70daf88d40b6873b9cc0e5a22efe5dc3 (diff)
downloadeclipse.platform.team-ed8034df6db2ec727126f32dadb936a360352328.tar.gz
eclipse.platform.team-ed8034df6db2ec727126f32dadb936a360352328.tar.xz
eclipse.platform.team-ed8034df6db2ec727126f32dadb936a360352328.zip
Working on model example
Diffstat (limited to 'examples')
-rw-r--r--examples/org.eclipse.team.examples.filesystem/plugin.xml38
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ModelWorkspace.java4
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ExampleModelProvider.java (renamed from examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ModelProvider.java)15
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ModelMerger.java4
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ModelResourceMapping.java2
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/AdapterFactory.java4
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelNavigatorContentProvider.java5
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/ModelSyncActionProvider.java24
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/ModelSyncContentProvider.java227
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/ModelSyncLabelProvider.java67
10 files changed, 379 insertions, 11 deletions
diff --git a/examples/org.eclipse.team.examples.filesystem/plugin.xml b/examples/org.eclipse.team.examples.filesystem/plugin.xml
index df86ef852..0a7772038 100644
--- a/examples/org.eclipse.team.examples.filesystem/plugin.xml
+++ b/examples/org.eclipse.team.examples.filesystem/plugin.xml
@@ -455,7 +455,7 @@
<extension
id="modelProvider"
point="org.eclipse.core.resources.modelProviders">
- <modelProvider class="org.eclipse.team.examples.model.mapping.ModelProvider"/>
+ <modelProvider class="org.eclipse.team.examples.model.mapping.ExampleModelProvider"/>
<extends-model id="org.eclipse.core.resources.modelProvider"/>
<enablement>
<test property="org.eclipse.core.resources.projectNature" value="org.eclipse.team.examples.filesystem.modelNature" />
@@ -479,6 +479,42 @@
<adapter type="org.eclipse.team.core.mapping.IResourceMappingMerger"/>
</factory>
</extension>
+ <extension
+ point="org.eclipse.team.ui.teamContentProviders">
+ <teamContentProvider
+ contentExtensionId="org.eclipse.team.examples.model.synchronizeContent"
+ icon="$nl$/icons/full/obj/root_obj.gif"
+ modelProviderId="org.eclipse.team.examples.filesystem.modelProvider"/>
+ </extension>
+ <extension
+ point="org.eclipse.ui.navigator.navigatorContent">
+ <navigatorContent
+ contentProvider="org.eclipse.team.examples.model.ui.mapping.ModelSyncContentProvider"
+ icon="$nl$/icons/full/obj/root_obj.gif"
+ id="org.eclipse.team.examples.model.synchronizeContent"
+ labelProvider="org.eclipse.team.examples.model.ui.mapping.ModelSyncLabelProvider"
+ name="Example Model"
+ priority="normal">
+ <actionProvider class="org.eclipse.team.examples.model.ui.mapping.ModelSyncActionProvider"/>
+ <override
+ policy="InvokeAlwaysRegardlessOfSuppressedExt"
+ suppressedExtensionId="org.eclipse.team.ui.resourceContent"/>
+ <triggerPoints>
+ <or>
+ <instanceof value="org.eclipse.team.core.mapping.ISynchronizationScope"/>
+ <instanceof value="org.eclipse.team.core.mapping.ISynchronizationContext"/>
+ <instanceof value="org.eclipse.team.examples.model.ModelObject"/>
+ <instanceof value="org.eclipse.team.examples.model.mapping.ExampleModelProvider"/>
+ </or>
+ </triggerPoints>
+ <possibleChildren>
+ <or>
+ <instanceof value="org.eclipse.team.examples.model.ModelObject"/>
+ <instanceof value="org.eclipse.team.examples.model.mapping.ExampleModelProvider"/>
+ </or>
+ </possibleChildren>
+ </navigatorContent>
+ </extension>
<!-- =================================================================================== -->
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ModelWorkspace.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ModelWorkspace.java
index a180287d3..bbd26ad64 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ModelWorkspace.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ModelWorkspace.java
@@ -26,4 +26,8 @@ public class ModelWorkspace extends ModelContainer {
return null;
}
+ public static Object getRoot() {
+ return new ModelWorkspace();
+ }
+
}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ModelProvider.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ExampleModelProvider.java
index 4a51fcc14..b244cec32 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ModelProvider.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ExampleModelProvider.java
@@ -14,7 +14,7 @@ import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.*;
-import org.eclipse.core.resources.mapping.ModelStatus;
+import org.eclipse.core.resources.mapping.*;
import org.eclipse.core.runtime.*;
import org.eclipse.osgi.util.NLS;
import org.eclipse.team.examples.filesystem.FileSystemPlugin;
@@ -23,12 +23,12 @@ import org.eclipse.team.examples.model.*;
/**
* The model provider for our example
*/
-public class ModelProvider extends
+public class ExampleModelProvider extends
org.eclipse.core.resources.mapping.ModelProvider {
public static final String ID = "org.eclipse.team.examples.filesystem.modelProvider";
- public ModelProvider() {
+ public ExampleModelProvider() {
super();
}
@@ -79,5 +79,14 @@ public class ModelProvider extends
}
return super.validateChange(delta, monitor);
}
+
+ public ResourceMapping[] getMappings(IResource resource, ResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
+ if (ModelProject.isModProject(resource.getProject())) {
+ ModelObject object = ModelObject.create(resource);
+ if (object != null)
+ return new ResourceMapping[] { (ResourceMapping)object.getAdapter(ResourceMapping.class) };
+ }
+ return super.getMappings(resource, context, monitor);
+ }
}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ModelMerger.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ModelMerger.java
index 23c8fb317..75953ff19 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ModelMerger.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ModelMerger.java
@@ -28,9 +28,9 @@ import org.eclipse.team.examples.model.*;
*/
public class ModelMerger extends ResourceMappingMerger {
- private final org.eclipse.team.examples.model.mapping.ModelProvider provider;
+ private final org.eclipse.team.examples.model.mapping.ExampleModelProvider provider;
- public ModelMerger(org.eclipse.team.examples.model.mapping.ModelProvider provider) {
+ public ModelMerger(org.eclipse.team.examples.model.mapping.ExampleModelProvider provider) {
this.provider = provider;
}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ModelResourceMapping.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ModelResourceMapping.java
index 09a10d39d..e936a94fa 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ModelResourceMapping.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ModelResourceMapping.java
@@ -46,7 +46,7 @@ public abstract class ModelResourceMapping extends ResourceMapping {
* @see org.eclipse.core.resources.mapping.ResourceMapping#getModelProviderId()
*/
public String getModelProviderId() {
- return ModelProvider.ID;
+ return ExampleModelProvider.ID;
}
/* (non-Javadoc)
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/AdapterFactory.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/AdapterFactory.java
index 1ed4b7b65..9a61b7cbf 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/AdapterFactory.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/AdapterFactory.java
@@ -27,9 +27,9 @@ public class AdapterFactory implements IAdapterFactory {
return modelAdapter;
if (adapterType == ResourceMapping.class && adaptableObject instanceof ModelObject)
return ModelResourceMapping.create((ModelObject)adaptableObject);
- if (adapterType == IResourceMappingMerger.class && adaptableObject instanceof ModelProvider) {
+ if (adapterType == IResourceMappingMerger.class && adaptableObject instanceof ExampleModelProvider) {
if (modelMerger == null) {
- modelMerger = new ModelMerger((ModelProvider)adaptableObject);
+ modelMerger = new ModelMerger((ExampleModelProvider)adaptableObject);
}
return modelMerger;
}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelNavigatorContentProvider.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelNavigatorContentProvider.java
index 58ce25751..46b5b0e89 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelNavigatorContentProvider.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelNavigatorContentProvider.java
@@ -26,7 +26,9 @@ import org.eclipse.ui.navigator.*;
/**
* Model content provider for use with the Common Navigator framework.
* It makes use of an IWorkbenchAdapter to get the children and parent
- * of model objects.
+ * of model objects. It also makes use of the Common Navigator pipeline
+ * to override the resource content extension so that model projects will
+ * replace the corresponding resource project in the Project Explorer.
*/
public class ModelNavigatorContentProvider extends BaseWorkbenchContentProvider
implements ICommonContentProvider, IResourceChangeListener, IPipelinedTreeContentProvider {
@@ -179,7 +181,6 @@ public class ModelNavigatorContentProvider extends BaseWorkbenchContentProvider
*/
public void getPipelinedChildren(Object aParent, Set theCurrentChildren) {
// Nothing to do
- theCurrentChildren.iterator();
}
/* (non-Javadoc)
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/ModelSyncActionProvider.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/ModelSyncActionProvider.java
new file mode 100644
index 000000000..1f27ce492
--- /dev/null
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/ModelSyncActionProvider.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2006 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.examples.model.ui.mapping;
+
+import org.eclipse.team.ui.mapping.SynchronizationActionProvider;
+
+/**
+ * The action provider that is used for synchronizations.
+ */
+public class ModelSyncActionProvider extends SynchronizationActionProvider {
+
+ public ModelSyncActionProvider() {
+ // TODO Auto-generated constructor stub
+ }
+
+}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/ModelSyncContentProvider.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/ModelSyncContentProvider.java
new file mode 100644
index 000000000..236f7c1d0
--- /dev/null
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/ModelSyncContentProvider.java
@@ -0,0 +1,227 @@
+/*******************************************************************************
+ * Copyright (c) 2006 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.examples.model.ui.mapping;
+
+import java.util.*;
+
+import org.eclipse.core.resources.*;
+import org.eclipse.core.resources.mapping.*;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.team.core.diff.IDiff;
+import org.eclipse.team.core.mapping.ISynchronizationContext;
+import org.eclipse.team.core.mapping.ISynchronizationScope;
+import org.eclipse.team.core.mapping.provider.ResourceDiffTree;
+import org.eclipse.team.examples.filesystem.FileSystemPlugin;
+import org.eclipse.team.examples.model.*;
+import org.eclipse.team.examples.model.mapping.ExampleModelProvider;
+import org.eclipse.team.examples.model.ui.ModelNavigatorContentProvider;
+import org.eclipse.team.internal.ui.mapping.SynchronizationResourceMappingContext;
+import org.eclipse.team.ui.mapping.SynchronizationContentProvider;
+import org.eclipse.ui.navigator.*;
+
+/**
+ * The content provider that is used for synchronizations.
+ * It also makes use of the Common Navigator pipeline
+ * to override the resource content extension so that model projects will
+ * replace the corresponding resource project in the Synchronize view.
+ */
+public class ModelSyncContentProvider extends SynchronizationContentProvider implements IPipelinedTreeContentProvider {
+
+ private ModelNavigatorContentProvider delegate;
+
+ public ModelSyncContentProvider() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.mapping.SynchronizationContentProvider#init(org.eclipse.ui.navigator.ICommonContentExtensionSite)
+ */
+ public void init(ICommonContentExtensionSite site) {
+ super.init(site);
+ delegate = new ModelNavigatorContentProvider();
+ delegate.init(site);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.mapping.SynchronizationContentProvider#dispose()
+ */
+ public void dispose() {
+ super.dispose();
+ if (delegate != null)
+ delegate.dispose();
+ }
+
+ protected ITreeContentProvider getDelegateContentProvider() {
+ return delegate;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.mapping.SynchronizationContentProvider#getModelProviderId()
+ */
+ protected String getModelProviderId() {
+ return ExampleModelProvider.ID;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.mapping.SynchronizationContentProvider#getModelRoot()
+ */
+ protected Object getModelRoot() {
+ return ModelWorkspace.getRoot();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.mapping.SynchronizationContentProvider#getTraversals(org.eclipse.team.core.mapping.ISynchronizationContext, java.lang.Object)
+ */
+ protected ResourceTraversal[] getTraversals(
+ ISynchronizationContext context, Object object) {
+ if (object instanceof ModelObject) {
+ ModelObject mo = (ModelObject) object;
+ ResourceMapping mapping = (ResourceMapping)mo.getAdapter(ResourceMapping.class);
+ ResourceMappingContext rmc = new SynchronizationResourceMappingContext(context);
+ try {
+ // Technically speaking, this may end up being too long running for this
+ // but it will do for illustration purposes
+ return mapping.getTraversals(rmc, new NullProgressMonitor());
+ } catch (CoreException e) {
+ FileSystemPlugin.log(e.getStatus());
+ }
+ }
+ return new ResourceTraversal[0];
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.mapping.SynchronizationContentProvider#getChildrenInContext(org.eclipse.team.core.mapping.ISynchronizationContext, java.lang.Object, java.lang.Object[])
+ */
+ protected Object[] getChildrenInContext(ISynchronizationContext context, Object parent, Object[] children) {
+ Set allChildren = new HashSet();
+ allChildren.addAll(Arrays.asList(super.getChildrenInContext(context, parent, children)));
+ // We need to override this method in order to ensure that any elements
+ // that exist in the context but do not exist locally are included
+ if (parent instanceof ModelContainer) {
+ ModelContainer mc = (ModelContainer) parent;
+ IDiff[] diffs = context.getDiffTree().getDiffs(mc.getResource(), IResource.DEPTH_ONE);
+ for (int i = 0; i < diffs.length; i++) {
+ IDiff diff = diffs[i];
+ IResource resource = ResourceDiffTree.getResourceFor(diff);
+ if (!resource.exists() && ModelObjectDefinitionFile.isModFile(resource)) {
+ allChildren.add(ModelObject.create(resource));
+ }
+ }
+ }
+ if (parent instanceof ModelObjectDefinitionFile) {
+ ResourceTraversal[] traversals = getTraversals(context, parent);
+ IDiff[] diffs = context.getDiffTree().getDiffs(traversals);
+ for (int i = 0; i < diffs.length; i++) {
+ IDiff diff = diffs[i];
+ IResource resource = ResourceDiffTree.getResourceFor(diff);
+ if (!resource.exists() && ModelObjectElementFile.isMoeFile(resource)) {
+ allChildren.add(ModelObject.create(resource));
+ }
+ }
+ }
+ return allChildren.toArray(new Object[allChildren.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#getPipelinedChildren(java.lang.Object, java.util.Set)
+ */
+ public void getPipelinedChildren(Object aParent, Set theCurrentChildren) {
+ // Nothing to do
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#getPipelinedElements(java.lang.Object, java.util.Set)
+ */
+ public void getPipelinedElements(Object anInput, Set theCurrentElements) {
+ // Replace any model projects with a ModelProject if the input
+ // is a synchronization context
+ if (anInput instanceof ISynchronizationContext) {
+ List newProjects = new ArrayList();
+ for (Iterator iter = theCurrentElements.iterator(); iter.hasNext();) {
+ Object element = iter.next();
+ if (element instanceof IProject) {
+ IProject project = (IProject) element;
+ try {
+ if (ModelProject.isModProject(project)) {
+ iter.remove();
+ newProjects.add(ModelObject.create(project));
+ }
+ } catch (CoreException e) {
+ FileSystemPlugin.log(e.getStatus());
+ }
+ }
+ }
+ theCurrentElements.addAll(newProjects);
+ } else if (anInput instanceof ISynchronizationScope) {
+ // When the root is a scope, we should return
+ // our model provider so all model providers appear
+ // at the root of the viewer.
+ theCurrentElements.add(getModelProvider());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#getPipelinedParent(java.lang.Object, java.lang.Object)
+ */
+ public Object getPipelinedParent(Object anObject, Object aSuggestedParent) {
+ // We're not changing the parenting of any resources
+ return aSuggestedParent;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#interceptAdd(org.eclipse.ui.navigator.PipelinedShapeModification)
+ */
+ public PipelinedShapeModification interceptAdd(PipelinedShapeModification anAddModification) {
+ if (anAddModification.getParent() instanceof ISynchronizationContext) {
+ for (Iterator iter = anAddModification.getChildren().iterator(); iter.hasNext();) {
+ Object element = iter.next();
+ if (element instanceof IProject) {
+ IProject project = (IProject) element;
+ try {
+ if (ModelProject.isModProject(project)) {
+ iter.remove();
+ }
+ } catch (CoreException e) {
+ FileSystemPlugin.log(e.getStatus());
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#interceptRefresh(org.eclipse.ui.navigator.PipelinedViewerUpdate)
+ */
+ public boolean interceptRefresh(PipelinedViewerUpdate aRefreshSynchronization) {
+ // No need to intercept the refresh
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#interceptRemove(org.eclipse.ui.navigator.PipelinedShapeModification)
+ */
+ public PipelinedShapeModification interceptRemove(PipelinedShapeModification aRemoveModification) {
+ // No need to intercept the remove
+ return aRemoveModification;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#interceptUpdate(org.eclipse.ui.navigator.PipelinedViewerUpdate)
+ */
+ public boolean interceptUpdate(PipelinedViewerUpdate anUpdateSynchronization) {
+ // No need to intercept the update
+ return false;
+ }
+
+}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/ModelSyncLabelProvider.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/ModelSyncLabelProvider.java
new file mode 100644
index 000000000..580bc64e2
--- /dev/null
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/ModelSyncLabelProvider.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2006 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.examples.model.ui.mapping;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.team.core.diff.IDiff;
+import org.eclipse.team.examples.model.ModelResource;
+import org.eclipse.team.examples.model.ui.ModelNavigatorLabelProvider;
+import org.eclipse.team.ui.mapping.SynchronizationLabelProvider;
+import org.eclipse.ui.navigator.ICommonContentExtensionSite;
+
+/**
+ * The label provider that is used for synchronizations.
+ */
+public class ModelSyncLabelProvider extends SynchronizationLabelProvider {
+
+ private ModelNavigatorLabelProvider delegate;
+
+ public ModelSyncLabelProvider() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.mapping.SynchronizationLabelProvider#init(org.eclipse.ui.navigator.ICommonContentExtensionSite)
+ */
+ public void init(ICommonContentExtensionSite site) {
+ super.init(site);
+ delegate = new ModelNavigatorLabelProvider();
+ delegate.init(site);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.synchronize.AbstractSynchronizeLabelProvider#dispose()
+ */
+ public void dispose() {
+ super.dispose();
+ if (delegate != null)
+ delegate.dispose();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.synchronize.AbstractSynchronizeLabelProvider#getDelegateLabelProvider()
+ */
+ protected ILabelProvider getDelegateLabelProvider() {
+ return delegate;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.synchronize.AbstractSynchronizeLabelProvider#getDiff(java.lang.Object)
+ */
+ protected IDiff getDiff(Object element) {
+ if (element instanceof ModelResource) {
+ ModelResource mr = (ModelResource) element;
+ return getContext().getDiffTree().getDiff(mr.getResource());
+ }
+ return super.getDiff(element);
+ }
+
+}

Back to the top