Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2012-10-18 06:23:49 +0000
committerUwe Stieber2012-10-18 06:23:49 +0000
commit46d6bef1e99bd6ba14ad21e98524b21162672523 (patch)
tree9632c1fff7c5722151b52b23dcf24ed92552462f /target_explorer
parent54bdfdfd54264d3cd807ea3dabd06eaaff185906 (diff)
downloadorg.eclipse.tcf-46d6bef1e99bd6ba14ad21e98524b21162672523.tar.gz
org.eclipse.tcf-46d6bef1e99bd6ba14ad21e98524b21162672523.tar.xz
org.eclipse.tcf-46d6bef1e99bd6ba14ad21e98524b21162672523.zip
Target Explorer: Fix sorting in System Manager view is confused by node decoration
Diffstat (limited to 'target_explorer')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/TreeViewerSorter.java23
1 files changed, 19 insertions, 4 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/TreeViewerSorter.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/TreeViewerSorter.java
index 1359860fc..3e6dd2217 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/TreeViewerSorter.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/TreeViewerSorter.java
@@ -14,8 +14,12 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.jface.viewers.ContentViewer;
+import org.eclipse.jface.viewers.DecoratingLabelProvider;
+import org.eclipse.jface.viewers.DecoratingStyledCellLabelProvider;
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
import org.eclipse.jface.viewers.IBaseLabelProvider;
import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.StyledString;
import org.eclipse.jface.viewers.TreePathViewerSorter;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
@@ -51,8 +55,15 @@ public class TreeViewerSorter extends TreePathViewerSorter {
* @return The text for the given node and column index or <code>null</code>.
*/
protected String doGetText(Viewer viewer, Object node, int index) {
- if (node != null && doGetLabelProvider(viewer) != null) {
- return doGetLabelProvider(viewer).getText(node);
+ if (node != null) {
+ IBaseLabelProvider labelProvider = doGetLabelProvider(viewer);
+ if (labelProvider instanceof ILabelProvider) {
+ return ((ILabelProvider)labelProvider).getText(node);
+ }
+ if (labelProvider instanceof IStyledLabelProvider) {
+ StyledString text = ((IStyledLabelProvider)labelProvider).getStyledText(node);
+ return text != null ? text.getString() : null;
+ }
}
return null;
}
@@ -63,10 +74,14 @@ public class TreeViewerSorter extends TreePathViewerSorter {
* @param viewer The viewer or <code>null</code>.
* @return The label provider or <code>null</code>.
*/
- protected ILabelProvider doGetLabelProvider(Viewer viewer) {
+ protected IBaseLabelProvider doGetLabelProvider(Viewer viewer) {
if (viewer instanceof ContentViewer) {
IBaseLabelProvider candidate = ((ContentViewer)viewer).getLabelProvider();
- if (candidate instanceof ILabelProvider) return (ILabelProvider)candidate;
+ // We don't want any decoration, so unwrap the decorating label provider here
+ if (candidate instanceof DecoratingLabelProvider) candidate = ((DecoratingLabelProvider)candidate).getLabelProvider();
+ if (candidate instanceof DecoratingStyledCellLabelProvider) candidate = ((DecoratingStyledCellLabelProvider)candidate).getStyledStringProvider();
+ // Return the label provider
+ return candidate;
}
return null;
}

Back to the top