]>
git.argeo.org Git - gpl/argeo-slc.git/blob - plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/controllers/DistTreeComparator.java
1 package org
.argeo
.slc
.client
.ui
.dist
.controllers
;
3 import org
.argeo
.slc
.client
.ui
.dist
.model
.DistParentElem
;
4 import org
.argeo
.slc
.client
.ui
.dist
.model
.ModularDistVersionElem
;
5 import org
.argeo
.slc
.client
.ui
.dist
.model
.RepoElem
;
6 import org
.argeo
.slc
.client
.ui
.dist
.model
.WkspGroupElem
;
7 import org
.argeo
.slc
.client
.ui
.dist
.model
.WorkspaceElem
;
8 import org
.eclipse
.jface
.viewers
.Viewer
;
9 import org
.eclipse
.jface
.viewers
.ViewerComparator
;
11 /** Specific comparator to enhance Distribution tree browsers */
12 public class DistTreeComparator
extends ViewerComparator
{
14 public int category(Object element
) {
15 if (element
instanceof RepoElem
)
16 if (((RepoElem
) element
).inHome())
17 // Home repository always first
21 else if (element
instanceof WkspGroupElem
)
23 else if (element
instanceof WorkspaceElem
)
29 public int compare(Viewer viewer
, Object e1
, Object e2
) {
30 int cat1
= category(e1
);
31 int cat2
= category(e2
);
39 if (e1
instanceof DistParentElem
) {
40 s1
= ((DistParentElem
) e1
).getName();
41 s2
= ((DistParentElem
) e2
).getName();
47 if (e1
instanceof WorkspaceElem
|| e1
instanceof ModularDistVersionElem
)
48 // Reverse order for versions
49 return s2
.compareTo(s1
);
51 return s1
.compareTo(s2
);