move restore navigator status to taxonNavigator preferences
authorKatja Luther <k.luther@bgbm.org>
Fri, 1 Apr 2016 12:27:10 +0000 (14:27 +0200)
committerKatja Luther <k.luther@bgbm.org>
Fri, 1 Apr 2016 12:27:10 +0000 (14:27 +0200)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/OrderPreferences.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 bc51c0d..047dab0 100644 (file)
@@ -1,17 +1,10 @@
 package eu.etaxonomy.taxeditor.preference;\r
 \r
-import java.io.IOException;\r
-\r
 import org.eclipse.jface.dialogs.MessageDialog;\r
 import org.eclipse.jface.preference.PreferencePage;\r
-import org.eclipse.jface.resource.ImageDescriptor;\r
-import org.eclipse.jface.viewers.ArrayContentProvider;\r
-import org.eclipse.jface.viewers.LabelProvider;\r
 import org.eclipse.swt.SWT;\r
 import org.eclipse.swt.events.SelectionAdapter;\r
 import org.eclipse.swt.events.SelectionEvent;\r
-import org.eclipse.swt.graphics.Image;\r
-import org.eclipse.swt.graphics.Point;\r
 import org.eclipse.swt.layout.GridLayout;\r
 import org.eclipse.swt.widgets.Button;\r
 import org.eclipse.swt.widgets.Composite;\r
@@ -19,17 +12,16 @@ import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Label;\r
 import org.eclipse.ui.IWorkbench;\r
 import org.eclipse.ui.IWorkbenchPreferencePage;\r
