Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2013-06-14 12:55:28 +0000
committerUwe Stieber2013-06-14 12:55:28 +0000
commit149ec7c79a2766524916ebb0b715d06fe5569384 (patch)
treeb8ff8d5632406aabac05a93e001e5d526be4ea95 /target_explorer
parentc332d9e57869110315a42d4e0da0c53bb8d515c6 (diff)
downloadorg.eclipse.tcf-149ec7c79a2766524916ebb0b715d06fe5569384.tar.gz
org.eclipse.tcf-149ec7c79a2766524916ebb0b715d06fe5569384.tar.xz
org.eclipse.tcf-149ec7c79a2766524916ebb0b715d06fe5569384.zip
Target Explorer: Process monitor tree label provider not forwarding color and font requests correctly
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/editor/tree/columns/PIDLabelProvider.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/tree/columns/PPIDLabelProvider.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/tree/columns/StateLabelProvider.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/tree/columns/UserLabelProvider.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/navigator/runtime/AbstractLabelProviderDelegate.java78
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/navigator/runtime/LabelProviderDelegate.java50
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/TreeViewerDecoratingLabelProvider.java424
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/TreeViewerLabelProvider.java75
8 files changed, 378 insertions, 265 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/tree/columns/PIDLabelProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/tree/columns/PIDLabelProvider.java
index 3aebb8070..e84ace6c1 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/tree/columns/PIDLabelProvider.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/tree/columns/PIDLabelProvider.java
@@ -12,7 +12,6 @@ package org.eclipse.tcf.te.tcf.processes.ui.editor.tree.columns;
import java.util.concurrent.atomic.AtomicLong;
import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.te.runtime.services.ServiceManager;
import org.eclipse.tcf.te.runtime.services.interfaces.IUIService;
@@ -21,11 +20,12 @@ import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IPendingOperationN
import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode;
import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.runtime.IRuntimeModel;
import org.eclipse.tcf.te.tcf.processes.ui.interfaces.IProcessMonitorUIDelegate;
+import org.eclipse.tcf.te.tcf.processes.ui.navigator.runtime.AbstractLabelProviderDelegate;
/**
* The label provider for the tree column "PID".
*/
-public class PIDLabelProvider extends LabelProvider {
+public class PIDLabelProvider extends AbstractLabelProviderDelegate {
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/tree/columns/PPIDLabelProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/tree/columns/PPIDLabelProvider.java
index f4a2dc2cf..184cad8c5 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/tree/columns/PPIDLabelProvider.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/tree/columns/PPIDLabelProvider.java
@@ -12,7 +12,6 @@ package org.eclipse.tcf.te.tcf.processes.ui.editor.tree.columns;
import java.util.concurrent.atomic.AtomicLong;
import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.te.runtime.services.ServiceManager;
import org.eclipse.tcf.te.runtime.services.interfaces.IUIService;
@@ -21,11 +20,12 @@ import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IPendingOperationN
import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode;
import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.runtime.IRuntimeModel;
import org.eclipse.tcf.te.tcf.processes.ui.interfaces.IProcessMonitorUIDelegate;
+import org.eclipse.tcf.te.tcf.processes.ui.navigator.runtime.AbstractLabelProviderDelegate;
/**
* The label provider for the tree column "PPID".
*/
-public class PPIDLabelProvider extends LabelProvider {
+public class PPIDLabelProvider extends AbstractLabelProviderDelegate {
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/tree/columns/StateLabelProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/tree/columns/StateLabelProvider.java
index 096e10e3a..aedbb0202 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/tree/columns/StateLabelProvider.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/tree/columns/StateLabelProvider.java
@@ -12,16 +12,16 @@ package org.eclipse.tcf.te.tcf.processes.ui.editor.tree.columns;
import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IPendingOperationNode;
import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode;
import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.runtime.IRuntimeModel;
+import org.eclipse.tcf.te.tcf.processes.ui.navigator.runtime.AbstractLabelProviderDelegate;
/**
* The label provider for the tree column "state".
*/
-public class StateLabelProvider extends LabelProvider {
+public class StateLabelProvider extends AbstractLabelProviderDelegate {
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/tree/columns/UserLabelProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/tree/columns/UserLabelProvider.java
index 4d9e9bbf6..72d95717f 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/tree/columns/UserLabelProvider.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/tree/columns/UserLabelProvider.java
@@ -12,16 +12,16 @@ package org.eclipse.tcf.te.tcf.processes.ui.editor.tree.columns;
import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IPendingOperationNode;
import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode;
import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.runtime.IRuntimeModel;
+import org.eclipse.tcf.te.tcf.processes.ui.navigator.runtime.AbstractLabelProviderDelegate;
/**
* The label provider for the tree column "user".
*/
-public class UserLabelProvider extends LabelProvider {
+public class UserLabelProvider extends AbstractLabelProviderDelegate {
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
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
new file mode 100644
index 000000000..3b9df31bd
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/navigator/runtime/AbstractLabelProviderDelegate.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Wind River Systems, Inc. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+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;
+
+/**
+ * Abstract label provider delegate implementation.
+ */
+public abstract class AbstractLabelProviderDelegate extends LabelProvider implements IColorProvider, IFontProvider {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
+ */
+ @Override
+ public Color getForeground(Object element) {
+ if (element instanceof IProcessContextNode) {
+ final IProcessContextNode node = (IProcessContextNode) element;
+ final AtomicBoolean canAttach = new AtomicBoolean();
+
+ Runnable runnable = new Runnable() {
+
+ @Override
+ public void run() {
+ if (node.getProcessContext() != null) {
+ if (node.getProcessContext().getProperties().containsKey("CanAttach")) { //$NON-NLS-1$
+ Boolean value = (Boolean)node.getProcessContext().getProperties().get("CanAttach"); //$NON-NLS-1$
+ canAttach.set(value != null && value.booleanValue());
+ } else {
+ canAttach.set(true);
+ }
+ }
+ }
+ };
+ if (Protocol.isDispatchThread()) runnable.run();
+ else Protocol.invokeAndWait(runnable);
+
+ if (!canAttach.get()) {
+ return PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY);
+ }
+ }
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
+ */
+ @Override
+ 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.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/navigator/runtime/LabelProviderDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/navigator/runtime/LabelProviderDelegate.java
index 36e6ab278..5975f4ef4 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/navigator/runtime/LabelProviderDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/navigator/runtime/LabelProviderDelegate.java
@@ -9,14 +9,9 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.processes.ui.navigator.runtime;
-import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
-import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.ILabelDecorator;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
@@ -26,13 +21,12 @@ import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.runtime.IRuntimeMo
import org.eclipse.tcf.te.tcf.processes.ui.activator.UIPlugin;
import org.eclipse.tcf.te.tcf.processes.ui.internal.ImageConsts;
import org.eclipse.tcf.te.tcf.processes.ui.nls.Messages;
-import org.eclipse.ui.PlatformUI;
/**
* Runtime model label provider delegate implementation.
*/
-public class LabelProviderDelegate extends LabelProvider implements ILabelDecorator, IColorProvider {
+public class LabelProviderDelegate extends AbstractLabelProviderDelegate implements ILabelDecorator {
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
@@ -127,46 +121,4 @@ public class LabelProviderDelegate extends LabelProvider implements ILabelDecora
public String decorateText(final String text, final Object element) {
return null;
}
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
- */
- @Override
- public Color getForeground(final Object element) {
- if (element instanceof IProcessContextNode) {
- final IProcessContextNode node = (IProcessContextNode) element;
- final AtomicBoolean canAttach = new AtomicBoolean();
-
- Runnable runnable = new Runnable() {
-
- @Override
- public void run() {
- if (node.getProcessContext() != null) {
- if (node.getProcessContext().getProperties().containsKey("CanAttach")) { //$NON-NLS-1$
- Boolean value = (Boolean)node.getProcessContext().getProperties().get("CanAttach"); //$NON-NLS-1$
- canAttach.set(value != null && value.booleanValue());
- } else {
- canAttach.set(true);
- }
- }
- }
- };
- if (Protocol.isDispatchThread()) runnable.run();
- else Protocol.invokeAndWait(runnable);
-
- if (!canAttach.get()) {
- return PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY);
- }
- }
-
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
- */
- @Override
- public Color getBackground(Object element) {
- return null;
- }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/TreeViewerDecoratingLabelProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/TreeViewerDecoratingLabelProvider.java
index 2a63bc4ef..18ffef7eb 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/TreeViewerDecoratingLabelProvider.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/TreeViewerDecoratingLabelProvider.java
@@ -1,199 +1,225 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. 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:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.trees;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.viewers.DecoratingLabelProvider;
-import org.eclipse.jface.viewers.ILabelDecorator;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelDecorator;
-import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.tcf.te.core.interfaces.IFilterable;
-import org.eclipse.tcf.te.ui.utils.TreeViewerUtil;
-
-/**
- * A subclass of DecoratingLabelProvider provides an FS Tree Viewer
- * with a label provider which combines a nested label provider and an optional
- * decorator. The decorator decorates the label text, image
- * provided by the nested label provider.
- *
- */
-public class TreeViewerDecoratingLabelProvider extends DecoratingLabelProvider implements ITableLabelProvider {
-
- //The label provider for the execution context viewer.
- private TreeViewerLabelProvider fProvider;
- //The label decorator decorating the above label provider.
- private ILabelDecorator fDecorator;
- //Tree viewer that this label provider serves.
- private TreeViewer viewer;
- // The content provider of this viewer.
- private ITreeContentProvider contentProvider;
-
- /**
- * Create a FSTreeDecoratingLabelProvider with an FSTreeLabelProvider and a decorator.
- *
- * @param provider The label provider to be decorated.
- * @param decorator The label decorator.
- */
- public TreeViewerDecoratingLabelProvider(TreeViewer viewer, TreeViewerLabelProvider provider, ILabelDecorator decorator) {
- super(provider, decorator);
- fProvider = provider;
- fDecorator = decorator;
- this.viewer = viewer;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
- */
- @Override
- public Image getColumnImage(Object element, int columnIndex) {
- Image image = fProvider.getColumnImage(element, columnIndex);
- if (columnIndex == 0) {
- if (fDecorator != null) {
- if (fDecorator instanceof LabelDecorator) {
- LabelDecorator ld2 = (LabelDecorator) fDecorator;
- Image decorated = ld2.decorateImage(image, element, getDecorationContext());
- if (decorated != null) {
- image = decorated;
- }
- }
- else {
- Image decorated = fDecorator.decorateImage(image, element);
- if (decorated != null) {
- image = decorated;
- }
- }
- }
- IFilterable decorator = adaptFilterable(element);
- TreePath path = getTreePath(element);
- if (image != null && decorator != null && path != null && TreeViewerUtil.isFiltering(viewer, path)) {
- image = TreeViewerUtil.getDecoratedImage(image, viewer, path);
- }
- }
- return image;
- }
-
- /**
- * Get the tree path whose leaf is the element.
- *
- * @param element The leaf element.
- * @return The tree path.
- */
- private TreePath getTreePath(Object element) {
- List<Object> elements = new ArrayList<Object>();
- while(element != null) {
- elements.add(0, element);
- element = getParent(element);
- }
- if(elements.isEmpty()) return TreePath.EMPTY;
- return new TreePath(elements.toArray());
- }
-
- /**
- * get the parent path.
- *
- * @param element The element whose parent is being retrieved.
- * @return The parent element.
- */
- private Object getParent(Object element) {
- if(this.contentProvider == null) {
- contentProvider = (ITreeContentProvider) viewer.getContentProvider();
- }
- return contentProvider.getParent(element);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
- */
- @Override
- public String getColumnText(Object element, int columnIndex) {
- String text = fProvider.getColumnText(element, columnIndex);
- if (columnIndex == 0) {
- if (fDecorator != null) {
- if (fDecorator instanceof LabelDecorator) {
- LabelDecorator ld2 = (LabelDecorator) fDecorator;
- String decorated = ld2.decorateText(text, element, getDecorationContext());
- if (decorated != null) {
- text = decorated;
- }
- }
- else {
- String decorated = fDecorator.decorateText(text, element);
- if (decorated != null) {
- text = decorated;
- }
- }
- }
- IFilterable decorator = adaptFilterable(element);
- TreePath path = getTreePath(element);
- if (decorator != null && path != null && TreeViewerUtil.isFiltering(viewer, path)) {
- text = TreeViewerUtil.getDecoratedText(text, viewer, path);
- }
- }
- return text;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.viewers.DecoratingLabelProvider#getImage(java.lang.Object)
- */
- @Override
- public Image getImage(Object element) {
- Image image = super.getImage(element);
- IFilterable decorator = adaptFilterable(element);
- TreePath path = getTreePath(element);
- if (image != null && decorator != null && path != null && TreeViewerUtil.isFiltering(viewer, path)) {
- image = TreeViewerUtil.getDecoratedImage(image, viewer, path);
- }
- return image;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.viewers.DecoratingLabelProvider#getText(java.lang.Object)
- */
- @Override
- public String getText(Object element) {
- String text = super.getText(element);
- IFilterable decorator = adaptFilterable(element);
- TreePath path = getTreePath(element);
- if (text != null && decorator != null && path != null && TreeViewerUtil.isFiltering(viewer, path)) {
- text = TreeViewerUtil.getDecoratedText(text, viewer, path);
- }
- return text;
- }
-
- /**
- * Get an adapter of IFilteringLabelProvider from the specified element.
- *
- * @param element The element to get the adapter from.
- * @return The element's adapter or null if does not adapt to IFilteringLabelProvider.
- */
- private IFilterable adaptFilterable(Object element) {
- IFilterable decorator = null;
- if(element instanceof IFilterable) {
- decorator = (IFilterable) element;
- }
- if(decorator == null && element instanceof IAdaptable) {
- decorator = (IFilterable) ((IAdaptable)element).getAdapter(IFilterable.class);
- }
- if(decorator == null) {
- decorator = (IFilterable) Platform.getAdapterManager().getAdapter(element, IFilterable.class);
- }
- return decorator;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Wind River Systems, Inc. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.trees;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.viewers.DecoratingLabelProvider;
+import org.eclipse.jface.viewers.ILabelDecorator;
+import org.eclipse.jface.viewers.ITableColorProvider;
+import org.eclipse.jface.viewers.ITableFontProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelDecorator;
+import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.tcf.te.core.interfaces.IFilterable;
+import org.eclipse.tcf.te.ui.utils.TreeViewerUtil;
+
+/**
+ * A subclass of DecoratingLabelProvider provides an FS Tree Viewer
+ * with a label provider which combines a nested label provider and an optional
+ * decorator. The decorator decorates the label text, image
+ * provided by the nested label provider.
+ *
+ */
+public class TreeViewerDecoratingLabelProvider extends DecoratingLabelProvider implements ITableLabelProvider, ITableColorProvider, ITableFontProvider {
+
+ //The label provider for the execution context viewer.
+ private TreeViewerLabelProvider fProvider;
+ //The label decorator decorating the above label provider.
+ private ILabelDecorator fDecorator;
+ //Tree viewer that this label provider serves.
+ private TreeViewer viewer;
+ // The content provider of this viewer.
+ private ITreeContentProvider contentProvider;
+
+ /**
+ * Create a decorating label provider instance with an label provider and a label decorator.
+ *
+ * @param provider The label provider to be decorated.
+ * @param decorator The label decorator.
+ */
+ public TreeViewerDecoratingLabelProvider(TreeViewer viewer, TreeViewerLabelProvider provider, ILabelDecorator decorator) {
+ super(provider, decorator);
+ fProvider = provider;
+ fDecorator = decorator;
+ this.viewer = viewer;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
+ */
+ @Override
+ public Image getColumnImage(Object element, int columnIndex) {
+ Image image = fProvider.getColumnImage(element, columnIndex);
+ if (columnIndex == 0) {
+ if (fDecorator != null) {
+ if (fDecorator instanceof LabelDecorator) {
+ LabelDecorator ld2 = (LabelDecorator) fDecorator;
+ Image decorated = ld2.decorateImage(image, element, getDecorationContext());
+ if (decorated != null) {
+ image = decorated;
+ }
+ }
+ else {
+ Image decorated = fDecorator.decorateImage(image, element);
+ if (decorated != null) {
+ image = decorated;
+ }
+ }
+ }
+ IFilterable decorator = adaptFilterable(element);
+ TreePath path = getTreePath(element);
+ if (image != null && decorator != null && path != null && TreeViewerUtil.isFiltering(viewer, path)) {
+ image = TreeViewerUtil.getDecoratedImage(image, viewer, path);
+ }
+ }
+ return image;
+ }
+
+ /**
+ * Get the tree path whose leaf is the element.
+ *
+ * @param element The leaf element.
+ * @return The tree path.
+ */
+ private TreePath getTreePath(Object element) {
+ List<Object> elements = new ArrayList<Object>();
+ while(element != null) {
+ elements.add(0, element);
+ element = getParent(element);
+ }
+ if(elements.isEmpty()) return TreePath.EMPTY;
+ return new TreePath(elements.toArray());
+ }
+
+ /**
+ * get the parent path.
+ *
+ * @param element The element whose parent is being retrieved.
+ * @return The parent element.
+ */
+ private Object getParent(Object element) {
+ if(this.contentProvider == null) {
+ contentProvider = (ITreeContentProvider) viewer.getContentProvider();
+ }
+ return contentProvider.getParent(element);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
+ */
+ @Override
+ public String getColumnText(Object element, int columnIndex) {
+ String text = fProvider.getColumnText(element, columnIndex);
+ if (columnIndex == 0) {
+ if (fDecorator != null) {
+ if (fDecorator instanceof LabelDecorator) {
+ LabelDecorator ld2 = (LabelDecorator) fDecorator;
+ String decorated = ld2.decorateText(text, element, getDecorationContext());
+ if (decorated != null) {
+ text = decorated;
+ }
+ }
+ else {
+ String decorated = fDecorator.decorateText(text, element);
+ if (decorated != null) {
+ text = decorated;
+ }
+ }
+ }
+ IFilterable decorator = adaptFilterable(element);
+ TreePath path = getTreePath(element);
+ if (decorator != null && path != null && TreeViewerUtil.isFiltering(viewer, path)) {
+ text = TreeViewerUtil.getDecoratedText(text, viewer, path);
+ }
+ }
+ return text;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.DecoratingLabelProvider#getImage(java.lang.Object)
+ */
+ @Override
+ public Image getImage(Object element) {
+ Image image = super.getImage(element);
+ IFilterable decorator = adaptFilterable(element);
+ TreePath path = getTreePath(element);
+ if (image != null && decorator != null && path != null && TreeViewerUtil.isFiltering(viewer, path)) {
+ image = TreeViewerUtil.getDecoratedImage(image, viewer, path);
+ }
+ return image;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.DecoratingLabelProvider#getText(java.lang.Object)
+ */
+ @Override
+ public String getText(Object element) {
+ String text = super.getText(element);
+ IFilterable decorator = adaptFilterable(element);
+ TreePath path = getTreePath(element);
+ if (text != null && decorator != null && path != null && TreeViewerUtil.isFiltering(viewer, path)) {
+ text = TreeViewerUtil.getDecoratedText(text, viewer, path);
+ }
+ return text;
+ }
+
+ /**
+ * Get an adapter of IFilteringLabelProvider from the specified element.
+ *
+ * @param element The element to get the adapter from.
+ * @return The element's adapter or null if does not adapt to IFilteringLabelProvider.
+ */
+ private IFilterable adaptFilterable(Object element) {
+ IFilterable decorator = null;
+ if(element instanceof IFilterable) {
+ decorator = (IFilterable) element;
+ }
+ if(decorator == null && element instanceof IAdaptable) {
+ decorator = (IFilterable) ((IAdaptable)element).getAdapter(IFilterable.class);
+ }
+ if(decorator == null) {
+ decorator = (IFilterable) Platform.getAdapterManager().getAdapter(element, IFilterable.class);
+ }
+ return decorator;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITableFontProvider#getFont(java.lang.Object, int)
+ */
+ @Override
+ public Font getFont(Object element, int columnIndex) {
+ return fProvider.getFont(element, columnIndex);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITableColorProvider#getForeground(java.lang.Object, int)
+ */
+ @Override
+ public Color getForeground(Object element, int columnIndex) {
+ return fProvider.getForeground(element, columnIndex);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITableColorProvider#getBackground(java.lang.Object, int)
+ */
+ @Override
+ public Color getBackground(Object element, int columnIndex) {
+ return fProvider.getBackground(element, columnIndex);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/TreeViewerLabelProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/TreeViewerLabelProvider.java
index 07660e5de..f559f7d03 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/TreeViewerLabelProvider.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/TreeViewerLabelProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2013 Wind River Systems, Inc. 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
@@ -9,9 +9,15 @@
*******************************************************************************/
package org.eclipse.tcf.te.ui.trees;
+import org.eclipse.jface.viewers.IColorProvider;
+import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITableColorProvider;
+import org.eclipse.jface.viewers.ITableFontProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;
@@ -19,7 +25,7 @@ import org.eclipse.swt.widgets.TreeColumn;
/**
* File system tree control label provider implementation.
*/
-public class TreeViewerLabelProvider extends PendingAwareLabelProvider implements ITableLabelProvider {
+public class TreeViewerLabelProvider extends PendingAwareLabelProvider implements ITableLabelProvider, ITableColorProvider, ITableFontProvider {
// Reference to the parent tree viewer
private TreeViewer viewer;
@@ -32,12 +38,12 @@ public class TreeViewerLabelProvider extends PendingAwareLabelProvider implement
super();
this.viewer = viewer;
}
-
+
/**
- * Get the specific column's ColumnDescriptor object.
- * <b>NOTE:</b> <em>The returned descriptor might be null, if the column is the
+ * Get the specific column's ColumnDescriptor object. <b>NOTE:</b>
+ * <em>The returned descriptor might be null, if the column is the
* padding column on linux host.</em>
- *
+ *
* @param columnIndex the column index.
* @return The ColumnDescriptor object describing the column.
*/
@@ -69,7 +75,7 @@ public class TreeViewerLabelProvider extends PendingAwareLabelProvider implement
*/
@Override
public Image getColumnImage(Object element, int columnIndex) {
- if(element instanceof Pending) {
+ if (element instanceof Pending) {
return columnIndex == 0 ? super.getImage(element) : null;
}
ColumnDescriptor column = getColumn(columnIndex);
@@ -87,8 +93,8 @@ public class TreeViewerLabelProvider extends PendingAwareLabelProvider implement
*/
@Override
public String getColumnText(Object element, int columnIndex) {
- if(element instanceof Pending){
- return columnIndex == 0 ? super.getText(element) : ""; //$NON-NLS-1$
+ if (element instanceof Pending) {
+ return columnIndex == 0 ? super.getText(element) : ""; //$NON-NLS-1$
}
ColumnDescriptor column = getColumn(columnIndex);
if (column != null) {
@@ -99,4 +105,55 @@ public class TreeViewerLabelProvider extends PendingAwareLabelProvider implement
}
return ""; //$NON-NLS-1$
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITableFontProvider#getFont(java.lang.Object, int)
+ */
+ @Override
+ public Font getFont(Object element, int columnIndex) {
+ if (!(element instanceof Pending)) {
+ ColumnDescriptor column = getColumn(columnIndex);
+ if (column != null) {
+ ILabelProvider labelProvider = column.getLabelProvider();
+ if (labelProvider instanceof IFontProvider) {
+ return ((IFontProvider)labelProvider).getFont(element);
+ }
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITableColorProvider#getForeground(java.lang.Object, int)
+ */
+ @Override
+ public Color getForeground(Object element, int columnIndex) {
+ if (!(element instanceof Pending)) {
+ ColumnDescriptor column = getColumn(columnIndex);
+ if (column != null) {
+ ILabelProvider labelProvider = column.getLabelProvider();
+ if (labelProvider instanceof IColorProvider) {
+ return ((IColorProvider)labelProvider).getForeground(element);
+ }
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITableColorProvider#getBackground(java.lang.Object, int)
+ */
+ @Override
+ public Color getBackground(Object element, int columnIndex) {
+ if (!(element instanceof Pending)) {
+ ColumnDescriptor column = getColumn(columnIndex);
+ if (column != null) {
+ ILabelProvider labelProvider = column.getLabelProvider();
+ if (labelProvider instanceof IColorProvider) {
+ return ((IColorProvider)labelProvider).getBackground(element);
+ }
+ }
+ }
+ return null;
+ }
}

Back to the top