Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Piggott2011-04-18 16:06:55 -0400
committerMatthew Piggott2011-04-18 18:01:10 -0400
commit8fb9652f1391d524d1facba9ff6cf9580b44fa12 (patch)
tree410f5aa3e9e2ed5a69d9f713e30ae90fc8cf7702
parent26db6c0e1a9eca57603e12aefb1a424719e01cbf (diff)
downloadm2e-core-8fb9652f1391d524d1facba9ff6cf9580b44fa12.tar.gz
m2e-core-8fb9652f1391d524d1facba9ff6cf9580b44fa12.tar.xz
m2e-core-8fb9652f1391d524d1facba9ff6cf9580b44fa12.zip
LifecycleMappingPage - Sort tree elements by Maven column
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/LifecycleMappingPage.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/LifecycleMappingPage.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/LifecycleMappingPage.java
index 620136e1..a411a19f 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/LifecycleMappingPage.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/LifecycleMappingPage.java
@@ -34,6 +34,7 @@ import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.TreeViewerColumn;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
@@ -395,6 +396,22 @@ public class LifecycleMappingPage extends WizardPage {
}
});
+ treeViewer.setComparator(new ViewerComparator() {
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ if(!(e1 instanceof ILifecycleMappingLabelProvider && e2 instanceof ILifecycleMappingLabelProvider)) {
+ return super.compare(viewer, e1, e2);
+ }
+ int cat1 = category(e1);
+ int cat2 = category(e2);
+
+ if(cat1 != cat2) {
+ return cat1 - cat2;
+ }
+ return ((ILifecycleMappingLabelProvider) e1).getMavenText().compareTo(
+ ((ILifecycleMappingLabelProvider) e2).getMavenText());
+ }
+ });
+
Composite composite = new Composite(container, SWT.NONE);
composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
composite.setLayout(new GridLayout(3, false));

Back to the top