Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Schwarz2013-08-16 05:23:02 +0000
committerTobias Schwarz2013-08-16 05:23:02 +0000
commite844a3e0ad15de923a213425ddae753f739f10a3 (patch)
treef344051466b5bee0af3c949f834fe01238d729c0 /target_explorer
parent36c64ccf43f41d65a74a585322cb3e423b7b4143 (diff)
downloadorg.eclipse.tcf-e844a3e0ad15de923a213425ddae753f739f10a3.tar.gz
org.eclipse.tcf-e844a3e0ad15de923a213425ddae753f739f10a3.tar.xz
org.eclipse.tcf-e844a3e0ad15de923a213425ddae753f739f10a3.zip
Target Explorer: add color and font provider to DelegatingLabelProvider
Diffstat (limited to 'target_explorer')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/navigator/runtime/AbstractLabelProviderDelegate.java12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/navigator/DelegatingLabelProvider.java69
2 files changed, 69 insertions, 12 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/navigator/runtime/AbstractLabelProviderDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/navigator/runtime/AbstractLabelProviderDelegate.java
index 3b9df31bd..a1c83de00 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/navigator/runtime/AbstractLabelProviderDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/navigator/runtime/AbstractLabelProviderDelegate.java
@@ -12,11 +12,9 @@ package org.eclipse.tcf.te.tcf.processes.ui.navigator.runtime;
import java.util.concurrent.atomic.AtomicBoolean;
import org.eclipse.jface.viewers.IColorProvider;
-import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode;
import org.eclipse.ui.PlatformUI;
@@ -24,7 +22,7 @@ import org.eclipse.ui.PlatformUI;
/**
* Abstract label provider delegate implementation.
*/
-public abstract class AbstractLabelProviderDelegate extends LabelProvider implements IColorProvider, IFontProvider {
+public abstract class AbstractLabelProviderDelegate extends LabelProvider implements IColorProvider {
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
@@ -67,12 +65,4 @@ public abstract class AbstractLabelProviderDelegate extends LabelProvider implem
public Color getBackground(Object element) {
return null;
}
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
- */
- @Override
- public Font getFont(Object element) {
- return null;
- }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/navigator/DelegatingLabelProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/navigator/DelegatingLabelProvider.java
index 5ca4d1585..aa18fcdc0 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/navigator/DelegatingLabelProvider.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/navigator/DelegatingLabelProvider.java
@@ -9,9 +9,13 @@
*******************************************************************************/
package org.eclipse.tcf.te.ui.views.navigator;
+import org.eclipse.jface.viewers.IColorProvider;
+import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.jface.viewers.ILabelDecorator;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.eclipse.tcf.te.runtime.services.interfaces.delegates.ILabelProviderDelegate;
import org.eclipse.tcf.te.ui.views.extensions.LabelProviderDelegateExtensionPointManager;
@@ -21,7 +25,7 @@ import org.eclipse.ui.navigator.IDescriptionProvider;
/**
* Label provider implementation.
*/
-public class DelegatingLabelProvider extends LabelProvider implements ILabelDecorator, ILabelProviderDelegate, IDescriptionProvider {
+public class DelegatingLabelProvider extends LabelProvider implements ILabelDecorator, ILabelProviderDelegate, IDescriptionProvider, IColorProvider, IFontProvider {
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
@@ -126,4 +130,67 @@ public class DelegatingLabelProvider extends LabelProvider implements ILabelDeco
return decorateText(getText(element), element) + (description != null ? " - " + description : ""); //$NON-NLS-1$ //$NON-NLS-2$
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
+ */
+ @Override
+ public Font getFont(Object element) {
+ ILabelProvider[] delegates = LabelProviderDelegateExtensionPointManager.getInstance().getDelegates(element, false);
+
+ if (delegates != null && delegates.length > 0) {
+ for (ILabelProvider delegate : delegates) {
+ if (delegate instanceof IFontProvider) {
+ Font candidate = ((IFontProvider)delegate).getFont(element);
+ if (candidate != null) {
+ return candidate;
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
+ */
+ @Override
+ public Color getForeground(Object element) {
+ ILabelProvider[] delegates = LabelProviderDelegateExtensionPointManager.getInstance().getDelegates(element, false);
+
+ if (delegates != null && delegates.length > 0) {
+ for (ILabelProvider delegate : delegates) {
+ if (delegate instanceof IColorProvider) {
+ Color candidate = ((IColorProvider)delegate).getForeground(element);
+ if (candidate != null) {
+ return candidate;
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
+ */
+ @Override
+ public Color getBackground(Object element) {
+ ILabelProvider[] delegates = LabelProviderDelegateExtensionPointManager.getInstance().getDelegates(element, false);
+
+ if (delegates != null && delegates.length > 0) {
+ for (ILabelProvider delegate : delegates) {
+ if (delegate instanceof IColorProvider) {
+ Color candidate = ((IColorProvider)delegate).getBackground(element);
+ if (candidate != null) {
+ return candidate;
+ }
+ }
+ }
+ }
+
+ return null;
+ }
}

Back to the top