ref #10307: missing adapted comparator
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / editor / definedterm / DefinedTermSorter.java
index aee5cb5a96c194c8f6e0000cce3ce036af75fba1..e7ebe175cb910c129abc4e54fb3e1134e7419e03 100644 (file)
@@ -8,14 +8,19 @@
 */
 package eu.etaxonomy.taxeditor.editor.definedterm;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.jface.viewers.ViewerComparator;
 
 import eu.etaxonomy.cdm.api.service.l10n.TermRepresentation_L10n;
 import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.cdm.model.common.Language;
 import eu.etaxonomy.cdm.model.term.DefinedTermBase;
 import eu.etaxonomy.cdm.persistence.dto.TermDto;
 import eu.etaxonomy.cdm.persistence.dto.TermVocabularyDto;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 
 /**
  * @author pplitzner
@@ -29,6 +34,8 @@ public class DefinedTermSorter extends ViewerComparator {
         // location <-> add term method used in the MoveDefinedTermOperation
         // execute call
         //FIXME: remove this when all viewer are changed to use DTOs
+        List<Language> languages = new ArrayList<>();
+        languages.add(PreferencesUtil.getGlobalLanguage());
         if(e1 instanceof DefinedTermBase && CdmBase.deproxy(e1, DefinedTermBase.class).isOrderRelevant()
                 && e2 instanceof DefinedTermBase && CdmBase.deproxy(e2, DefinedTermBase.class).isOrderRelevant()) {
             DefinedTermBase<?> otbe1 = (DefinedTermBase<?>)e1;
@@ -61,8 +68,9 @@ public class DefinedTermSorter extends ViewerComparator {
             }
             else {
                 // order indexes are equal or null -> compare by label
-                termDto1.localize(new TermRepresentation_L10n());
-                termDto2.localize(new TermRepresentation_L10n());
+
+                termDto1.localize(new TermRepresentation_L10n(), languages);
+                termDto2.localize(new TermRepresentation_L10n(), languages);
                 if(termDto1.getRepresentation_L10n()!=null){
                     if(termDto2.getRepresentation_L10n()!=null) {
                         return termDto1.getRepresentation_L10n().toLowerCase().compareTo(termDto2.getRepresentation_L10n().toLowerCase());
@@ -79,8 +87,8 @@ public class DefinedTermSorter extends ViewerComparator {
         else if(e1 instanceof TermVocabularyDto && e2 instanceof TermVocabularyDto) {
             TermVocabularyDto termVoc1 = (TermVocabularyDto)e1;
             TermVocabularyDto termVoc2 = (TermVocabularyDto)e2;
-            termVoc1.localize(new TermRepresentation_L10n());
-            termVoc2.localize(new TermRepresentation_L10n());
+            termVoc1.localize(new TermRepresentation_L10n(), languages);
+            termVoc2.localize(new TermRepresentation_L10n(), languages);
             if(termVoc1.getRepresentation_L10n()!=null){
                 if(termVoc2.getRepresentation_L10n()!=null) {
                     return termVoc1.getRepresentation_L10n().toLowerCase().compareTo(termVoc2.getRepresentation_L10n().toLowerCase());