395d202e523fff887cbdc8e794b7b6f9c976457f
[taxeditor.git] / eu.etaxonomy.taxeditor.navigation / src / main / java / eu / etaxonomy / taxeditor / navigation / navigator / TaxonNodeComparator.java
1 package eu.etaxonomy.taxeditor.navigation.navigator;
2
3 import java.util.Arrays;
4
5
6 import org.eclipse.jface.viewers.Viewer;
7 import org.eclipse.jface.viewers.ViewerComparator;
8
9
10 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
11 import eu.etaxonomy.cdm.model.taxon.TaxonComparatorSearch;
12 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
13
14 public class TaxonNodeComparator extends ViewerComparator{
15
16
17 public TaxonNodeComparator(TaxonComparatorSearch comparator) {
18 super(comparator);
19 }
20
21 @Override
22 public void sort(final Viewer viewer, Object[] elements) {
23
24 TaxonBase[] nodesArray = new TaxonBase[elements.length];
25 if (elements.length>1){
26 for(int i=0; i<elements.length; i++){
27 nodesArray[i] = ((TaxonNode)elements[i]).getTaxon();
28 }
29 Arrays.sort(nodesArray, this.getComparator());
30 }
31 }
32 }