commit df366db549e422a21b550372b78a70b1f68f05a2
Author: Katja Luther <k.luther@bgbm.org>
Date:   Thu Feb 9 14:29:28 2017 +0100

    ref #4232: some more comparators to adapt

diff --git a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/sortprovider/ReferenceSortProvider.java b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/sortprovider/ReferenceSortProvider.java
index c61b504d4..ebdc23b07 100644
--- a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/sortprovider/ReferenceSortProvider.java
+++ b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/sortprovider/ReferenceSortProvider.java
@@ -1,8 +1,8 @@
 /**
 * Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy 
+* European Distributed Institute of Taxonomy
 * http://www.e-taxonomy.eu
-* 
+*
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 * See LICENSE.TXT at the top of this package for the full license terms.
 */
@@ -22,7 +22,7 @@ import eu.etaxonomy.cdm.model.reference.Reference;
 public class ReferenceSortProvider extends AbstractSortProvider<Reference> {
 
 	/**
-	 * 
+	 *
 	 */
 	public ReferenceSortProvider() {
 		comparators.put("Type", new ReferenceTypeComparator());
@@ -30,20 +30,21 @@ public class ReferenceSortProvider extends AbstractSortProvider<Reference> {
 	}
 
 	private class ReferenceYearComparator implements Comparator<Reference> {
-		
+
 		/**
 		 * @param o1
 		 * @return
 		 */
 		private String getYearString(Reference o) {
-			TimePeriod datePublished = o == null ? null : o.getDatePublished(); 
+			TimePeriod datePublished = o == null ? null : o.getDatePublished();
 			return datePublished == null? null : datePublished.toString();
 		}
-		
+
 		/* (non-Javadoc)
 		 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
 		 */
-		public int compare(Reference o1, Reference o2) {
+		@Override
+        public int compare(Reference o1, Reference o2) {
 			String yearString1 = getYearString(o1);
 			String yearString2 = getYearString(o2);
 			if (yearString1 == null) {
@@ -58,19 +59,21 @@ public class ReferenceSortProvider extends AbstractSortProvider<Reference> {
 			}
 			int returnVal = yearString1.compareToIgnoreCase(yearString2);
 			if (returnVal == 0) {
-				return new TitleCacheComparator<Reference>().compare(o1, o2);
-			} else {
-				return returnVal;
+				returnVal = new TitleCacheComparator<Reference>().compare(o1, o2);
+
 			}
-		}		
+			return returnVal;
+
+		}
 	}
-	
+
 	private class ReferenceTypeComparator implements Comparator<Reference> {
-		
+
 		/* (non-Javadoc)
 		 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
 		 */
-		public int compare(Reference o1, Reference o2) {
+		@Override
+        public int compare(Reference o1, Reference o2) {
 			String typeString1 = o1.getClass().toString();
 			String typeString2 = o2.getClass().toString();
 			if (typeString1 == null) {
@@ -85,12 +88,13 @@ public class ReferenceSortProvider extends AbstractSortProvider<Reference> {
 			}
 			int returnVal = typeString1.compareToIgnoreCase(typeString2);
 			if (returnVal == 0) {
+			    //the TitleCacheComparator already fulfills the comparator contract
 				return new TitleCacheComparator<Reference>().compare(o1, o2);
 			} else {
 				return returnVal;
 			}
-		}		
+		}
 	}
 
-	
+
 }
diff --git a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/sortprovider/TitleCacheComparator.java b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/sortprovider/TitleCacheComparator.java
index 842417ca8..4d5892d96 100644
--- a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/sortprovider/TitleCacheComparator.java
+++ b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/sortprovider/TitleCacheComparator.java
@@ -1,8 +1,8 @@
 /**
 * Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy 
+* European Distributed Institute of Taxonomy
 * http://www.e-taxonomy.eu
-* 
+*
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 * See LICENSE.TXT at the top of this package for the full license terms.
 */
@@ -21,18 +21,19 @@ import eu.etaxonomy.cdm.model.common.IIdentifiableEntity;
  * @version 1.0
  */
 public class TitleCacheComparator<T extends IIdentifiableEntity> implements Comparator<T> {
-	
+
     private boolean fIgnoreCase;
 
 	private String getTitleCache(T o) {
 		return o == null ? null : o.getTitleCache();
 	}
-	
+
 	/* (non-Javadoc)
 	 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
 	 */
 	/** {@inheritDoc} */
-	public int compare(T o1, T o2) {
+	@Override
+    public int compare(T o1, T o2) {
 		String titleCache1 = getTitleCache(o1);
 		String titleCache2 = getTitleCache(o2);
 		if (titleCache1 == null && titleCache2 == null) {
@@ -43,8 +44,13 @@ public class TitleCacheComparator<T extends IIdentifiableEntity> implements Comp
 		}
 		if (titleCache2 == null) {
 			return 1;
-		}				
-        return fIgnoreCase ? titleCache1.compareToIgnoreCase(titleCache2) : 
+		}
+        int result =  fIgnoreCase ? titleCache1.compareToIgnoreCase(titleCache2) :
         						titleCache1.compareTo(titleCache2);
+
+        if (result == 0){
+            result = o1.getUuid().compareTo(o2.getUuid());
+        }
+        return result;
 	}
 }
diff --git a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/referencingobjects/ReferencingObjectsView.java b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/referencingobjects/ReferencingObjectsView.java
index a97a1704f..2ac4a7925 100644
--- a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/referencingobjects/ReferencingObjectsView.java
+++ b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/referencingobjects/ReferencingObjectsView.java
@@ -342,21 +342,23 @@ public class ReferencingObjectsView extends AbstractCdmViewPart {
 	}
 
 
-	class ReferencingClassComparator implements Comparator<CdmBase> {
+	class ReferencingClassComparator implements Comparator<CdmBase>   {
 
 		@Override
         public int compare(CdmBase o1, CdmBase o2) {
 			String string1 = o1.getClass().getSimpleName();
 			String string2 = o2.getClass().getSimpleName();
-			int classCompare = string1.compareToIgnoreCase(string2);
-			if (classCompare == 0) {
+			int result = string1.compareToIgnoreCase(string2);
+			if (result == 0) {
 				string1 = DescriptionHelper.getObjectDescription(o1);
 				string2 = DescriptionHelper.getObjectDescription(o2);
 
-				return string1.compareToIgnoreCase(string2);
-			} else {
-				return classCompare;
+				result = string1.compareToIgnoreCase(string2);
+				if (result == 0){
+				    return o1.getUuid().compareTo(o2.getUuid());
+				}
 			}
+				return result;
 		}
 	}
 
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/DefinedTermMenu.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/DefinedTermMenu.java
index 9bc72b20b..da41ff5e2 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/DefinedTermMenu.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/DefinedTermMenu.java
@@ -170,7 +170,14 @@ public class DefinedTermMenu extends CompoundContributionItem {
 	private class SortByTermTypeMessage implements Comparator<TermType> {
 	    @Override
         public int compare(TermType t1, TermType t2) {
-	        return t1.getMessage().compareTo(t2.getMessage());
+	        if (t1.equals(t2)){
+	            return 0;
+	        }
+	        int result = t1.getMessage().compareTo(t2.getMessage());
+	        if (result == 0){
+	            return t1.compareTo(t2);
+	        }
+	        return result;
 	    }
 	}
 
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ExportToFileDestinationWizardPage.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ExportToFileDestinationWizardPage.java
index 91a5edd78..461336da7 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ExportToFileDestinationWizardPage.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ExportToFileDestinationWizardPage.java
@@ -68,13 +68,13 @@ public class ExportToFileDestinationWizardPage extends WizardPage implements Sel
 	public static final String XML = "xml";
 
 	public static final String CSV = "csv";
-	
-	
+
+
 
 	public static final String ZIP = "zip";
 
     private static boolean csvExport = false;
-    
+
     private static boolean csvNameExport = false;
 
 	private static String CSV_PRINT_EXPORT ="CSV_PRINT_EXPORT";
@@ -91,9 +91,9 @@ public class ExportToFileDestinationWizardPage extends WizardPage implements Sel
 	private final String extension;
 
     private Combo classificationSelectionCombo;
-    
+
     private List<Classification> classifications;
-    
+
     private Classification selectedClassification;
 
 	/**
@@ -190,7 +190,7 @@ public class ExportToFileDestinationWizardPage extends WizardPage implements Sel
                 "Export the contents of the currently selected database into Comma Separated Value format.",
                 CSV);
     }
-    
+
     /**
      * @return
      */
@@ -203,7 +203,7 @@ public class ExportToFileDestinationWizardPage extends WizardPage implements Sel
                 "Export the names of the currently selected database into Semicolon Separated Value format.",
                 CSV);
     }
-    
+
     /**
      * @return
      */
@@ -240,10 +240,17 @@ public class ExportToFileDestinationWizardPage extends WizardPage implements Sel
 
                 @Override
                 public int compare(Classification o1, Classification o2) {
-                    return o1.getTitleCache().compareTo(o2.getTitleCache());
+                    if (o1.equals(o2)){
+                        return 0;
+                    }
+                    int result = o1.getTitleCache().compareTo(o2.getTitleCache());
+                    if (result == 0){
+                        return o1.getUuid().compareTo(o2.getUuid());
+                    }
+                    return result;
                 }
             });
-			
+
 			selectedClassification = classifications.iterator().next();
 		}
 
@@ -251,13 +258,13 @@ public class ExportToFileDestinationWizardPage extends WizardPage implements Sel
 		if(csvExport || csvPrintExport){
 		    Label comboBoxLabel = new Label(composite, SWT.NONE);
 		    comboBoxLabel.setText("Classification");
-		   
+
 		    createClassificationSelectionCombo(composite);
 		    classificationSelectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL,
 		                true, false, 2, 1));
 		}
