Cache the default feature tree
authorCherian Mathew <c.mathew@bgbm.org>
Wed, 16 Sep 2015 13:01:54 +0000 (15:01 +0200)
committerCherian Mathew <c.mathew@bgbm.org>
Wed, 16 Sep 2015 13:01:54 +0000 (15:01 +0200)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptiveContentProvider.java

index 3171375485ddfad8afbd1c4fb09ff7c8d173e551..33626cb75ca5c6ad6a7f206bbd56ee81f3271ac6 100644 (file)
@@ -38,6 +38,7 @@ public class DescriptiveContentProvider implements ITreeContentProvider {
        protected static final Object[] NO_CHILDREN = new Object[0];
        protected Map<DescriptionBase<?>, FeatureNodeContainerTree> featureNodeContainerCache;
        private boolean showOnlyIndividualAssociations;
+       private static FeatureTree defaultFeatureTree = null;
 
        public DescriptiveContentProvider(Map<DescriptionBase<?>, FeatureNodeContainerTree> featureNodeContainerCache) {
            this(featureNodeContainerCache, false);
@@ -144,8 +145,11 @@ public class DescriptiveContentProvider implements ITreeContentProvider {
         * @return
         */
        private FeatureTree getFeatureTree(DescriptionBase description){
-               FeatureTree featureTree = null;
 
+           if(defaultFeatureTree == null) {
+               defaultFeatureTree = FeatureTree.NewInstance(TermStore.getTerms(Feature.class));
+           }
+           FeatureTree featureTree;
                // TODO change this to the feature tree associated with this taxon description
                if (description.hasStructuredData()){
                        featureTree = PreferencesUtil.getDefaultFeatureTreeForStructuredDescription();
@@ -155,7 +159,7 @@ public class DescriptiveContentProvider implements ITreeContentProvider {
 
                // create a transient tree with all features if none was selected
                if(featureTree == null){
-                       featureTree = FeatureTree.NewInstance(TermStore.getTerms(Feature.class));
+                       featureTree = defaultFeatureTree;
                }
 
                return featureTree;