]>
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
.RepoElem
;
5 import org
.argeo
.slc
.client
.ui
.dist
.model
.WkspGroupElem
;
6 import org
.argeo
.slc
.client
.ui
.dist
.model
.WorkspaceElem
;
7 import org
.eclipse
.jface
.viewers
.Viewer
;
8 import org
.eclipse
.jface
.viewers
.ViewerComparator
;
10 /** Specific comparator to enhance Distribution tree browsers */
11 public class DistTreeComparator
extends ViewerComparator
{
13 public int category(Object element
) {
14 if (element
instanceof RepoElem
)
15 if (((RepoElem
) element
).inHome())
16 // Home repository always first
20 else if (element
instanceof WkspGroupElem
)
22 else if (element
instanceof WorkspaceElem
)
28 public int compare(Viewer viewer
, Object e1
, Object e2
) {
29 int cat1
= category(e1
);
30 int cat2
= category(e2
);
38 if (e1
instanceof DistParentElem
) {
39 s1
= ((DistParentElem
) e1
).getName();
40 s2
= ((DistParentElem
) e2
).getName();
46 if (e1
instanceof WorkspaceElem
)
47 // Reverse order for versions
48 return s2
.compareTo(s1
);
50 return s1
.compareTo(s2
);