-		
-		
+
+
 
 
 		Label fileLabel = new Label(composite, SWT.NONE);
@@ -385,17 +392,17 @@ public class ExportToFileDestinationWizardPage extends WizardPage implements Sel
 	@Override
 	public void widgetSelected(SelectionEvent e) {
 		selectedClassification = classifications.get(classificationSelectionCombo.getSelectionIndex());
-		
+
 	}
 
 	@Override
 	public void widgetDefaultSelected(SelectionEvent e) {
 		//not needed here
-		
+
 	}
 
 	public UUID getSelectedClassificationUUID() {
-		
+
 		return selectedClassification.getUuid();
 	}
 
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/GenericConfiguratorWizardPage.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/GenericConfiguratorWizardPage.java
index eb1447459..f70d34148 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/GenericConfiguratorWizardPage.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/GenericConfiguratorWizardPage.java
@@ -137,6 +137,9 @@ public class GenericConfiguratorWizardPage extends WizardPage {
              */
             @Override
             public int compare(Method o1, Method o2) {
+                if (o1.equals(o2)){
+                    return 0;
+                }
                 if(o1.getName()==null && o2.getName()!=null){
                     return -1;
                 }
@@ -144,9 +147,13 @@ public class GenericConfiguratorWizardPage extends WizardPage {
                     return 1;
                 }
                 if(o1.getName()==null && o2.getName()==null){
-                    return 0;
+                    return o1.toString().compareTo(o1.toString());
+                }
+                int result = o1.getName().compareTo(o2.getName());
+                if (result == 0){
+                    return o1.toString().compareTo(o1.toString());
                 }
-                return o1.getName().compareTo(o2.getName());
+                return result;
             }
         });
 
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/DefaultTermComparator.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/DefaultTermComparator.java
index ef08badd6..9abcbb67d 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/DefaultTermComparator.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/DefaultTermComparator.java
@@ -1,8 +1,8 @@
 /**
 * Copyright (C) 2009 EDIT
-* European Distributed Institute of Taxonomy 
+* European Distributed Institute of Taxonomy
 * http://www.e-taxonomy.eu
-* 
+*
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 * See LICENSE.TXT at the top of this package for the full license terms.
 */
