Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2004-06-08 19:46:01 +0000
committerJean Michel-Lemieux2004-06-08 19:46:01 +0000
commit901caedc141379a3879a88f90b8fa7564556c64b (patch)
tree9c3958f6ea688ed3feb67ad61347fde0b6eafe16 /examples
parent63bd16753d9e9354fcb0ee0d154f4feedc5900c7 (diff)
downloadeclipse.platform.team-901caedc141379a3879a88f90b8fa7564556c64b.tar.gz
eclipse.platform.team-901caedc141379a3879a88f90b8fa7564556c64b.tar.xz
eclipse.platform.team-901caedc141379a3879a88f90b8fa7564556c64b.zip
added label decorator
Diffstat (limited to 'examples')
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemSynchronizeParticipant.java67
1 files changed, 66 insertions, 1 deletions
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemSynchronizeParticipant.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemSynchronizeParticipant.java
index 5342c736b..0dec4224c 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemSynchronizeParticipant.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemSynchronizeParticipant.java
@@ -10,23 +10,74 @@
*******************************************************************************/
package org.eclipse.team.examples.filesystem.ui;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.viewers.ILabelDecorator;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.subscribers.Subscriber;
+import org.eclipse.team.core.synchronize.SyncInfo;
+import org.eclipse.team.core.variants.IResourceVariant;
import org.eclipse.team.examples.filesystem.subscriber.FileSystemSubscriber;
import org.eclipse.team.ui.TeamUI;
-import org.eclipse.team.ui.synchronize.*;
+import org.eclipse.team.ui.synchronize.ISynchronizeModelElement;
+import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.team.ui.synchronize.ISynchronizeParticipantDescriptor;
+import org.eclipse.team.ui.synchronize.ISynchronizeScope;
import org.eclipse.team.ui.synchronize.SubscriberParticipant;
+
+/**
+ * This is an example synchronize participant for the file system provider. It will allow
+ * showing synchronization state for local resources mapped to a remote file system
+ * location.
+ *
+ * @since 3.0
+ */
public class FileSystemSynchronizeParticipant extends SubscriberParticipant {
private static final String ID = "org.eclipse.team.examples.filesystem.participant"; //$NON-NLS-1$
+ /**
+ * A custom label decorator that will show the remote mapped path for each
+ * file.
+ */
+ private class FileSystemParticipantLabelDecorator extends LabelProvider implements ILabelDecorator {
+
+ public Image decorateImage(Image image, Object element) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ILabelDecorator#decorateText(java.lang.String, java.lang.Object)
+ */
+ public String decorateText(String text, Object element) {
+ try {
+ if (element instanceof ISynchronizeModelElement) {
+ IResource resource = ((ISynchronizeModelElement) element).getResource();
+ if (resource != null) {
+ SyncInfo info = FileSystemSubscriber.getInstance().getSyncInfo(resource);
+ IResourceVariant variant = info.getRemote();
+ if (variant != null) {
+ return text + " (" + variant.getContentIdentifier() + ")";
+ }
+ }
+ }
+ } catch (TeamException e) {
+ }
+ return null;
+ }
+ }
+
public FileSystemSynchronizeParticipant(ISynchronizeScope scope) {
super(scope);
setSubscriber(FileSystemSubscriber.getInstance());
}
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.synchronize.SubscriberParticipant#setSubscriber(org.eclipse.team.core.subscribers.Subscriber)
+ */
protected void setSubscriber(Subscriber subscriber) {
super.setSubscriber(subscriber);
try {
@@ -37,4 +88,18 @@ public class FileSystemSynchronizeParticipant extends SubscriberParticipant {
// ignore
}
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.synchronize.subscribers.SubscriberParticipant#initializeConfiguration(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration)
+ */
+ protected void initializeConfiguration(ISynchronizePageConfiguration configuration) {
+ super.initializeConfiguration(configuration);
+
+ ILabelDecorator labelDecorator = new FileSystemParticipantLabelDecorator();
+ configuration.addLabelDecorator(labelDecorator);
+
+ // Add support for showing mode buttons
+ configuration.setSupportedModes(ISynchronizePageConfiguration.ALL_MODES);
+ configuration.setMode(ISynchronizePageConfiguration.BOTH_MODE);
+ }
}

Back to the top