natural order preferences
authorKatja Luther <k.luther@bgbm.org>
Mon, 11 May 2015 11:48:09 +0000 (11:48 +0000)
committerKatja Luther <k.luther@bgbm.org>
Mon, 11 May 2015 11:48:09 +0000 (11:48 +0000)
.gitattributes
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/OrderPreferences.java [new file with mode: 0644]

index 947b40f..07c5c2f 100644 (file)
@@ -1371,6 +1371,7 @@ eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/Mat
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/MediaPreferences.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/MobotOpenUrlPreferences.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/NomenclaturalCodePreferences.java -text
+eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/OrderPreferences.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/PreferencePropertyTester.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/PreferencesUtil.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/Resources.java -text
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/OrderPreferences.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/OrderPreferences.java
new file mode 100644 (file)
index 0000000..3e434a9
--- /dev/null
@@ -0,0 +1,86 @@
+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.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
+import org.eclipse.swt.widgets.Control;\r
+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
+\r
+import eu.etaxonomy.taxeditor.Messages;\r
+\r
+public class OrderPreferences extends PreferencePage implements IWorkbenchPreferencePage {\r
+       \r
+\r
+           boolean isNaturalOrderActivated;\r
+           boolean isSelectionChanged = false;\r
+           /*\r
+            * (non-Javadoc)\r
+            *\r
+            * @see\r
+            * org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors\r
+            * ()\r
+            */\r
+           @Override\r
+           protected Control createContents(Composite parent) {\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
+               isNaturalOrderActivated = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SORT_NODES_NATURALLY);\r
+               final Button activateCheckButton = new Button(composite, SWT.CHECK);\r
+               activateCheckButton.setText("Enable Natural Order");\r
+               activateCheckButton.setSelection(isNaturalOrderActivated);\r
+               activateCheckButton.addSelectionListener(new SelectionAdapter(){\r
+                   @Override\r
+                   public void widgetSelected(SelectionEvent e) {\r
+                       if(isNaturalOrderActivated != activateCheckButton.getSelection()) {\r
+                               isNaturalOrderActivated = activateCheckButton.getSelection();\r
+                               PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SORT_NODES_NATURALLY, isNaturalOrderActivated);\r
+                        isSelectionChanged = true;\r
+                    }else{\r
+                        isSelectionChanged = false;\r
+                    }\r
+\r
+                   }\r
+               });\r
+\r
+              \r
+\r
+               return composite;\r
+           }\r
+\r
+         \r
+               @Override\r
+               public void init(IWorkbench workbench) {\r
+                       // TODO Auto-generated method stub\r
+                       \r
+               }\r
+\r
+               /* (non-Javadoc)\r
+                * @see org.eclipse.jface.preference.PreferencePage#performOk()\r
+                */\r
+               @Override\r
+               public boolean performOk() {\r
+              if(isSelectionChanged){\r
+                 MessageDialog.openInformation(getShell(), null, Messages.OrderPreferencePage_PleaseReopenNavigator);            \r
+                       return super.performOk();\r
+              }\r
+              return true;\r
+               }\r
+\r
+\r
+}\r