@@ -17,7 +17,7 @@ import eu.etaxonomy.taxeditor.store.CdmStore;
  * Implements a {@link Comparator} for {@link DefinedTermBase} objects based on the term's label.
  * The compare algorithm compares a term's label. Example: If used on an unsorted list of terms, the
  * list will be alphabetically  sorted by label afterwards.
- * 
+ *
  * @author n.hoffmann
  * @date Jan 18, 2012
  *
@@ -36,6 +36,10 @@ public class DefaultTermComparator<T extends DefinedTermBase> implements Compara
 		}
 		String label1 = o1.getLabel(CdmStore.getDefaultLanguage()) != null ? o1.getLabel(CdmStore.getDefaultLanguage()) : o1.getTitleCache();
 		String label2 = o2.getLabel(CdmStore.getDefaultLanguage()) != null ? o2.getLabel(CdmStore.getDefaultLanguage()) : o2.getTitleCache();
-		return label1.compareTo(label2);
+		int result = label1.compareTo(label2);
+		if (result == 0){
+		    return o1.getUuid().compareTo(o2.getUuid());
+		}
+		return result;
 	}
 };
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/FeatureNodeContainerTree.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/FeatureNodeContainerTree.java
index 55bf93082..c337da240 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/FeatureNodeContainerTree.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/FeatureNodeContainerTree.java
@@ -1,8 +1,8 @@
 /**
 * Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy 
+* European Distributed Institute of Taxonomy
 * http://www.e-taxonomy.eu
-* 
+*
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 * See LICENSE.TXT at the top of this package for the full license terms.
 */
