fix default feature tree for facts and name facts
authorKatja Luther <k.luther@bgbm.org>
Fri, 3 May 2019 16:13:30 +0000 (18:13 +0200)
committerKatja Luther <k.luther@bgbm.org>
Wed, 8 May 2019 11:37:17 +0000 (13:37 +0200)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/DynamicFeatureMenuE4.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/TermManager.java

index d3a892d..ccdc081 100644 (file)
@@ -34,7 +34,6 @@ import eu.etaxonomy.cdm.model.term.DefinedTermBase;
 import eu.etaxonomy.cdm.model.term.FeatureNode;
 import eu.etaxonomy.cdm.model.term.FeatureTree;
 import eu.etaxonomy.cdm.model.term.VocabularyEnum;
-import eu.etaxonomy.taxeditor.editor.definedterm.input.TermEditorInput;
 import eu.etaxonomy.taxeditor.editor.l10n.Messages;
 import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.CreateDescriptionElementOperation;
 import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
@@ -137,7 +136,11 @@ public class DynamicFeatureMenuE4 {
                }
 
                if (featureTree == null) {
-                       featureTree = TermEditorInput.getDefaultFeatureTree();
+                   List<Feature> terms = CdmStore.getTermManager().getPreferredTerms(CdmStore.getService(IVocabularyService.class).load(VocabularyEnum.Feature.getUuid()), null);
+            terms.remove(Feature.IMAGE());
+
+                       featureTree = FeatureTree.NewInstance(terms);
+
                }
                if (description instanceof TaxonNameDescription){
                    List<Feature> terms = CdmStore.getTermManager().getPreferredTerms(CdmStore.getService(IVocabularyService.class).load(VocabularyEnum.NameFeature.getUuid()));
index 5c09ad1..1ea29a3 100644 (file)
@@ -11,6 +11,7 @@ package eu.etaxonomy.taxeditor.store;
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -20,6 +21,7 @@ import eu.etaxonomy.cdm.model.term.DefinedTermBase;
 import eu.etaxonomy.cdm.model.term.TermBase;
 import eu.etaxonomy.cdm.model.term.TermType;
 import eu.etaxonomy.cdm.model.term.TermVocabulary;
+import eu.etaxonomy.taxeditor.model.DefaultTermComparator;
 import eu.etaxonomy.taxeditor.model.TaxonRelationshipTypeInverseContainer;
 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 
@@ -65,12 +67,30 @@ public class TermManager {
        public <T extends DefinedTermBase> List<T> getPreferredTerms(TermVocabulary<T> termVocabulary){
            List terms = cachedTermMap.get(termVocabulary);
            if(terms==null){
-               terms = getFilteredTerms(new ArrayList<T>(TermStore.getTerms(termVocabulary, null)));
+               terms = getFilteredTerms(new ArrayList<T>(TermStore.getTerms(termVocabulary,null)));
                cachedTermMap.put(termVocabulary, terms);
            }
            return terms;
        }
 
+
+       /**
+    *
+    * @param clazz
+    * @return
+    */
+   public <T extends DefinedTermBase> List<T> getPreferredTerms(TermVocabulary<T> termVocabulary, Comparator comp){
+       if (comp == null){
+           comp = new DefaultTermComparator<T>();
+       }
+       List terms = cachedTermMap.get(termVocabulary);
+       if(terms==null){
+           terms = getFilteredTerms(new ArrayList<T>(TermStore.getTerms(termVocabulary,comp)));
+           cachedTermMap.put(termVocabulary, terms);
+       }
+       terms.sort(comp);
+       return terms;
+   }
        /**
         *
         * @param clazz