Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2015-01-30 08:26:21 -0500
committerUwe Stieber2015-01-30 08:26:21 -0500
commitd3a6dc64c19a3abe2f740effecefd6d6a65c4b38 (patch)
tree906b7952d57d395c7997b93abc8631fe6c852e60
parent4ba79a77eb069d37389db861571953981f48666e (diff)
downloadorg.eclipse.tcf-d3a6dc64c19a3abe2f740effecefd6d6a65c4b38.tar.gz
org.eclipse.tcf-d3a6dc64c19a3abe2f740effecefd6d6a65c4b38.tar.xz
org.eclipse.tcf-d3a6dc64c19a3abe2f740effecefd6d6a65c4b38.zip
Target Explorer: Fix sorting of tree columns is wrong if the column represent number only (i.e. PID)
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/TreeViewerSorter.java20
1 files changed, 18 insertions, 2 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 770d12f9d..9e3277727 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
@@ -203,6 +203,8 @@ public class TreeViewerSorter extends TreePathViewerSorter {
if (!Character.isUpperCase(c1) && Character.isUpperCase(c2)) return 1 * inverter;
}
+ // If the text to compare is kind of "<text><number>", and the "<text>" part
+ // is the same, compare the numbers as number.
Matcher m1 = Pattern.compile("(\\D+)(\\d+)").matcher(text1); //$NON-NLS-1$
Matcher m2 = Pattern.compile("(\\D+)(\\d+)").matcher(text2); //$NON-NLS-1$
if (m1.matches() && m2.matches()) {
@@ -219,14 +221,28 @@ public class TreeViewerSorter extends TreePathViewerSorter {
long l1 = Long.parseLong(p12);
long l2 = Long.parseLong(p22);
- if (l1 > l2) result = 1;
- if (l1 < l2) result = -1;
+ if (l1 > l2) result = 1 * inverter;
+ if (l1 < l2) result = -1 * inverter;
return result;
} catch (NumberFormatException e) { /* ignored on purpose */ }
}
}
+ // If the text to compare represents a number after all, compare it as numbers
+ if (text1.matches("\\d+") && text2.matches("\\d+")) { //$NON-NLS-1$ //$NON-NLS-2$
+ try {
+ int result = 0;
+ long l1 = Long.parseLong(text1);
+ long l2 = Long.parseLong(text2);
+
+ if (l1 > l2) result = 1 * inverter;
+ if (l1 < l2) result = -1 * inverter;
+
+ return result;
+ } catch (NumberFormatException e) { /* ignored on purpose */ }
+ }
+
if (text1.matches(".*[A-Z]+.*") || text2.matches(".*[A-Z]+.*")) { //$NON-NLS-1$ //$NON-NLS-2$
if (text1.matches(".*[A-Z]+.*") && !text2.matches(".*[A-Z]+.*")) return -1 * inverter; //$NON-NLS-1$ //$NON-NLS-2$
if (!text1.matches(".*[A-Z]+.*") && text2.matches(".*[A-Z]+.*")) return 1 * inverter; //$NON-NLS-1$ //$NON-NLS-2$

Back to the top