@@ -37,25 +37,32 @@ public class FeatureNodeContainerTree {
 
 		@Override
 		public int compare(DescriptionElementBase o1, DescriptionElementBase o2) {
-			return DescriptionHelper.getLabel(o1).compareTo(DescriptionHelper.getLabel(o2));
+		    if (o1.equals(o2)){
+		        return 0;
+		    }
+			int result = DescriptionHelper.getLabel(o1).compareTo(DescriptionHelper.getLabel(o2));
+			if (result == 0){
+			    return o1.getUuid().compareTo(o2.getUuid());
+			}
+			return result;
 		}
 	};
-	
+
 	private Set<FeatureNodeContainer> featureNodeContainers = new HashSet<FeatureNodeContainer>();
-	
+
 	private FeatureNodeContainer root;
 	private DescriptionBase description;
 	private FeatureTree featureTree;
-	
+
 	public FeatureNodeContainerTree(DescriptionBase description, FeatureTree featureTree){
 		this.description = description;
 		this.featureTree = featureTree;
-		
+
 		root = new FeatureNodeContainer(this);
-		
+
 		buildTree();
 	}
-	
+
 	/**
 	 * Traverses the given {@link FeatureNode} and computes a FeatureNodeContainer branch if the
 	 * given {@link TaxonDescription} has elements for the given feature node or any of its children
@@ -63,16 +70,16 @@ public class FeatureNodeContainerTree {
 	 */
 	public void buildTree(){
 		List<FeatureNode> children = featureTree.getRootChildren();
-		
+
 //		if(description.getElements().isEmpty()){
 //			return;
 //		}
-		
+
 		for(FeatureNode featureNode : children){
 			root.findLeaves(featureNode);
 		}
 	}