-import org.eclipse.ui.PlatformUI;\r
-import org.eclipse.ui.dialogs.ListSelectionDialog;\r
 \r
 import eu.etaxonomy.taxeditor.Messages;\r
 \r
 public class OrderPreferences extends PreferencePage implements IWorkbenchPreferencePage {\r
-       \r
+\r
 \r
            boolean isNaturalOrderActivated;\r
            boolean isAlphabeticalOrderActivated;\r
            boolean isRankAndNameOrderActivated;\r
+           boolean isRestoreTaxonNavigator;\r
            boolean isSelectionChanged = false;\r
            boolean isStrictlyAlphabeticallyOrdered;\r
            /*\r
@@ -42,25 +34,44 @@ public class OrderPreferences extends PreferencePage implements IWorkbenchPrefer
            @Override\r
            protected Control createContents(Composite parent) {\r
 \r
-               Composite composite = new Composite(parent, SWT.NULL);\r
+               isRestoreTaxonNavigator = PreferencesUtil.isRestoreNavigator();\r
+\r
+            Composite secondComposite = new Composite(parent, SWT.NULL);\r
+            secondComposite.setLayout(new GridLayout());\r
+\r
+            final Button activateRestoreNavigatorButton = new Button(secondComposite, SWT.CHECK | SWT.LEFT);\r
+            activateRestoreNavigatorButton.setText("Restore the last Taxon Navigator state.");\r
+            activateRestoreNavigatorButton.setSelection(isRestoreTaxonNavigator);\r
+            activateRestoreNavigatorButton.addSelectionListener(new SelectionAdapter(){\r
+                @Override\r
+                public void widgetSelected(SelectionEvent e) {\r
+                    if(isRestoreTaxonNavigator != activateRestoreNavigatorButton.getSelection()) {\r
+                        isRestoreTaxonNavigator = activateRestoreNavigatorButton.getSelection();\r
+                        PreferencesUtil.setRestoreNavigator(isRestoreTaxonNavigator);\r
+                    }\r
+                }\r
+\r
+            });\r
+\r
+\r
+            Composite composite = new Composite(parent, SWT.NULL);\r
                composite.setLayout(new GridLayout());\r
-               final Label description = new Label(parent, SWT.NONE);\r
-               description.setText(Messages.OrderPreferencePage_NewNavigatorWindowRequired);\r
+\r
                isNaturalOrderActivated = PreferencesUtil.getSortNodesNaturally();\r
                final Button activateNaturalOrderCheckButton = new Button(composite, SWT.RADIO);\r
                activateNaturalOrderCheckButton.setText("Enable Natural Order");\r
                activateNaturalOrderCheckButton.setSelection(isNaturalOrderActivated);\r
-              \r
+\r
                isRankAndNameOrderActivated = !PreferencesUtil.getSortNodesStrictlyAlphabetically() && !PreferencesUtil.getSortNodesNaturally();\r
                final Button activateRankAndNameOrderActivatedCheckButton = new Button(composite, SWT.RADIO);\r
                activateRankAndNameOrderActivatedCheckButton.setText("Enable Rank and Aplhabetical Order");\r
                activateRankAndNameOrderActivatedCheckButton.setSelection(isRankAndNameOrderActivated);\r
-               \r
+\r
                isAlphabeticalOrderActivated = PreferencesUtil.getSortNodesStrictlyAlphabetically();\r
                final Button activateAlphabeticallyOrderedCheckButton = new Button(composite, SWT.RADIO);\r
                activateAlphabeticallyOrderedCheckButton.setText("Enable Alphabetical Order");\r
                activateAlphabeticallyOrderedCheckButton.setSelection(isAlphabeticalOrderActivated);\r
-               \r
+\r
                activateNaturalOrderCheckButton.addSelectionListener(new SelectionAdapter(){\r
                    @Override\r
                    public void widgetSelected(SelectionEvent e) {\r
@@ -69,10 +80,10 @@ public class OrderPreferences extends PreferencePage implements IWorkbenchPrefer
                                if (isAlphabeticalOrderActivated && isNaturalOrderActivated){\r
                                        isAlphabeticalOrderActivated = false;\r
                                        PreferencesUtil.setSortNodesStrictlyAlphabetically(isAlphabeticalOrderActivated);\r
-                               } \r
+                               }\r
                                if (isRankAndNameOrderActivated && isNaturalOrderActivated){\r
                                        isRankAndNameOrderActivated = false;\r
-                               } \r
+                               }\r
                                PreferencesUtil.setSortNodesNaturally(isNaturalOrderActivated);\r
                         isSelectionChanged = true;\r
                     }else{\r
@@ -89,10 +100,10 @@ public class OrderPreferences extends PreferencePage implements IWorkbenchPrefer
                                if (isNaturalOrderActivated && isAlphabeticalOrderActivated){\r
                                        isNaturalOrderActivated = false;\r
                                        PreferencesUtil.setSortNodesNaturally(isNaturalOrderActivated);\r
-                               } \r
+                               }\r
                                if (isRankAndNameOrderActivated && isAlphabeticalOrderActivated){\r
                                        isRankAndNameOrderActivated = false;\r
-                               }  \r
+                               }\r
                                PreferencesUtil.setSortNodesStrictlyAlphabetically(isAlphabeticalOrderActivated);\r
                         isSelectionChanged = true;\r
                     }else{\r
@@ -101,7 +112,7 @@ public class OrderPreferences extends PreferencePage implements IWorkbenchPrefer
 \r
                    }\r
                });\r
-               \r
+\r
                activateRankAndNameOrderActivatedCheckButton.addSelectionListener(new SelectionAdapter(){\r
                    @Override\r
                    public void widgetSelected(SelectionEvent e) {\r
@@ -109,11 +120,11 @@ public class OrderPreferences extends PreferencePage implements IWorkbenchPrefer
                                isRankAndNameOrderActivated = activateRankAndNameOrderActivatedCheckButton.getSelection();\r
                                if (isAlphabeticalOrderActivated && isRankAndNameOrderActivated){\r
                                         isAlphabeticalOrderActivated = false;\r
-                               } \r
+                               }\r
                                if (isNaturalOrderActivated && isRankAndNameOrderActivated){\r
                                        isNaturalOrderActivated = false;\r
-                               } \r
-                               \r
+                               }\r
+\r
                                if (isRankAndNameOrderActivated ||(!isNaturalOrderActivated && !isAlphabeticalOrderActivated)){\r
                                        PreferencesUtil.setSortNodesStrictlyAlphabetically(false);\r
                                        PreferencesUtil.setSortNodesNaturally(false);\r
@@ -127,16 +138,20 @@ public class OrderPreferences extends PreferencePage implements IWorkbenchPrefer
                });\r
 \r
 \r
-              \r
+\r
+\r
+\r
+            final Label description = new Label(parent, SWT.NONE);\r
+            description.setText(Messages.OrderPreferencePage_NewNavigatorWindowRequired);\r
 \r
                return composite;\r
            }\r
 \r
-         \r
+\r
                @Override\r
                public void init(IWorkbench workbench) {\r
                        // TODO Auto-generated method stub\r
-                       \r
+\r
                }\r
 \r
                /* (non-Javadoc)\r
index 6e87339..d97e7ce 100644 (file)
@@ -834,4 +834,15 @@ public class PreferencesUtil implements IPreferenceKeys {
     public static void setShowUpWidgetIsDisposedMessages(boolean selection) {
         getPreferenceStore().setValue(IS_SHOW_UP_WIDGET_IS_DISPOSED, selection);
     }
+
+    /**
+     * @return
+     */
+    public static boolean isRestoreNavigator() {
+       return getPreferenceStore().getBoolean(RESTORE_NAVIGATOR_STATE);
+    }
+    public static void setRestoreNavigator(boolean selection) {
+        getPreferenceStore().setValue(RESTORE_NAVIGATOR_STATE, selection);
+    }
+
 }
index d07a19f..df1f512 100644 (file)
@@ -61,9 +61,6 @@ public class TaxonomicEditorGeneralPreferences extends
                        "Open search results in separate windows",
                        getFieldEditorParent()));
 
-             addField(new BooleanFieldEditor(IPreferenceKeys.RESTORE_NAVIGATOR_STATE,
-                       "Restore the last Taxon Navigator state.",
-                       getFieldEditorParent()));
 
        }