import org.eclipse.jface.viewers.ViewerComparator;
import eu.etaxonomy.cdm.model.taxon.Classification;
-import eu.etaxonomy.cdm.model.taxon.TaxonNaturalComparator;
-import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
public class TaxonNodeNavigatorComparator extends ViewerComparator{
-
- public TaxonNodeNavigatorComparator(Comparator<TaxonNode> comparator){
- super(comparator);
+ Comparator<TaxonNodeDto> comparator;
+
+ public TaxonNodeNavigatorComparator(Comparator<TaxonNodeDto> comparator){
+ super();
+ this.comparator = comparator;
}
-
-
+
+
@Override
public int compare(Viewer viewer, Object e1, Object e2){
- if (e1 instanceof Classification && e2 instanceof Classification){
+ if ((e1 instanceof Classification && e2 instanceof Classification) ){
return ((Classification)e1).getTitleCache().compareTo(((Classification)e2).getTitleCache());
} else{
- if (this.getComparator() instanceof TaxonNaturalComparator){
- return this.getComparator().compare((TaxonNode)e1, (TaxonNode)e2);
+ if (((TaxonNodeDto)e1).getTaxonUuid() == null && ((TaxonNodeDto)e2).getTaxonUuid() == null){
+ String title1 = ((TaxonNodeDto)e1).getTitleCache();
+ title1 = title1 == null ? "" : title1;
+ return title1.compareTo(((TaxonNodeDto)e2).getTitleCache());
}else{
- return this.getComparator().compare(e1,e2);
+ return comparator.compare((TaxonNodeDto)e1, (TaxonNodeDto)e2);
}
+
}
}
}