-	
+
 	/**
 	 * <p>getFeatureNodeContainerForDescriptionElement</p>
 	 *
@@ -81,7 +88,7 @@ public class FeatureNodeContainerTree {
 	 */
 	public FeatureNodeContainer getFeatureNodeContainerForDescriptionElement (DescriptionElementBase descriptionElement) {
 		List<FeatureNodeContainer> leafs = root.getLeafs();
-		
+
 		for(FeatureNodeContainer container : leafs){
 			if(container.getDescriptionElements().contains(descriptionElement)){
 				return container;
@@ -89,40 +96,40 @@ public class FeatureNodeContainerTree {
 		}
 		return null;
 	}
-	
+
 	/**
 	 * Returns all elements contained in the given {@link DescriptionBase description} that have the given {@link Feature feature}.
-	 * 
+	 *
 	 * @param description
 	 * @param feature
 	 * @return a list of description elements with the given feature alphabetically sorted by {@link DescriptionHelper#getLabel(Object)}
 	 */
 	public List<DescriptionElementBase> getDescriptionsElementsForFeature(Feature feature) {
 		List<DescriptionElementBase> featureElements = new ArrayList<DescriptionElementBase>();
-		
+
 		Set<DescriptionElementBase> elements = description.getElements();
-		
+
 		if (elements != null) {
 			for (DescriptionElementBase element : elements) {
-				Feature elementFeature = (Feature) HibernateProxyHelper.deproxy(element.getFeature());
-				
+				Feature elementFeature = HibernateProxyHelper.deproxy(element.getFeature());
+
 				if (feature.equals(elementFeature)) {
 					featureElements.add(element);
 				}
 			}
 		}
-		
+
 		if(featureElements.size() != 0){
 			Collections.sort(featureElements, comparator);
 		}
-		
+
 		return featureElements;
 	}
-	
-	
-	public FeatureNodeContainer getFeatureNodeContainer(Feature feature) {		
+
+
+	public FeatureNodeContainer getFeatureNodeContainer(Feature feature) {
 		List<FeatureNodeContainer> leafs = root.getLeafs();
-		
+
 		for(FeatureNodeContainer container : leafs){
 			if(container.getFeature().equals(feature)){
 				return container;
@@ -130,10 +137,10 @@ public class FeatureNodeContainerTree {
 		}
 		return null;
 	}
-	
+
 	public FeatureNodeContainer getFeatureNodeContainer(FeatureNode featureNode){
 		List<FeatureNodeContainer> leafs = root.getLeafs();
-		
+
 		for(FeatureNodeContainer container : leafs){
 			if(container.getFeatureNode().equals(featureNode)){
 				return container;
@@ -141,18 +148,18 @@ public class FeatureNodeContainerTree {
 		}
 		return null;
 	}
-	
+
 	public void addContainer(FeatureNodeContainer container){
 		featureNodeContainers.add(container);
 	}
 
 	/**
-	 * 
+	 *
 	 */
 	public void removeContainer(FeatureNodeContainer container) {
 		featureNodeContainers.remove(container);
 	}
-	
+
 	public FeatureNodeContainer getRoot() {
 		return root;
 	}
@@ -164,5 +171,5 @@ public class FeatureNodeContainerTree {
 	public FeatureTree getFeatureTree() {
 		return featureTree;
 	}
-	
+
 }
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/AbstractFilteredCdmEnumSelectionDialog.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/AbstractFilteredCdmEnumSelectionDialog.java
index e02afa3c9..792a10026 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/AbstractFilteredCdmEnumSelectionDialog.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/AbstractFilteredCdmEnumSelectionDialog.java
@@ -49,55 +49,55 @@ public abstract class AbstractFilteredCdmEnumSelectionDialog<T extends IEnumTerm
 
 	private ConversationHolder conversation;
 
-	protected List<T> model;	
-	private String settings;	
-	
-	
-	
+	protected List<T> model;
+	private String settings;
+
+
+
 	/**
 	 * <p>Constructor for AbstractFilteredCdmResourceSelectionDialog.</p>
 	 *
 	 * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
-	 * @param conversation 
+	 * @param conversation
 	 * @param title a {@link java.lang.String} object.
 	 * @param multi a boolean.
 	 * @param settings a {@link java.lang.String} object.
 	 * @param cdmEnum a T object.
 	 * @param <T> a T object.
 	 */
-	protected AbstractFilteredCdmEnumSelectionDialog(Shell shell, 
-			ConversationHolder conversation, 
-			String title, 
-			boolean multi, 
+	protected AbstractFilteredCdmEnumSelectionDialog(Shell shell,
+			ConversationHolder conversation,
+			String title,
+			boolean multi,
 			String settings,
 			T cdmEnum) {
 		super(shell, multi);
 		setTitle(title);
 		setMessage("Use * for wildcard, or ? to see all entries");
 		this.settings = settings;
-		
+
 		this.conversation = conversation;
-		
+
 		init();
-		
+
 		initModel();
-		
+
 		String objectTitle = getTitle(cdmEnum);
 		if (objectTitle != null) {
 			setInitialPattern(objectTitle);
 		}
-		
+
 		setListLabelProvider(createListLabelProvider());
 		setDetailsLabelProvider(createDetailsLabelProvider());
-		
+
 		setSelectionHistory(new ResourceSelectionHistory());
 	}
-	
+
 	/**
 	 * By default, we are returning the standard list label provider
-	 * 
-	 * Override in subclasses if you want different behavior 
-	 * 
+	 *
+	 * Override in subclasses if you want different behavior
+	 *
 	 * @return
 	 */
 	protected ILabelProvider createDetailsLabelProvider() {
@@ -105,7 +105,7 @@ public abstract class AbstractFilteredCdmEnumSelectionDialog<T extends IEnumTerm
 	}
 
 	/**
-	 * 
+	 *
 	 * @return
 	 */
 	protected ILabelProvider createListLabelProvider() {
@@ -117,9 +117,9 @@ public abstract class AbstractFilteredCdmEnumSelectionDialog<T extends IEnumTerm
 	 * Will run before initModel()
 	 */
 	protected void init() {
-		
+
 	}
-	
+
 	/**
 	 * <p>getSelectionFromDialog</p>
 	 *
@@ -128,13 +128,13 @@ public abstract class AbstractFilteredCdmEnumSelectionDialog<T extends IEnumTerm
 	 * @return a TYPE object.
 	 */
 	protected static <TYPE extends IEnumTerm> TYPE getSelectionFromDialog(AbstractFilteredCdmEnumSelectionDialog<TYPE> dialog) {
-		
+
 		int result = dialog.open();
-		
+
 		if (result == Window.CANCEL) {
 			return null;
 		}
-		
+
 		return dialog.getSelectedEnumTerm();
 	}
 
@@ -148,15 +148,15 @@ public abstract class AbstractFilteredCdmEnumSelectionDialog<T extends IEnumTerm
 	protected String getTitle(T cdmEnum) {
 		return cdmEnum.getMessage();
 	}
-	
+
 
 	/** {@inheritDoc} */
 	@Override
 	public void refresh() {
-		initModel();		
+		initModel();
 		super.refresh();
 	}
-	
+
 	/**
 	 * <p>initModel</p>
 	 */
@@ -177,7 +177,7 @@ public abstract class AbstractFilteredCdmEnumSelectionDialog<T extends IEnumTerm
 			public boolean equalsFilter(ItemsFilter filter) {
 				return false;
 			}
-			
+
 			@Override
 			public boolean isConsistentItem(Object item) {
 				return false;
@@ -193,10 +193,10 @@ public abstract class AbstractFilteredCdmEnumSelectionDialog<T extends IEnumTerm
 				}
 				return text != null ? matches(text) : false;
 			}
-			
+
 		};
 	}
-	
+
 
 	/**
 	 * Set the filter input to the Agent's title cache
@@ -204,11 +204,11 @@ public abstract class AbstractFilteredCdmEnumSelectionDialog<T extends IEnumTerm
 	 * @param cdmObject a T object.
 	 */
 	protected void setPattern(T cdmObject) {
-		// FilteredSelection does some very tricky caching to make sure it 
-		// runs with high performance. 
+		// FilteredSelection does some very tricky caching to make sure it
+		// runs with high performance.
 		// This works for most use cases, but we want to change the model while the dialog is open
 		// and all the clever caching prevents the content provider from knowing that the model has changed
-		// I am aware, that this is a hack, but the FilteredSelectionDialog API does not offer a convenient 
+		// I am aware, that this is a hack, but the FilteredSelectionDialog API does not offer a convenient
 		// way to solve the problem.
 		try {
 			Field lastCompletedFilter = this.getClass().getSuperclass().getSuperclass().getDeclaredField("lastCompletedFilter");
@@ -223,14 +223,14 @@ public abstract class AbstractFilteredCdmEnumSelectionDialog<T extends IEnumTerm
 		} catch (IllegalAccessException e) {
 			MessagingUtils.error(getClass(), e);
 		}
-		
-		// this also is not the nicest way to do it. 
+
+		// this also is not the nicest way to do it.
 		// I am still amazed, that FilteredSelectionDialog does not offer any methods to change its data
 		// once it was opened. Am I doing it wrong?
 		String pattern = getTitle(cdmObject);
 		((Text) getPatternControl()).setText(pattern);
 	}
-	
+
 	/* (non-Javadoc)
 	* @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#fillContentProvider(org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.AbstractContentProvider, org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.ItemsFilter, org.eclipse.core.runtime.IProgressMonitor)
 	*/
@@ -240,7 +240,7 @@ public abstract class AbstractFilteredCdmEnumSelectionDialog<T extends IEnumTerm
 		ItemsFilter itemsFilter, IProgressMonitor progressMonitor)
 		throws CoreException {
 		try {
-			if(model != null){				
+			if(model != null){
 				progressMonitor.beginTask("Looking for entities", model.size());
 				for(T element : model){
 					contentProvider.add(element, itemsFilter);
@@ -288,10 +288,19 @@ public abstract class AbstractFilteredCdmEnumSelectionDialog<T extends IEnumTerm
 	@Override
 	protected Comparator getItemsComparator() {
 		return new Comparator<IEnumTerm>() {
-			public int compare(IEnumTerm entity1,
+			@Override
+            public int compare(IEnumTerm entity1,
 					IEnumTerm entity2) {
-				Collator collator = Collator.getInstance();
-				return collator.compare(entity1.getMessage(), entity2.getMessage());
+				if (entity1.equals(entity2)){
+				    return 0;
+				}
+			    Collator collator = Collator.getInstance();
+
+				int result = collator.compare(entity1.getMessage(), entity2.getMessage());
+				if (result == 0){
+				    return entity1.getUuid().compareTo(entity2.getUuid());
+				}
+				return result;
 			}
 		};
 	}
@@ -304,7 +313,7 @@ public abstract class AbstractFilteredCdmEnumSelectionDialog<T extends IEnumTerm
 	protected IStatus validateItem(Object item) {
 		return Status.OK_STATUS;
 	}
-	
+
 	/**
 	 * <p>getSelectedUuidAndTitleCache</p>
 	 *
@@ -314,7 +323,7 @@ public abstract class AbstractFilteredCdmEnumSelectionDialog<T extends IEnumTerm
 		Object[] result = getResult();
 		return result[0] == null ? null : (T) result[0];
 	}
-	
+
 	/**
 	 * <p>Getter for the field <code>settings</code>.</p>
 	 *
@@ -326,9 +335,9 @@ public abstract class AbstractFilteredCdmEnumSelectionDialog<T extends IEnumTerm
 		}
 		return settings;
 	}
-	
+
 	/**
-	 * 
+	 *
 	 * @author n.hoffmann
 	 * @created Oct 19, 2009
 	 * @version 1.0
@@ -337,39 +346,42 @@ public abstract class AbstractFilteredCdmEnumSelectionDialog<T extends IEnumTerm
 	    /*
 	    * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.SelectionHistory#restoreItemFromMemento(org.eclipse.ui.IMemento)
 	   	*/
-		protected Object restoreItemFromMemento(IMemento element) {
+		@Override
+        protected Object restoreItemFromMemento(IMemento element) {
 			return element.getString("resource"); //$NON-NLS-1$
 	  	}
 	  	/*
 	  	 * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.SelectionHistory#storeItemToMemento(java.lang.Object,
 	  	 *      org.eclipse.ui.IMemento)
 	  	 */
-		protected void storeItemToMemento(Object item, IMemento element) {
+		@Override
+        protected void storeItemToMemento(Object item, IMemento element) {
 			element.putString("resource", item.toString()); //$NON-NLS-1$
 		}
 	}
-	
+
 	/**
 	 * <p>getNewWizardLinkText</p>
 	 *
 	 * @return a {@link java.lang.String} object.
 	 */
 	protected abstract String getNewWizardLinkText();
-	
+
 	/**
 	 * <p>getNewEntityWizard</p>
-	 * @param parameter 
+	 * @param parameter
 	 * @return a {@link eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard} object.
 	 */
 	protected abstract AbstractNewEntityWizard getNewEntityWizard(String parameter);
-	
+
 	public class FilteredCdmResourceLabelProvider extends LabelProvider {
-		public String getText(Object element) {
+		@Override
+        public String getText(Object element) {
 			if (element == null) {
 				return null;
 			}
 			return ((IEnumTerm) element).getMessage();
-		}			
+		}
 	};
 
 	/* (non-Javadoc)
@@ -386,23 +398,23 @@ public abstract class AbstractFilteredCdmEnumSelectionDialog<T extends IEnumTerm
 		}
 		return null;
 	}
-	
+
 	protected SelectionListener getNewWizardLinkSelectionListener(){
 		return new SelectionAdapter() {
-			
+
 			/* (non-Javadoc)
 			 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
 			 */
 			@Override
 			public void widgetSelected(SelectionEvent e) {
-				
+
 				AbstractNewEntityWizard wizard = getNewEntityWizard(e.text);
 				wizard.init(null, null);
 				WizardDialog dialog = new WizardDialog(getShell(), wizard);
 				int status = dialog.open();
-				
+
 				if (status == IStatus.OK) {
-					
+
 					T entity = (T) wizard.getEntity();
 
 					refresh();
@@ -412,17 +424,19 @@ public abstract class AbstractFilteredCdmEnumSelectionDialog<T extends IEnumTerm
 			}
 		};
 	}
-	
+
 	/**
 	 * <p>getConversationHolder</p>
 	 *
 	 * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
 	 */
-	public ConversationHolder getConversationHolder() {
+	@Override
+    public ConversationHolder getConversationHolder() {
 		return conversation;
 	}
-	
+
 	/** {@inheritDoc} */
-	public void update(CdmDataChangeMap changeEvents) {}
+	@Override
+    public void update(CdmDataChangeMap changeEvents) {}
 
 }
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/TaxonNodeSelectionDialog.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/TaxonNodeSelectionDialog.java
index f727331f7..09e106b5f 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/TaxonNodeSelectionDialog.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/TaxonNodeSelectionDialog.java
@@ -140,7 +140,14 @@ public class TaxonNodeSelectionDialog extends AbstractFilteredCdmResourceSelecti
 
                 @Override
                 public int compare(Classification o1, Classification o2) {
-                    return o1.getTitleCache().compareTo(o2.getTitleCache());
+                    if (o1.equals(o2)){
+                        return 0;
+                    }
+                    int result = o1.getTitleCache().compareTo(o2.getTitleCache());
+                    if (result == 0){
+                        return o1.getUuid().compareTo(o2.getUuid());
+                    }
+                    return result;
                 }
             });
 			if (this.cdmBaseToBeFiltered == null){
