Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/tree/columns/ProcessComparator.java35
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/ColumnDescriptor.java14
2 files changed, 32 insertions, 17 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/ProcessComparator.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/tree/columns/ProcessComparator.java
index 05253ef0e..e7d4fcb9e 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/tree/columns/ProcessComparator.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/tree/columns/ProcessComparator.java
@@ -25,6 +25,17 @@ public class ProcessComparator implements Comparator<IProcessContextNode> , Seri
private static final long serialVersionUID = 1L;
private static LabelProvider labelProvider = new LabelProviderDelegate();
+ /**
+ * If or if not the sorting should happen case sensitive.
+ * <p>
+ * The default implementation returns <code>true</code>.
+ *
+ * @return <code>True</code> if the sorting is case sensitive, <code>false</code> otherwise.
+ */
+ protected boolean isCaseSensitve() {
+ return false;
+ }
+
/* (non-Javadoc)
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
@@ -38,13 +49,19 @@ public class ProcessComparator implements Comparator<IProcessContextNode> , Seri
String text1 = node1 == null ? null : labelProvider.getText(node1);
String text2 = node2 == null ? null : labelProvider.getText(node2);
- // Normalize labels
- if (text1 == null) text1 = ""; //$NON-NLS-1$
- if (text2 == null) text2 = ""; //$NON-NLS-1$
+ // If we fail to determine the labels, we cannot continue
+ if (text1 == null && text2 == null) return 0;
+ if (text1 != null && text2 == null) return 1;
+ if (text1 == null && text2 != null) return -1;
+
+ // Convert the labels to compare to lowercase if the sorting is case-insensitive
+ if (!isCaseSensitve()) {
+ text1 = text1.toLowerCase();
+ text2 = text2.toLowerCase();
+ }
// The tree sorts not strictly alphabetical. First comes entries starting with numbers,
- // second entries starting with uppercase and than all the rest. Additional, if a label
- // contains
+ // second entries starting with uppercase and than all the rest. Additional, if a label contains
// uppercase characters, it is sorted in before any labels being lowercase only.
if (text1.length() > 0 && text2.length() > 0) {
// Get the first characters of both
@@ -58,8 +75,7 @@ public class ProcessComparator implements Comparator<IProcessContextNode> , Seri
}
if (Character.isUpperCase(c1) || Character.isUpperCase(c2)) {
- // Check on the differences. If both are uppercase characters, the standard compare
- // will do it
+ // Check on the differences. If both are uppercase characters, the standard compare will do it
if (Character.isUpperCase(c1) && !Character.isUpperCase(c2)) return -1;
if (!Character.isUpperCase(c1) && Character.isUpperCase(c2)) return 1;
}
@@ -84,9 +100,7 @@ public class ProcessComparator implements Comparator<IProcessContextNode> , Seri
if (l1 < l2) result = -1;
return result;
- }
- catch (NumberFormatException e) { /* ignored on purpose */
- }
+ } catch (NumberFormatException e) { /* ignored on purpose */ }
}
}
@@ -108,6 +122,7 @@ public class ProcessComparator implements Comparator<IProcessContextNode> , Seri
}
}
}
+
return text1.compareTo(text2);
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/ColumnDescriptor.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/ColumnDescriptor.java
index 946cd7105..0ca14a843 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/ColumnDescriptor.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/ColumnDescriptor.java
@@ -27,7 +27,7 @@ import org.eclipse.swt.widgets.TreeColumn;
* <li><code>name</code>, the column's name used as the column's label.</li>
* <li><code>description</code>, the column's description used as the tooltip
* text of the column.</li>
- * <li><code>moveable</code>, if the column is moveable.</li>
+ * <li><code>moveable</code>, if the column is move able.</li>
* <li><code>resizable</code>, if the column is resizable.</li>
* <li><code>visible</code>, if the column is visible.</li>
* <li><code>style</code>, the column's style when it is created.</li>
@@ -49,8 +49,8 @@ public class ColumnDescriptor {
//The description of the column, used as the column's tooltip text.
private String description;
- //If the column is moveable.
- private boolean mveable;
+ //If the column is move able.
+ private boolean moveable;
//If the column is resizable, true by default.
private boolean resizable = true;
//If the column is visible, true by default.
@@ -224,16 +224,16 @@ public class ColumnDescriptor {
* @param m The new value.
*/
public void setMoveable(boolean m) {
- mveable = m;
+ moveable = m;
}
/**
- * Get if the column is moveable.
+ * Get if the column is move able.
*
- * @return If the column is moveable.
+ * @return If the column is move able.
*/
public boolean isMoveable() {
- return mveable;
+ return moveable;
}
/**

Back to the top