make restore of taxon navigator a preference
authorKatja Luther <k.luther@bgbm.org>
Mon, 29 Feb 2016 13:31:01 +0000 (14:31 +0100)
committerKatja Luther <k.luther@bgbm.org>
Mon, 29 Feb 2016 13:31:01 +0000 (14:31 +0100)
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/NavigatorStateManager.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/IPreferenceKeys.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/PreferencesUtil.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/TaxonomicEditorGeneralPreferences.java

index c25b2af7970e7a63b353b62f8cdc258fc5609cee..0ec7431c9cf026e110b40767cdd0df19a89526de 100644 (file)
@@ -6,6 +6,8 @@ import org.eclipse.ui.IMemento;
 
 import eu.etaxonomy.taxeditor.model.ContextListenerAdapter;
 import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigator;
 
 import eu.etaxonomy.taxeditor.model.ContextListenerAdapter;
 import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigator;
+import eu.etaxonomy.taxeditor.preference.CdmPreferences;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 
 /**
  * <p>NavigatorStateManager class.</p>
 
 /**
  * <p>NavigatorStateManager class.</p>
@@ -26,7 +28,12 @@ public class NavigatorStateManager extends ContextListenerAdapter {
                TaxonNavigator navigator = NavigationUtil.getNavigator(true);
                if(navigator != null){
                        navigator.init();
                TaxonNavigator navigator = NavigationUtil.getNavigator(true);
                if(navigator != null){
                        navigator.init();
-                       navigator.restore(memento, monitor);
+                       if (PreferencesUtil.isStoreNavigatorState()){
+                               navigator.restore(memento, monitor);
+                       } else {
+                               navigator.restore(null, monitor);
+                       }
+                       
                }
        }
        
                }
        }
        
@@ -59,6 +66,7 @@ public class NavigatorStateManager extends ContextListenerAdapter {
        @Override
        public void workbenchShutdown(IMemento memento, IProgressMonitor monitor) {
                saveNavigatorState(memento, monitor);
        @Override
        public void workbenchShutdown(IMemento memento, IProgressMonitor monitor) {
                saveNavigatorState(memento, monitor);
+       
        }
        
        /**
        }
        
        /**
index 57e7465ce85c7cc3cbe7c018da45df965bb6c1f1..4b493063ca641cf4ade4b7ad4335b2c060d44b05 100644 (file)
@@ -103,6 +103,8 @@ public interface IPreferenceKeys {
        public static final String SORT_NODES_NATURALLY = "eu.etaxonomy.taxeditor.menus.sortNodesNaturally";
        /** Constant <code>SORT_NODES_NATURALL="eu.etaxonomy.taxeditor.menus.sortNodesN"{trunked}</code> */
        public static final String SORT_NODES_ALPHABETICALLY = "eu.etaxonomy.taxeditor.menus.sortNodesAlphabetically";
        public static final String SORT_NODES_NATURALLY = "eu.etaxonomy.taxeditor.menus.sortNodesNaturally";
        /** Constant <code>SORT_NODES_NATURALL="eu.etaxonomy.taxeditor.menus.sortNodesN"{trunked}</code> */
        public static final String SORT_NODES_ALPHABETICALLY = "eu.etaxonomy.taxeditor.menus.sortNodesAlphabetically";
+       /** Constant <code>RESTORE_NAVIGATOR_STATE="eu.etaxonomy.taxeditor.taxonnavigator.restoreState"{trunked}</code> */
+       public static final String RESTORE_NAVIGATOR_STATE = "eu.etaxonomy.taxeditor.taxonnavigator.restoreState";
        /**
         * Whether multilanguage text fields should be editable in multiple languages.
         */
        /**
         * Whether multilanguage text fields should be editable in multiple languages.
         */
index 1f9f25b2631ae4f8d5efd2f8427dbe6b1bf23a77..3ece8622d92a934d7d8d3e96f5a4f08283b3e2c4 100644 (file)
@@ -798,5 +798,31 @@ public class PreferencesUtil implements IPreferenceKeys {
        public static void setSortNodesStrictlyAlphabetically(boolean selection) {
                getPreferenceStore().setValue(SORT_NODES_ALPHABETICALLY, selection);
        }
        public static void setSortNodesStrictlyAlphabetically(boolean selection) {
                getPreferenceStore().setValue(SORT_NODES_ALPHABETICALLY, selection);
        }
+
+       /**
+        * <p>
+        * setStoreNavigatorState
+        * </p>
+        *
+        * @param selection
+        *            a boolean.
+        */
+       public static boolean isStoreNavigatorState() {
+               return getPreferenceStore().getBoolean(RESTORE_NAVIGATOR_STATE);
+               
+       }
+       
+       /**
+        * <p>
+        * setStoreNavigatorState
+        * </p>
+        *
+        * @param selection
+        *            a boolean.
+        */
+       public static void setStoreNavigatorState(boolean selection) {
+               getPreferenceStore().setValue(RESTORE_NAVIGATOR_STATE, selection);
+               
+       }
        
 }
        
 }
index 9ec409300f05a58bd20e7606ee0eda7a3fe769f5..62b86e423d5acbaafacff3ba303bb7bb56d3666f 100644 (file)
@@ -63,6 +63,9 @@ public class TaxonomicEditorGeneralPreferences extends
              addField(new BooleanFieldEditor(IPreferenceKeys.DISABLE_SERVICES_API_TIMESTAMP_CHECK,
                        "Disable services api timestamp check",
                        getFieldEditorParent()));
              addField(new BooleanFieldEditor(IPreferenceKeys.DISABLE_SERVICES_API_TIMESTAMP_CHECK,
                        "Disable services api timestamp check",
                        getFieldEditorParent()));
+             addField(new BooleanFieldEditor(IPreferenceKeys.RESTORE_NAVIGATOR_STATE,
+                       "Restore the last Taxon Navigator state.",
+                       getFieldEditorParent()));
        }
 
        /*
        }
 
        /*