Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Schwarz2013-08-14 08:00:53 -0400
committerTobias Schwarz2013-08-14 08:00:53 -0400
commit6667513805082cb40b15d4b45194617e29b76a53 (patch)
tree5e5b63da1a345ddee1833f086c20586d5a97d2c8 /target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf
parentee9b181ea290f19ad5c918edc8ec5a9150b05449 (diff)
downloadorg.eclipse.tcf-6667513805082cb40b15d4b45194617e29b76a53.tar.gz
org.eclipse.tcf-6667513805082cb40b15d4b45194617e29b76a53.tar.xz
org.eclipse.tcf-6667513805082cb40b15d4b45194617e29b76a53.zip
Target Explorer: rework label provider delegate handling
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/ContextSelectorSectionControl.java6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/AgentSelectionDialog.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/AdapterFactory.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/ContentProvider.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/ContentProviderDelegate.java)8
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/PeerLabelProviderDelegate.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/DelegatingLabelProvider.java)99
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/PeerExportWizardPage.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/PeerImportWizardPage.java2
7 files changed, 33 insertions, 88 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/ContextSelectorSectionControl.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/ContextSelectorSectionControl.java
index bec8576aa..85fad0345 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/ContextSelectorSectionControl.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/ContextSelectorSectionControl.java
@@ -15,9 +15,9 @@ import org.eclipse.jface.dialogs.IDialogPage;
import org.eclipse.jface.viewers.DecoratingLabelProvider;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.tcf.te.tcf.locator.model.Model;
-import org.eclipse.tcf.te.tcf.ui.navigator.ContentProviderDelegate;
-import org.eclipse.tcf.te.tcf.ui.navigator.DelegatingLabelProvider;
+import org.eclipse.tcf.te.tcf.ui.navigator.ContentProvider;
import org.eclipse.tcf.te.ui.views.controls.AbstractContextSelectorControl;
+import org.eclipse.tcf.te.ui.views.navigator.DelegatingLabelProvider;
import org.eclipse.tcf.te.ui.views.sections.AbstractContextSelectorSection;
/**
@@ -61,7 +61,7 @@ public class ContextSelectorSectionControl extends AbstractContextSelectorContro
*/
@Override
protected void doConfigureTreeContentAndLabelProvider(TreeViewer viewer) {
- viewer.setContentProvider(new ContentProviderDelegate(true));
+ viewer.setContentProvider(new ContentProvider(true));
DelegatingLabelProvider labelProvider = new DelegatingLabelProvider();
viewer.setLabelProvider(new DecoratingLabelProvider(labelProvider, labelProvider));
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/AgentSelectionDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/AgentSelectionDialog.java
index 6e7cde58c..5bae72b8c 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/AgentSelectionDialog.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/AgentSelectionDialog.java
@@ -47,10 +47,10 @@ import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties;
import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService;
import org.eclipse.tcf.te.tcf.locator.model.Model;
import org.eclipse.tcf.te.tcf.ui.help.IContextHelpIds;
-import org.eclipse.tcf.te.tcf.ui.navigator.DelegatingLabelProvider;
import org.eclipse.tcf.te.tcf.ui.nls.Messages;
import org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog;
import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
+import org.eclipse.tcf.te.ui.views.navigator.DelegatingLabelProvider;
/**
* TCF agent selection dialog implementation.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/AdapterFactory.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/AdapterFactory.java
index 27e8edd05..232c654eb 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/AdapterFactory.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/AdapterFactory.java
@@ -12,10 +12,10 @@ package org.eclipse.tcf.te.tcf.ui.internal.adapters;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-import org.eclipse.tcf.te.tcf.ui.navigator.DelegatingLabelProvider;
import org.eclipse.tcf.te.ui.views.editor.EditorInput;
import org.eclipse.tcf.te.ui.views.interfaces.IEditorSaveAsAdapter;
import org.eclipse.tcf.te.ui.views.interfaces.categories.ICategorizable;
+import org.eclipse.tcf.te.ui.views.navigator.DelegatingLabelProvider;
import org.eclipse.ui.IPersistableElement;
/**
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/ContentProviderDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/ContentProvider.java
index e9b15b507..8e475f313 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/ContentProviderDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/ContentProvider.java
@@ -55,10 +55,10 @@ import org.eclipse.ui.navigator.INavigatorFilterService;
/**
- * Content provider delegate implementation.
+ * Content provider implementation.
*/
@SuppressWarnings("restriction")
-public class ContentProviderDelegate implements ICommonContentProvider, ITreePathContentProvider {
+public class ContentProvider implements ICommonContentProvider, ITreePathContentProvider {
private final static Object[] NO_ELEMENTS = new Object[0];
// The "Redirected Peers" filter id
@@ -84,7 +84,7 @@ public class ContentProviderDelegate implements ICommonContentProvider, ITreePat
/**
* Constructor.
*/
- public ContentProviderDelegate() {
+ public ContentProvider() {
this(false);
}
@@ -93,7 +93,7 @@ public class ContentProviderDelegate implements ICommonContentProvider, ITreePat
*
* @param showInvisible If <code>true</code>, {@link #getChildren(Object)} will include invisible nodes too.
*/
- public ContentProviderDelegate(boolean showInvisible) {
+ public ContentProvider(boolean showInvisible) {
super();
this.showInvisible = showInvisible;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/DelegatingLabelProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/PeerLabelProviderDelegate.java
index d70571d3f..161dfb4ca 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/DelegatingLabelProvider.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/PeerLabelProviderDelegate.java
@@ -16,7 +16,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.viewers.ILabelDecorator;
-import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.eclipse.tcf.protocol.IPeer;
@@ -32,28 +31,17 @@ import org.eclipse.tcf.te.tcf.ui.navigator.images.PeerImageDescriptor;
import org.eclipse.tcf.te.tcf.ui.navigator.nodes.PeerRedirectorGroupNode;
import org.eclipse.tcf.te.tcf.ui.nls.Messages;
import org.eclipse.tcf.te.ui.jface.images.AbstractImageDescriptor;
-import org.eclipse.tcf.te.ui.views.extensions.LabelProviderDelegateExtensionPointManager;
-
/**
* Label provider implementation.
*/
-public class DelegatingLabelProvider extends LabelProvider implements ILabelDecorator {
+public class PeerLabelProviderDelegate extends LabelProvider implements ILabelDecorator {
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
*/
@Override
public String getText(final Object element) {
- ILabelProvider[] delegates = LabelProviderDelegateExtensionPointManager.getInstance().getDelegates(element, false);
-
- if (delegates != null && delegates.length > 0) {
- String text = delegates[0].getText(element);
- if (text != null) {
- return text;
- }
- }
-
if (element instanceof IPeerModel || element instanceof IPeer) {
StringBuilder builder = new StringBuilder();
@@ -111,7 +99,7 @@ public class DelegatingLabelProvider extends LabelProvider implements ILabelDeco
return Messages.RemotePeerDiscoveryRootNode_label;
}
- return ""; //$NON-NLS-1$
+ return super.getText(element);
}
/**
@@ -153,15 +141,6 @@ public class DelegatingLabelProvider extends LabelProvider implements ILabelDeco
*/
@Override
public Image getImage(final Object element) {
- ILabelProvider[] delegates = LabelProviderDelegateExtensionPointManager.getInstance().getDelegates(element, false);
-
- if (delegates != null && delegates.length > 0) {
- Image image = delegates[0].getImage(element);
- if (image != null) {
- return image;
- }
- }
-
if (element instanceof IPeerModel || element instanceof IPeer) {
final AtomicBoolean isStatic = new AtomicBoolean();
@@ -199,24 +178,14 @@ public class DelegatingLabelProvider extends LabelProvider implements ILabelDeco
*/
@Override
public Image decorateImage(Image image, Object element) {
- Image decoratedImage = null;
-
- if (image != null && element instanceof IPeerModel) {
- ILabelProvider[] delegates = LabelProviderDelegateExtensionPointManager.getInstance().getDelegates(element, false);
- if (delegates != null && delegates.length > 0) {
- if (delegates[0] instanceof ILabelDecorator) {
- Image candidate = ((ILabelDecorator)delegates[0]).decorateImage(image, element);
- if (candidate != null) image = candidate;
- }
- }
-
- boolean isStatic = ((IPeerModel)element).isStatic();
- if (!isStatic) {
- AbstractImageDescriptor descriptor = new PeerImageDescriptor(UIPlugin.getDefault().getImageRegistry(),
- image,
- (IPeerModel)element);
- decoratedImage = UIPlugin.getSharedImage(descriptor);
- }
+ Image decoratedImage = image;
+
+ if (image != null && element instanceof IPeerModel && !((IPeerModel)element).isStatic()) {
+ AbstractImageDescriptor descriptor = new PeerImageDescriptor(
+ UIPlugin.getDefault().getImageRegistry(),
+ image,
+ (IPeerModel)element);
+ decoratedImage = UIPlugin.getSharedImage(descriptor);
}
return decoratedImage;
@@ -229,21 +198,24 @@ public class DelegatingLabelProvider extends LabelProvider implements ILabelDeco
public String decorateText(final String text, final Object element) {
String label = text;
- ILabelProvider[] delegates = LabelProviderDelegateExtensionPointManager.getInstance().getDelegates(element, false);
- if (delegates != null && delegates.length > 0) {
- if (delegates[0] instanceof ILabelDecorator) {
- String candidate = ((ILabelDecorator)delegates[0]).decorateText(label, element);
- if (candidate != null) label = candidate;
- }
- }
-
if (element instanceof IPeerModel) {
final StringBuilder builder = new StringBuilder(label != null && !"".equals(label.trim()) ? label.trim() : "<noname>"); //$NON-NLS-1$ //$NON-NLS-2$
Runnable runnable = new Runnable() {
@Override
public void run() {
- doDecorateText(builder, (IPeerModel)element);
+ boolean isStatic = ((IPeerModel)element).isStatic();
+
+ int state = ((IPeerModel)element).getIntProperty(IPeerModelProperties.PROP_STATE);
+ if (state > IPeerModelProperties.STATE_UNKNOWN
+ && (!isStatic
+ || state == IPeerModelProperties.STATE_REACHABLE
+ || state == IPeerModelProperties.STATE_CONNECTED
+ || state == IPeerModelProperties.STATE_WAITING_FOR_READY)) {
+ builder.append(" ["); //$NON-NLS-1$
+ builder.append(Messages.getString("LabelProviderDelegate_state_" + state)); //$NON-NLS-1$
+ builder.append("]"); //$NON-NLS-1$
+ }
}
};
@@ -258,31 +230,4 @@ public class DelegatingLabelProvider extends LabelProvider implements ILabelDeco
}
return null;
}
-
- /**
- * Decorate the text with some peer attributes.
- * <p>
- * <b>Note:</b> Must be called with the TCF event dispatch thread.
- *
- * @param builder The string builder to decorate. Must not be <code>null</code>.
- * @param peerModel The peer model node. Must not be <code>null</code>.
- */
- /* default */ void doDecorateText(StringBuilder builder, IPeerModel peerModel) {
- Assert.isNotNull(builder);
- Assert.isNotNull(peerModel);
- Assert.isTrue(Protocol.isDispatchThread());
-
- boolean isStatic = peerModel.isStatic();
-
- int state = peerModel.getIntProperty(IPeerModelProperties.PROP_STATE);
- if (state > IPeerModelProperties.STATE_UNKNOWN
- && (!isStatic
- || state == IPeerModelProperties.STATE_REACHABLE
- || state == IPeerModelProperties.STATE_CONNECTED
- || state == IPeerModelProperties.STATE_WAITING_FOR_READY)) {
- builder.append(" ["); //$NON-NLS-1$
- builder.append(Messages.getString("LabelProviderDelegate_state_" + state)); //$NON-NLS-1$
- builder.append("]"); //$NON-NLS-1$
- }
- }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/PeerExportWizardPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/PeerExportWizardPage.java
index 51ee33ba5..35acdc10e 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/PeerExportWizardPage.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/PeerExportWizardPage.java
@@ -54,8 +54,8 @@ import org.eclipse.tcf.te.tcf.core.interfaces.IExportPersistenceService;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
import org.eclipse.tcf.te.tcf.locator.model.Model;
-import org.eclipse.tcf.te.tcf.ui.navigator.DelegatingLabelProvider;
import org.eclipse.tcf.te.tcf.ui.nls.Messages;
+import org.eclipse.tcf.te.ui.views.navigator.DelegatingLabelProvider;
import org.eclipse.ui.progress.UIJob;
/**
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/PeerImportWizardPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/PeerImportWizardPage.java
index fdf607b3c..8fc219182 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/PeerImportWizardPage.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/PeerImportWizardPage.java
@@ -61,8 +61,8 @@ import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService;
import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelRefreshService;
import org.eclipse.tcf.te.tcf.locator.model.Model;
-import org.eclipse.tcf.te.tcf.ui.navigator.DelegatingLabelProvider;
import org.eclipse.tcf.te.tcf.ui.nls.Messages;
+import org.eclipse.tcf.te.ui.views.navigator.DelegatingLabelProvider;
import org.eclipse.ui.progress.UIJob;
/**

Back to the top