X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/blobdiff_plain/e0812cf204b15a6c263cb9f3a284d82c7004269a..ecf884346c2f8b00c6c7ae6acba8e8350be340c2:/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/MatrixRowComparator.java diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/MatrixRowComparator.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/MatrixRowComparator.java index 124d3be2d..d9eab66b0 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/MatrixRowComparator.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/MatrixRowComparator.java @@ -31,9 +31,9 @@ public class MatrixRowComparator implements Comparator{ private Comparator comparator; public MatrixRowComparator() { - if (PreferencesUtil.getSortNodesNaturally()){ + if (PreferencesUtil.isNodesSortedNaturally()){ comparator = new TaxonNaturalComparator(); - } else if (PreferencesUtil.getSortNodesStrictlyAlphabetically()){ + } else if (PreferencesUtil.isNodesSortedByName()){ comparator = new TaxonNodeByNameComparator(); }else { comparator = new TaxonNodeByRankAndNameComparator(); @@ -42,12 +42,26 @@ public class MatrixRowComparator implements Comparator{ @Override public int compare(Object o1, Object o2) { + if(o1 instanceof TaxonNode){ + if(o2 instanceof RowWrapperDTO){ + return 1; + } + } + else{ + if(o2 instanceof TaxonNode){ + return -1; + } + } if(o1 instanceof TaxonNode && o2 instanceof TaxonNode){ return comparator.compare((TaxonNode)o1, (TaxonNode)o2); } if(o1 instanceof RowWrapperDTO && o2 instanceof RowWrapperDTO){ RowWrapperDTO rowWrapper1 = (RowWrapperDTO)o1; RowWrapperDTO rowWrapper2 = (RowWrapperDTO)o2; + //check for equality + if(rowWrapper1.equals(rowWrapper2)){ + return 0; + } TaxonNode node1 = rowWrapper1.getTaxonNode().getParent(); TaxonNode node2 = rowWrapper2.getTaxonNode().getParent(); if(node1!=null && node2!=null){