Drastically reducing code by using field editors for preferences
authorn.hoffmann <n.hoffmann@localhost>
Thu, 21 Apr 2011 13:53:25 +0000 (13:53 +0000)
committern.hoffmann <n.hoffmann@localhost>
Thu, 21 Apr 2011 13:53:25 +0000 (13:53 +0000)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/AbstractIOManager.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/ExportManager.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/FeatureTreePreferences.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/MobotOpenUrlPreferences.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/NomenclaturalCodePreferences.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
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStore.java

index 09b5afca00d2e8472cf84901c9368d610cedb8a7..2c552df0c2447f6754695c1447bdee6e493f0846 100644 (file)
@@ -1,12 +1,12 @@
 // $Id$
 /**
 // $Id$
 /**
-* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy 
-* http://www.e-taxonomy.eu
-* 
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
+ * Copyright (C) 2007 EDIT
+ * European Distributed Institute of Taxonomy 
+ * http://www.e-taxonomy.eu
+ 
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * See LICENSE.TXT at the top of this package for the full license terms.
+ */
 
 package eu.etaxonomy.taxeditor.io;
 
 
 package eu.etaxonomy.taxeditor.io;
 
@@ -17,8 +17,10 @@ import eu.etaxonomy.cdm.api.application.CdmApplicationController;
 import eu.etaxonomy.cdm.io.common.IIoConfigurator;
 
 /**
 import eu.etaxonomy.cdm.io.common.IIoConfigurator;
 
 /**
- * <p>Abstract AbstractIOHandler class.</p>
- *
+ * <p>
+ * Abstract AbstractIOHandler class.
+ * </p>
+ * 
  * @author n.hoffmann
  * @created Sep 11, 2009
  * @version 1.0
  * @author n.hoffmann
  * @created Sep 11, 2009
  * @version 1.0
@@ -26,27 +28,34 @@ import eu.etaxonomy.cdm.io.common.IIoConfigurator;
 public abstract class AbstractIOManager<CONFIGURATOR extends IIoConfigurator> {
 
        protected CdmApplicationController applicationController;
 public abstract class AbstractIOManager<CONFIGURATOR extends IIoConfigurator> {
 
        protected CdmApplicationController applicationController;
-       
+
        public static enum TYPE {
                BerlinModel, Jaxb, Tcs, Excel_Taxa, Endnote, Sdd, Abcd
        }
 
        /**
        public static enum TYPE {
                BerlinModel, Jaxb, Tcs, Excel_Taxa, Endnote, Sdd, Abcd
        }
 
        /**
-        * <p>Constructor for AbstractIOHandler.</p>
-        *
-        * @param applicationController a {@link eu.etaxonomy.cdm.api.application.CdmApplicationController} object.
-        * @param <CONFIGURATOR> a CONFIGURATOR object.
+        * <p>
+        * Constructor for AbstractIOHandler.
+        * </p>
+        * 
+        * @param applicationController
+        *            a
+        *            {@link eu.etaxonomy.cdm.api.application.CdmApplicationController}
+        *            object.
+        * @param <CONFIGURATOR>
+        *            a CONFIGURATOR object.
         */
         */
-       protected AbstractIOManager(CdmApplicationController applicationController){
+       protected AbstractIOManager(CdmApplicationController applicationController) {
                this.applicationController = applicationController;
        }
                this.applicationController = applicationController;
        }
-       
+
        /**
         * Starts the IO process
        /**
         * Starts the IO process
-        *
-        * @param configurator a CONFIGURATOR object.
+        * 
+        * @param configurator
+        *            a CONFIGURATOR object.
         */
         */
-       public void run(final CONFIGURATOR configurator){
+       public void run(final CONFIGURATOR configurator) {
                // create job
                Job job = createIOJob(configurator);
                // configure the job
                // create job
                Job job = createIOJob(configurator);
                // configure the job
@@ -54,13 +63,16 @@ public abstract class AbstractIOManager<CONFIGURATOR extends IIoConfigurator> {
                job.setUser(true);
                // schedule job
                job.schedule();
                job.setUser(true);
                // schedule job
                job.schedule();
-               
+
        }
        }
-       
+
        /**
        /**
-        * <p>createIOJob</p>
-        *
-        * @param configurator a CONFIGURATOR object.
+        * <p>
+        * createIOJob
+        * </p>
+        * 
+        * @param configurator
+        *            a CONFIGURATOR object.
         * @return a {@link org.eclipse.core.runtime.jobs.Job} object.
         */
        protected abstract Job createIOJob(CONFIGURATOR configurator);
         * @return a {@link org.eclipse.core.runtime.jobs.Job} object.
         */
        protected abstract Job createIOJob(CONFIGURATOR configurator);
index d8697df40ac10aa5cc7a3ae5f091117a684b0972..88093316ea251254506b3a3adc20a50bbe85c87c 100644 (file)
@@ -1,12 +1,12 @@
 // $Id$
 /**
 // $Id$
 /**
-* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy 
-* http://www.e-taxonomy.eu
-* 
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
+ * Copyright (C) 2007 EDIT
+ * European Distributed Institute of Taxonomy 
+ * http://www.e-taxonomy.eu
+ 
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * See LICENSE.TXT at the top of this package for the full license terms.
+ */
 
 package eu.etaxonomy.taxeditor.io;
 
 
 package eu.etaxonomy.taxeditor.io;
 
@@ -28,127 +28,157 @@ import eu.etaxonomy.taxeditor.model.CdmProgressMonitorAdapter;
 import eu.etaxonomy.taxeditor.store.StoreUtil;
 
 /**
 import eu.etaxonomy.taxeditor.store.StoreUtil;
 
 /**
- * <p>ExportHandler class.</p>
- *
+ * <p>
+ * ExportHandler class.
+ * </p>
+ * 
  * @author n.hoffmann
  * @created Sep 11, 2009
  * @version 1.0
  */
  * @author n.hoffmann
  * @created Sep 11, 2009
  * @version 1.0
  */
-public class ExportManager extends AbstractIOManager<IExportConfigurator>{
-       
+public class ExportManager extends AbstractIOManager<IExportConfigurator> {
+
        /**
         * 
         * @param applicationController
         */
        /**
         * 
         * @param applicationController
         */
-       private ExportManager(CdmApplicationController applicationController){
+       private ExportManager(CdmApplicationController applicationController) {
                super(applicationController);
        }
                super(applicationController);
        }
-       
+
        /**
        /**
-        * <p>NewInstance</p>
-        *
-        * @param applicationController a {@link eu.etaxonomy.cdm.api.application.CdmApplicationController} object.
+        * <p>
+        * NewInstance
+        * </p>
+        * 
+        * @param applicationController
+        *            a
+        *            {@link eu.etaxonomy.cdm.api.application.CdmApplicationController}
+        *            object.
         * @return a {@link eu.etaxonomy.taxeditor.io.ExportManager} object.
         */
         * @return a {@link eu.etaxonomy.taxeditor.io.ExportManager} object.
         */
-       public static ExportManager NewInstance(CdmApplicationController applicationController){
+       public static ExportManager NewInstance(
+                       CdmApplicationController applicationController) {
                return new ExportManager(applicationController);
        }
                return new ExportManager(applicationController);
        }
-       
+
        /**
        /**
-        * <p>createIOJob</p>
-        *
-        * @param configurator a {@link eu.etaxonomy.cdm.io.common.IExportConfigurator} object.
+        * <p>
+        * createIOJob
+        * </p>
+        * 
+        * @param configurator
+        *            a {@link eu.etaxonomy.cdm.io.common.IExportConfigurator}
+        *            object.
         * @return a {@link org.eclipse.core.runtime.jobs.Job} object.
         */
         * @return a {@link org.eclipse.core.runtime.jobs.Job} object.
         */
-       protected Job createIOJob(final IExportConfigurator configurator){
-               
+       @Override
+       protected Job createIOJob(final IExportConfigurator configurator) {
+
                Assert.isNotNull(configurator, "Configuration may not be null");
                Assert.isNotNull(configurator, "Configuration may not be null");
-               
+
                final Display display = Display.getCurrent();
                final Display display = Display.getCurrent();
-               
-               Job job = new Job("Export: " + configurator.getClass().getSimpleName()){
+
+               Job job = new Job("Export: " + configurator.getClass().getSimpleName()) {
                        @Override
                        protected IStatus run(IProgressMonitor monitor) {
                        @Override
                        protected IStatus run(IProgressMonitor monitor) {
-                               monitor.beginTask("Exporting database. This will take some time.", 100);
+                               monitor.beginTask(
+                                               "Exporting database. This will take some time.", 100);
                                monitor.worked(10);
                                monitor.worked(10);
-                               
+
                                display.asyncExec(new Runnable() {
                                display.asyncExec(new Runnable() {
-                                       
+
                                        @Override
                                        public void run() {
                                                // terminate any open transactions
                                        @Override
                                        public void run() {
                                                // terminate any open transactions
-                                               IConversationEnabled activePart = (IConversationEnabled) StoreUtil.getActivePage().getActivePart();
+                                               IConversationEnabled activePart = (IConversationEnabled) StoreUtil
+                                                               .getActivePage().getActivePart();
                                                activePart.getConversationHolder().commit(false);
                                        }
                                });
                                                activePart.getConversationHolder().commit(false);
                                        }
                                });
-                               
+
                                monitor.worked(10);
                                monitor.worked(10);
-                               
+
                                CdmDefaultExport<IExportConfigurator> exporter = new CdmDefaultExport<IExportConfigurator>();
                                CdmDefaultExport<IExportConfigurator> exporter = new CdmDefaultExport<IExportConfigurator>();
-                               configurator.setProgressMonitor(CdmProgressMonitorAdapter.CreateSubMonitor(monitor, 80));
+                               configurator.setProgressMonitor(CdmProgressMonitorAdapter
+                                               .CreateSubMonitor(monitor, 80));
                                exporter.setCdmAppController(applicationController);
                                monitor.worked(10);
                                exporter.setCdmAppController(applicationController);
                                monitor.worked(10);
-                               
-                               try{
+
+                               try {
                                        exporter.invoke(configurator);
                                        monitor.worked(60);
                                        exporter.invoke(configurator);
                                        monitor.worked(60);
-                               }catch(RuntimeException e){
-                                       StoreUtil.errorDialog("Error exporting data", this, "An error occured while" +
-                                                       "exporting to destination '" + configurator.getDestinationNameString() + "'.\n" +
-                                                                       "Please check error log for details.", e);
+                               } catch (RuntimeException e) {
+                                       StoreUtil.errorDialog("Error exporting data", this,
+                                                       "An error occured while"
+                                                                       + "exporting to destination '"
+                                                                       + configurator.getDestinationNameString()
+                                                                       + "'.\n"
+                                                                       + "Please check error log for details.", e);
                                }
                                }
-                               
+
                                display.asyncExec(new Runnable() {
                                display.asyncExec(new Runnable() {
-                                       
+
                                        @Override
                                        public void run() {
                                                // terminate any open transactions
                                        @Override
                                        public void run() {
                                                // terminate any open transactions
-                                               IConversationEnabled activePart = (IConversationEnabled) StoreUtil.getActivePage().getActivePart();
-                                               // restarting transaction and committing it to trigger change listener
+                                               IConversationEnabled activePart = (IConversationEnabled) StoreUtil
+                                                               .getActivePage().getActivePart();
+                                               // restarting transaction and committing it to trigger
+                                               // change listener
                                                // TODO verify correct behaviour
                                                activePart.getConversationHolder().startTransaction();
                                                activePart.getConversationHolder().commit();
                                        }
                                });
                                monitor.worked(10);
                                                // TODO verify correct behaviour
                                                activePart.getConversationHolder().startTransaction();
                                                activePart.getConversationHolder().commit();
                                        }
                                });
                                monitor.worked(10);
-                               
+
                                return Status.OK_STATUS;
                        }
                };
                                return Status.OK_STATUS;
                        }
                };
-               
+
                return job;
        }
                return job;
        }
-       
+
        /**
         * @param jaxb
         * @return
         */
        private IIoConfigurator getConfigurator(TYPE type) {
                Assert.isNotNull(type, "Type should not be null");
        /**
         * @param jaxb
         * @return
         */
        private IIoConfigurator getConfigurator(TYPE type) {
                Assert.isNotNull(type, "Type should not be null");
-                               
-               switch (type){
-                       case Jaxb:
-                               return JaxbExportConfigurator.NewInstance(null, null);
-                       case Sdd:
-                               return SDDExportConfigurator.NewInstance(null, null, null);
-                       default:
-                               StoreUtil.notImplementedMessage(this);
-                               throw new IllegalArgumentException("Export not supported yet");
+
+               switch (type) {
+               case Jaxb:
+                       return JaxbExportConfigurator.NewInstance(null, null);
+               case Sdd:
+                       return SDDExportConfigurator.NewInstance(null, null, null);
+               default:
+                       StoreUtil.notImplementedMessage(this);
+                       throw new IllegalArgumentException("Export not supported yet");
                }
        }
                }
        }
-       
+
        /**
        /**
-        * <p>JaxbConfigurator</p>
-        *
+        * <p>
+        * JaxbConfigurator
+        * </p>
+        * 
         * @return a {@link eu.etaxonomy.cdm.io.jaxb.JaxbExportConfigurator} object.
         */
         * @return a {@link eu.etaxonomy.cdm.io.jaxb.JaxbExportConfigurator} object.
         */
-       public final JaxbExportConfigurator JaxbConfigurator() { return (JaxbExportConfigurator) getConfigurator(TYPE.Jaxb);    }
+       public final JaxbExportConfigurator JaxbConfigurator() {
+               return (JaxbExportConfigurator) getConfigurator(TYPE.Jaxb);
+       }
 
        /**
 
        /**
-        * <p>SddConfigurator</p>
-        *
-        * @return a {@link eu.etaxonomy.cdm.io.sdd.out.SDDExportConfigurator} object.
+        * <p>
+        * SddConfigurator
+        * </p>
+        * 
+        * @return a {@link eu.etaxonomy.cdm.io.sdd.out.SDDExportConfigurator}
+        *         object.
         */
         */
-       public final SDDExportConfigurator SddConfigurator() { return (SDDExportConfigurator) getConfigurator(TYPE.Sdd); }
+       public final SDDExportConfigurator SddConfigurator() {
+               return (SDDExportConfigurator) getConfigurator(TYPE.Sdd);
+       }
 
 }
 
 }
index 969807d13ed7d4c9a72fc8f6ecd2bf9e527a44e7..df0300989a055463e4632d92d3a8cceed97cf901 100644 (file)
@@ -1,12 +1,12 @@
 // $Id$
 /**
 // $Id$
 /**
-* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy 
-* http://www.e-taxonomy.eu
-* 
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
+ * Copyright (C) 2007 EDIT
+ * European Distributed Institute of Taxonomy 
+ * http://www.e-taxonomy.eu
+ 
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * See LICENSE.TXT at the top of this package for the full license terms.
+ */
 
 package eu.etaxonomy.taxeditor.preference;
 
 
 package eu.etaxonomy.taxeditor.preference;
 
@@ -26,8 +26,10 @@ import org.eclipse.ui.IWorkbenchPreferencePage;
 import eu.etaxonomy.taxeditor.featuretree.FeatureTreeEditorWizard;
 
 /**
 import eu.etaxonomy.taxeditor.featuretree.FeatureTreeEditorWizard;
 
 /**
- * <p>FeatureTreePreferences class.</p>
- *
+ * <p>
+ * FeatureTreePreferences class.
+ * </p>
+ * 
  * @author n.hoffmann
  * @created Aug 5, 2010
  * @version 1.0
  * @author n.hoffmann
  * @created Aug 5, 2010
  * @version 1.0
@@ -36,61 +38,78 @@ public class FeatureTreePreferences extends PreferencePage implements
                IWorkbenchPreferencePage {
 
        /**
                IWorkbenchPreferencePage {
 
        /**
-        * <p>Constructor for FeatureTreePreferences.</p>
+        * <p>
+        * Constructor for FeatureTreePreferences.
+        * </p>
         */
        public FeatureTreePreferences() {
        }
 
        /**
         */
        public FeatureTreePreferences() {
        }
 
        /**
-        * <p>Constructor for FeatureTreePreferences.</p>
-        *
-        * @param title a {@link java.lang.String} object.
+        * <p>
+        * Constructor for FeatureTreePreferences.
+        * </p>
+        * 
+        * @param title
+        *            a {@link java.lang.String} object.
         */
        public FeatureTreePreferences(String title) {
                super(title);
        }
 
        /**
         */
        public FeatureTreePreferences(String title) {
                super(title);
        }
 
        /**
-        * <p>Constructor for FeatureTreePreferences.</p>
-        *
-        * @param title a {@link java.lang.String} object.
-        * @param image a {@link org.eclipse.jface.resource.ImageDescriptor} object.
+        * <p>
+        * Constructor for FeatureTreePreferences.
+        * </p>
+        * 
+        * @param title
+        *            a {@link java.lang.String} object.
+        * @param image
+        *            a {@link org.eclipse.jface.resource.ImageDescriptor} object.
         */
        public FeatureTreePreferences(String title, ImageDescriptor image) {
                super(title, image);
        }
 
         */
        public FeatureTreePreferences(String title, ImageDescriptor image) {
                super(title, image);
        }
 
-       /* (non-Javadoc)
-        * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
         */
        /** {@inheritDoc} */
        @Override
        public void init(IWorkbench workbench) {
        }
 
         */
        /** {@inheritDoc} */
        @Override
        public void init(IWorkbench workbench) {
        }
 
-       /* (non-Javadoc)
-        * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse
+        * .swt.widgets.Composite)
         */
        /** {@inheritDoc} */
        @Override
        protected Control createContents(Composite parent) {
         */
        /** {@inheritDoc} */
        @Override
        protected Control createContents(Composite parent) {
-               
+
                Composite composite = new Composite(parent, SWT.NULL);
                composite.setLayout(new GridLayout());
                Composite composite = new Composite(parent, SWT.NULL);
                composite.setLayout(new GridLayout());
-               
+
                final Button button_openFeatureTree = new Button(composite, SWT.PUSH);
                button_openFeatureTree.setText("Open FeatureTree Editor");
                final Button button_openFeatureTree = new Button(composite, SWT.PUSH);
                button_openFeatureTree.setText("Open FeatureTree Editor");
-               
+
                button_openFeatureTree.addSelectionListener(new SelectionAdapter() {
                        @Override
                        public void widgetSelected(SelectionEvent e) {
                                FeatureTreeEditorWizard featureTreeEditorDialog = new FeatureTreeEditorWizard();
                button_openFeatureTree.addSelectionListener(new SelectionAdapter() {
                        @Override
                        public void widgetSelected(SelectionEvent e) {
                                FeatureTreeEditorWizard featureTreeEditorDialog = new FeatureTreeEditorWizard();
-                               WizardDialog dialog = new WizardDialog(getShell(), featureTreeEditorDialog);
-                               
+                               WizardDialog dialog = new WizardDialog(getShell(),
+                                               featureTreeEditorDialog);
+
                                dialog.open();
                        }
                });
                                dialog.open();
                        }
                });
-               
+
                return composite;
        }
 }
                return composite;
        }
 }
index 77b9350029918ba51182478437cd979dc001917f..8679d677e2085a5b284a3badd90519dfa28ab269 100644 (file)
@@ -1,12 +1,12 @@
 // $Id$
 /**
 // $Id$
 /**
-* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy 
-* http://www.e-taxonomy.eu
-* 
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
+ * Copyright (C) 2007 EDIT
+ * European Distributed Institute of Taxonomy 
+ * http://www.e-taxonomy.eu
+ 
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * See LICENSE.TXT at the top of this package for the full license terms.
+ */
 
 package eu.etaxonomy.taxeditor.preference;
 
 
 package eu.etaxonomy.taxeditor.preference;
 
@@ -31,69 +31,77 @@ import org.eclipse.ui.IWorkbenchPreferencePage;
 public class MobotOpenUrlPreferences extends PreferencePage implements
                IWorkbenchPreferencePage {
 
 public class MobotOpenUrlPreferences extends PreferencePage implements
                IWorkbenchPreferencePage {
 
-
        private String openUrlServiceAccessPoint;
        private String openUrlImageMaxWidth;
        private String openUrlImageMaxHeight;
        private String openUrlServiceAccessPoint;
        private String openUrlImageMaxWidth;
        private String openUrlImageMaxHeight;
-       
-       /* (non-Javadoc)
-        * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
         */
        @Override
        public void init(IWorkbench workbench) {
                setPreferenceStore(PreferencesUtil.getPreferenceStore());
        }
 
         */
        @Override
        public void init(IWorkbench workbench) {
                setPreferenceStore(PreferencesUtil.getPreferenceStore());
        }
 
-       /* (non-Javadoc)
-        * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse
+        * .swt.widgets.Composite)
         */
        @Override
        protected Control createContents(Composite parent) {
                Composite container = new Composite(parent, SWT.NULL);
                final GridLayout gridLayout = new GridLayout();
                container.setLayout(gridLayout);
         */
        @Override
        protected Control createContents(Composite parent) {
                Composite container = new Composite(parent, SWT.NULL);
                final GridLayout gridLayout = new GridLayout();
                container.setLayout(gridLayout);
-               
+
                creatOpenUrlServiceAccessPoint(container);
                creatOpenUrlServiceAccessPoint(container);
-               
+
                createOpenUrlImageSize(container);
                createOpenUrlImageSize(container);
-               
+
                return container;
        }
                return container;
        }
-       
+
        /**
         * @param container
         */
        private void createOpenUrlImageSize(Composite container) {
        /**
         * @param container
         */
        private void createOpenUrlImageSize(Composite container) {
-               openUrlImageMaxWidth = getPreferenceStore().getString(IPreferenceKeys.OPENURL_IMAGE_MAX_WIDTH);
-               openUrlImageMaxHeight = getPreferenceStore().getString(IPreferenceKeys.OPENURL_IMAGE_MAX_HEIGHT);
-               
+               openUrlImageMaxWidth = getPreferenceStore().getString(
+                               IPreferenceKeys.OPENURL_IMAGE_MAX_WIDTH);
+               openUrlImageMaxHeight = getPreferenceStore().getString(
+                               IPreferenceKeys.OPENURL_IMAGE_MAX_HEIGHT);
+
                Composite composite = new Composite(container, SWT.NULL);
                final GridLayout gridLayout = new GridLayout(2, false);
                composite.setLayout(gridLayout);
                Composite composite = new Composite(container, SWT.NULL);
                final GridLayout gridLayout = new GridLayout(2, false);
                composite.setLayout(gridLayout);
-               
+
                final CLabel labelWidth = new CLabel(composite, SWT.NULL);
                labelWidth.setText("Image Maximum Width: ");
                final CLabel labelWidth = new CLabel(composite, SWT.NULL);
                labelWidth.setText("Image Maximum Width: ");
-               
+
                final Text textWidth = new Text(composite, SWT.BORDER);
                textWidth.setText(openUrlImageMaxWidth);
                textWidth.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
                final Text textWidth = new Text(composite, SWT.BORDER);
                textWidth.setText(openUrlImageMaxWidth);
                textWidth.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
-               
+
                textWidth.addModifyListener(new ModifyListener() {
                textWidth.addModifyListener(new ModifyListener() {
-                       
+
                        public void modifyText(ModifyEvent e) {
                                openUrlImageMaxWidth = textWidth.getText();
                        }
                });
                        public void modifyText(ModifyEvent e) {
                                openUrlImageMaxWidth = textWidth.getText();
                        }
                });
-               
+
                final CLabel labelHeight = new CLabel(composite, SWT.NULL);
                labelHeight.setText("Image Maximum Height: ");
                final CLabel labelHeight = new CLabel(composite, SWT.NULL);
                labelHeight.setText("Image Maximum Height: ");
-               
+
                final Text textHeight = new Text(composite, SWT.BORDER);
                textHeight.setText(openUrlImageMaxHeight);
                textHeight.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
                final Text textHeight = new Text(composite, SWT.BORDER);
                textHeight.setText(openUrlImageMaxHeight);
                textHeight.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
-               
+
                textHeight.addModifyListener(new ModifyListener() {
                textHeight.addModifyListener(new ModifyListener() {
-                       
+
                        public void modifyText(ModifyEvent e) {
                                openUrlImageMaxHeight = textHeight.getText();
                        }
                        public void modifyText(ModifyEvent e) {
                                openUrlImageMaxHeight = textHeight.getText();
                        }
@@ -101,32 +109,38 @@ public class MobotOpenUrlPreferences extends PreferencePage implements
        }
 
        private void creatOpenUrlServiceAccessPoint(Composite composite) {
        }
 
        private void creatOpenUrlServiceAccessPoint(Composite composite) {
-               openUrlServiceAccessPoint = getPreferenceStore().getString(IPreferenceKeys.OPENURL_ACCESS_POINT);
-               
+               openUrlServiceAccessPoint = getPreferenceStore().getString(
+                               IPreferenceKeys.OPENURL_ACCESS_POINT);
+
                final CLabel label = new CLabel(composite, SWT.NULL);
                label.setText("Mobot Open Url Service Access Point:");
                final CLabel label = new CLabel(composite, SWT.NULL);
                label.setText("Mobot Open Url Service Access Point:");
-               
+
                final Text text = new Text(composite, SWT.BORDER);
                text.setText(openUrlServiceAccessPoint);
                text.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
                final Text text = new Text(composite, SWT.BORDER);
                text.setText(openUrlServiceAccessPoint);
                text.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
-               
+
                text.addModifyListener(new ModifyListener() {
                text.addModifyListener(new ModifyListener() {
-                       
+
                        public void modifyText(ModifyEvent e) {
                                openUrlServiceAccessPoint = text.getText();
                        }
                });
        }
                        public void modifyText(ModifyEvent e) {
                                openUrlServiceAccessPoint = text.getText();
                        }
                });
        }
-       
-       /* (non-Javadoc)
+
+       /*
+        * (non-Javadoc)
+        * 
         * @see org.eclipse.jface.preference.PreferencePage#performOk()
         */
        @Override
        public boolean performOk() {
         * @see org.eclipse.jface.preference.PreferencePage#performOk()
         */
        @Override
        public boolean performOk() {
-               getPreferenceStore().setValue(IPreferenceKeys.OPENURL_ACCESS_POINT, openUrlServiceAccessPoint);
-               getPreferenceStore().setValue(IPreferenceKeys.OPENURL_IMAGE_MAX_WIDTH, openUrlImageMaxWidth);
-               getPreferenceStore().setValue(IPreferenceKeys.OPENURL_IMAGE_MAX_HEIGHT, openUrlImageMaxHeight);
-               
+               getPreferenceStore().setValue(IPreferenceKeys.OPENURL_ACCESS_POINT,
+                               openUrlServiceAccessPoint);
+               getPreferenceStore().setValue(IPreferenceKeys.OPENURL_IMAGE_MAX_WIDTH,
+                               openUrlImageMaxWidth);
+               getPreferenceStore().setValue(IPreferenceKeys.OPENURL_IMAGE_MAX_HEIGHT,
+                               openUrlImageMaxHeight);
+
                return super.performOk();
        }
 
                return super.performOk();
        }
 
index bde2e26f4d1e06e7877f0c1218fc00a78b697864..fd3b21782651b73a7abb12e5aa8af18fa1e0a94a 100644 (file)
@@ -1,24 +1,17 @@
 /**
 /**
-* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy 
-* http://www.e-taxonomy.eu
-* 
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
+ * Copyright (C) 2007 EDIT
+ * European Distributed Institute of Taxonomy 
+ * http://www.e-taxonomy.eu
+ 
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * See LICENSE.TXT at the top of this package for the full license terms.
+ */
 package eu.etaxonomy.taxeditor.preference;
 
 package eu.etaxonomy.taxeditor.preference;
 
-import java.util.HashMap;
-import java.util.Map;
+import java.util.List;
 
 
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.RadioGroupFieldEditor;
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.IWorkbenchPreferencePage;
 
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.IWorkbenchPreferencePage;
 
@@ -27,92 +20,59 @@ import eu.etaxonomy.taxeditor.model.NomenclaturalCodeHelper;
 import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
 
 /**
 import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
 
 /**
- * <p>NomenclaturalCodePreferences class.</p>
- *
+ * <p>
+ * NomenclaturalCodePreferences class.
+ * </p>
+ * 
  * @author p.ciardelli
  * @created 16.09.2008
  * @version 1.0
  */
  * @author p.ciardelli
  * @created 16.09.2008
  * @version 1.0
  */
-public class NomenclaturalCodePreferences extends PreferencePage implements
-               IWorkbenchPreferencePage {
-
-       /** Constant <code>PLUGIN_ID="eu.etaxonomy.taxeditor.preferences.nome"{trunked}</code> */
-       public static final String PLUGIN_ID = "eu.etaxonomy.taxeditor.preferences.nomenclatural";
-       
-       private NomenclaturalCode preferredCode;
+public class NomenclaturalCodePreferences extends FieldEditorPreferencePage
+               implements IWorkbenchPreferencePage {
 
 
-       private Map<NomenclaturalCode, Button> buttons = new HashMap<NomenclaturalCode, Button>();
-               
-       /**
-        * <p>Constructor for NomenclaturalCodePreferences.</p>
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors
+        * ()
         */
         */
-       public NomenclaturalCodePreferences() {
-               super();
-               setDescription("Choose which nomenclatural code you would like to use for scientific names unless otherwise specified.");
+       @Override
+       protected void createFieldEditors() {
+
+               addField(new RadioGroupFieldEditor(
+                               IPreferenceKeys.PREFERRED_NOMENCLATURAL_CODE_KEY,
+                               "Available Codes", 1, getLabelAndValues(),
+                               getFieldEditorParent(), true));
+
        }
 
        /**
        }
 
        /**
-        * {@inheritDoc}
-        *
-        * Create contents of the preference page
+        * @return
         */
         */
-       @Override
-       public Control createContents(Composite parent) {
-               
-               Composite container = new Composite(parent, SWT.NULL);
-               container.setLayout(new GridLayout());
-               
-               for (final NomenclaturalCode code : NomenclaturalCodeHelper.getSupportedCodes()) {
-                       Button button = new Button(container, SWT.RADIO);
-                       button.setText(NomenclaturalCodeHelper.getDescription(code));
-                       button.addSelectionListener(new SelectionAdapter() {
-                               public void widgetSelected(SelectionEvent e) {
-                                       preferredCode = code;
-                               }
-                       });
-                       buttons.put(code, button);
-               }
-               
-               preferredCode = PreferencesUtil.getPreferredNomenclaturalCode();
-               if (preferredCode == null) {
-                       preferredCode = NomenclaturalCodeHelper.getDefaultCode();
-                       PreferencesUtil.setPreferredNomenclaturalCode(preferredCode);
+       private String[][] getLabelAndValues() {
+               List<NomenclaturalCode> supportedCodes = NomenclaturalCodeHelper
+                               .getSupportedCodes();
+               String[][] labelAndValues = new String[supportedCodes.size()][2];
+               for (int i = 0; i < supportedCodes.size(); i++) {
+                       labelAndValues[i][0] = NomenclaturalCodeHelper
+                                       .getDescription(supportedCodes.get(i));
+                       labelAndValues[i][1] = PreferencesUtil
+                                       .getPreferenceKey(supportedCodes.get(i));
                }
                }
-               setButton(preferredCode);               
-               
-               return container;
+               return labelAndValues;
        }
 
        /**
         * {@inheritDoc}
        }
 
        /**
         * {@inheritDoc}
-        *
+        * 
         * Initialize the preference page
         */
        public void init(IWorkbench workbench) {
         * Initialize the preference page
         */
        public void init(IWorkbench workbench) {
-               setPreferenceStore(TaxeditorStorePlugin.getDefault().getPreferenceStore());
-       }
-       
-       /**
-        * <p>performDefaults</p>
-        */
-       protected void performDefaults() {
-               setButton(NomenclaturalCodeHelper.getDefaultCode());
-       }
-       
-       /**
-        * <p>performOk</p>
-        *
-        * @return a boolean.
-        */
-       public boolean performOk() {
-               PreferencesUtil.setPreferredNomenclaturalCode(preferredCode);
-               return true;
-       }
-       
-       private void setButton(NomenclaturalCode preferredCode) {
-               this.preferredCode = preferredCode;
-               for (NomenclaturalCode code : buttons.keySet()) {
-                       buttons.get(code).setSelection(code.equals(preferredCode));
-               }
+               setPreferenceStore(TaxeditorStorePlugin.getDefault()
+                               .getPreferenceStore());
+               setDescription("Choose which nomenclatural code you would like to use for scientific names unless otherwise specified.");
        }
        }
+
 }
 }
index 310ee58a367152e4f5f8046eae9de0b3cbdb01df..aaa47ef9da6e0baca54180ca6008490406ece5e5 100644 (file)
@@ -1,11 +1,11 @@
 /**
 /**
-* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy 
-* http://www.e-taxonomy.eu
-* 
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
+ * Copyright (C) 2007 EDIT
+ * European Distributed Institute of Taxonomy 
+ * http://www.e-taxonomy.eu
+ 
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * See LICENSE.TXT at the top of this package for the full license terms.
+ */
 
 package eu.etaxonomy.taxeditor.preference;
 
 
 package eu.etaxonomy.taxeditor.preference;
 
@@ -45,70 +45,83 @@ import eu.etaxonomy.taxeditor.store.StoreUtil;
 import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
 
 /**
 import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
 
 /**
- * <p>PreferencesUtil class.</p>
- *
+ * <p>
+ * PreferencesUtil class.
+ * </p>
+ * 
  * @author p.ciardelli
  * @author n.hoffmann
  * @created 05.12.2008
  * @version 1.0
  */
  * @author p.ciardelli
  * @author n.hoffmann
  * @created 05.12.2008
  * @version 1.0
  */
-public class PreferencesUtil implements IPreferenceKeys{
+public class PreferencesUtil implements IPreferenceKeys {
 
        /**
         * 
         */
        public static final String PREFERRED_TERMS_CHANGE = "preferred_terms";
 
        /**
         * 
         */
        public static final String PREFERRED_TERMS_CHANGE = "preferred_terms";
-       
 
 
-       
        /**
        /**
-        * <p>getPreferenceStore</p>
-        *
+        * <p>
+        * getPreferenceStore
+        * </p>
+        * 
         * @return a {@link org.eclipse.jface.preference.IPreferenceStore} object.
         */
        public static IPreferenceStore getPreferenceStore() {
                return TaxeditorStorePlugin.getDefault().getPreferenceStore();
        }
         * @return a {@link org.eclipse.jface.preference.IPreferenceStore} object.
         */
        public static IPreferenceStore getPreferenceStore() {
                return TaxeditorStorePlugin.getDefault().getPreferenceStore();
        }
-               
+
        /**
        /**
-        * <p>setPreferredNomenclaturalCode</p>
-        *
-        * @param preferredCode a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode} object.
+        * <p>
+        * setPreferredNomenclaturalCode
+        * </p>
+        * 
+        * @param preferredCode
+        *            a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode}
+        *            object.
         */
         */
-       public static void setPreferredNomenclaturalCode(NomenclaturalCode preferredCode) {
-               getPreferenceStore().setValue(PREFERRED_NOMENCLATURAL_CODE_KEY, getPreferenceKey(preferredCode));
+       public static void setPreferredNomenclaturalCode(
+                       NomenclaturalCode preferredCode) {
+               getPreferenceStore().setValue(PREFERRED_NOMENCLATURAL_CODE_KEY,
+                               getPreferenceKey(preferredCode));
        }
        }
-               
+
        /**
        /**
-        * <p>getPreferredNomenclaturalCode</p>
-        *
+        * <p>
+        * getPreferredNomenclaturalCode
+        * </p>
+        * 
         * @return a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode} object.
         */
        public static NomenclaturalCode getPreferredNomenclaturalCode() {
         * @return a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode} object.
         */
        public static NomenclaturalCode getPreferredNomenclaturalCode() {
-       
+
                for (NomenclaturalCode code : NomenclaturalCodeHelper.getAllCodes()) {
                for (NomenclaturalCode code : NomenclaturalCodeHelper.getAllCodes()) {
-                       String preferredCode = getPreferenceStore().getString(PREFERRED_NOMENCLATURAL_CODE_KEY);
+                       String preferredCode = getPreferenceStore().getString(
+                                       PREFERRED_NOMENCLATURAL_CODE_KEY);
                        if (getPreferenceKey(code).equals(preferredCode)) {
                                return code;
                        }
                }
                return null;
        }
                        if (getPreferenceKey(code).equals(preferredCode)) {
                                return code;
                        }
                }
                return null;
        }
-       
+
        /**
         * Get the match strategy for the given class that was stored in preferences
         * or the default strategy if it was not stored in preferences
        /**
         * Get the match strategy for the given class that was stored in preferences
         * or the default strategy if it was not stored in preferences
-        *
-        * @param clazz a {@link java.lang.Class} object.
+        * 
+        * @param clazz
+        *            a {@link java.lang.Class} object.
         * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
         */
         * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
         */
-       public static IMatchStrategy getMatchStrategy(Class clazz){
+       public static IMatchStrategy getMatchStrategy(Class clazz) {
                String className = clazz.getName();
                String className = clazz.getName();
-               if(getPreferenceStore().getBoolean(MATCH_STRATEGY_PREFIX + className)){
+               if (getPreferenceStore().getBoolean(MATCH_STRATEGY_PREFIX + className)) {
                        IMatchStrategy matchStrategy = getDefaultMatchStrategy(clazz);
                        IMatchStrategy matchStrategy = getDefaultMatchStrategy(clazz);
-                       
-                       for(String fieldName : matchStrategy.getMatchFieldPropertyNames()){
-                               String matchModeName = getPreferenceStore().getString(getMatchStrategyFieldName(className, fieldName));
+
+                       for (String fieldName : matchStrategy.getMatchFieldPropertyNames()) {
+                               String matchModeName = getPreferenceStore().getString(
+                                               getMatchStrategyFieldName(className, fieldName));
                                MatchMode matchMode = MatchMode.valueOf(matchModeName);
                                try {
                                        matchStrategy.setMatchMode(fieldName, matchMode);
                                MatchMode matchMode = MatchMode.valueOf(matchModeName);
                                try {
                                        matchStrategy.setMatchMode(fieldName, matchMode);
@@ -117,29 +130,32 @@ public class PreferencesUtil implements IPreferenceKeys{
                                        throw new RuntimeException(e);
                                }
                        }
                                        throw new RuntimeException(e);
                                }
                        }
-                       
+
                        return matchStrategy;
                }
                return getDefaultMatchStrategy(clazz);
        }
                        return matchStrategy;
                }
                return getDefaultMatchStrategy(clazz);
        }
-       
+
        /**
         * Stores a matchStrategy into the preference store.
        /**
         * Stores a matchStrategy into the preference store.
-        *
-        * @param matchStrategy a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
+        * 
+        * @param matchStrategy
+        *            a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy}
+        *            object.
         */
         */
-       public static void setMatchStrategy(IMatchStrategy matchStrategy){
+       public static void setMatchStrategy(IMatchStrategy matchStrategy) {
                String className = matchStrategy.getMatchClass().getName();
                getPreferenceStore().setValue(MATCH_STRATEGY_PREFIX + className, true);
                String className = matchStrategy.getMatchClass().getName();
                getPreferenceStore().setValue(MATCH_STRATEGY_PREFIX + className, true);
-               
+
                Set<String> matchFields = matchStrategy.getMatchFieldPropertyNames();
                Set<String> matchFields = matchStrategy.getMatchFieldPropertyNames();
-               
-               for(String fieldName : matchFields){
-                       getPreferenceStore().setValue(getMatchStrategyFieldName(className, fieldName),
+
+               for (String fieldName : matchFields) {
+                       getPreferenceStore().setValue(
+                                       getMatchStrategyFieldName(className, fieldName),
                                        matchStrategy.getMatchMode(fieldName).name());
                }
        }
                                        matchStrategy.getMatchMode(fieldName).name());
                }
        }
-       
+
        /**
         * Helper method to create the preference property for a match field.
         * 
        /**
         * Helper method to create the preference property for a match field.
         * 
@@ -147,47 +163,56 @@ public class PreferencesUtil implements IPreferenceKeys{
         * @param fieldName
         * @return
         */
         * @param fieldName
         * @return
         */
-       private static String getMatchStrategyFieldName(String className, String fieldName){
-               return MATCH_STRATEGY_PREFIX + className  + "." +  fieldName;
+       private static String getMatchStrategyFieldName(String className,
+                       String fieldName) {
+               return MATCH_STRATEGY_PREFIX + className + "." + fieldName;
        }
        }
-       
+
        /**
         * Returns the default match strategy for a given class.
        /**
         * Returns the default match strategy for a given class.
-        *
-        * @param clazz a {@link java.lang.Class} object.
+        * 
+        * @param clazz
+        *            a {@link java.lang.Class} object.
         * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
         */
         * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
         */
-       public static IMatchStrategy getDefaultMatchStrategy(Class clazz){
+       public static IMatchStrategy getDefaultMatchStrategy(Class clazz) {
                return DefaultMatchStrategy.NewInstance(clazz);
        }
                return DefaultMatchStrategy.NewInstance(clazz);
        }
-       
-       
+
        /**
        /**
-        * <p>getDateFormatPattern</p>
-        *
+        * <p>
+        * getDateFormatPattern
+        * </p>
+        * 
         * @return a {@link java.lang.String} object.
         */
         * @return a {@link java.lang.String} object.
         */
-       public static String getDateFormatPattern(){
+       public static String getDateFormatPattern() {
                // TODO make this configurable in properties
                String pattern = "Y-M-d H:m";
                return pattern;
        }
                // TODO make this configurable in properties
                String pattern = "Y-M-d H:m";
                return pattern;
        }
-       
+
        /**
        /**
-        * <p>addTermToPreferredTerms</p>
-        *
-        * @param term a T object.
-        * @param <T> a T object.
+        * <p>
+        * addTermToPreferredTerms
+        * </p>
+        * 
+        * @param term
+        *            a T object.
+        * @param <T>
+        *            a T object.
         */
         */
-       public static <T extends TermBase> void addTermToPreferredTerms(T term){
+       public static <T extends TermBase> void addTermToPreferredTerms(T term) {
 
 
-//             VocabularyEnum vocabulary = VocabularyEnum.getVocabularyEnum(term.getClass());
-//             
-//             getPreferenceStore().setValue(getPreferenceKey(term), VocabularyStore.getTermVocabulary(vocabulary).getTerms().contains(term));
-//             
-//             firePreferencesChanged(term.getClass());
+               // VocabularyEnum vocabulary =
+               // VocabularyEnum.getVocabularyEnum(term.getClass());
+               //
+               // getPreferenceStore().setValue(getPreferenceKey(term),
+               // VocabularyStore.getTermVocabulary(vocabulary).getTerms().contains(term));
+               //
+               // firePreferencesChanged(term.getClass());
        }
        }
-       
+
        /**
         * Construct a unique key using the CdmBase object's uuid
         * 
        /**
         * Construct a unique key using the CdmBase object's uuid
         * 
@@ -196,10 +221,9 @@ public class PreferencesUtil implements IPreferenceKeys{
         */
        private static String getPreferenceKey(ICdmBase cdmBase) {
                cdmBase = (ICdmBase) HibernateProxyHelper.deproxy(cdmBase);
         */
        private static String getPreferenceKey(ICdmBase cdmBase) {
                cdmBase = (ICdmBase) HibernateProxyHelper.deproxy(cdmBase);
-               
-               String key = cdmBase.getClass().getName()
-                               . concat(".")
-                               . concat(cdmBase.getUuid().toString());
+
+               String key = cdmBase.getClass().getName().concat(".")
+                               .concat(cdmBase.getUuid().toString());
                if (key.contains("javassist")) {
                        StoreUtil.info("proxy");
                }
                if (key.contains("javassist")) {
                        StoreUtil.info("proxy");
                }
@@ -212,82 +236,103 @@ public class PreferencesUtil implements IPreferenceKeys{
         * @param cdmBase
         * @return
         */
         * @param cdmBase
         * @return
         */
-       private static String getPreferenceKey(IDefinedTerm definedTerm) {
+       public static String getPreferenceKey(IDefinedTerm definedTerm) {
                definedTerm = (IDefinedTerm) HibernateProxyHelper.deproxy(definedTerm);
                definedTerm = (IDefinedTerm) HibernateProxyHelper.deproxy(definedTerm);
-               String key = definedTerm.getClass().getName()
-                               . concat(".")
-                               . concat(definedTerm.getUuid().toString());
+               String key = definedTerm.getClass().getName().concat(".")
+                               .concat(definedTerm.getUuid().toString());
                if (key.contains("javassist")) {
                if (key.contains("javassist")) {
-                       StoreUtil.warn(PreferencesUtil.class, "Trying to persist a preference based on a proxy class.");
+                       StoreUtil.warn(PreferencesUtil.class,
+                                       "Trying to persist a preference based on a proxy class.");
                }
                return key;
        }
                }
                return key;
        }
-       
+
        /**
         * Retrieves search preferences from the preference store
        /**
         * Retrieves search preferences from the preference store
-        *
+        * 
         * @return an {@link ITaxonServiceConfigurator} to pass to search methods
         */
        public static ITaxonServiceConfigurator getSearchConfigurator() {
                ITaxonServiceConfigurator configurator = initializeSearchConfigurator();
         * @return an {@link ITaxonServiceConfigurator} to pass to search methods
         */
        public static ITaxonServiceConfigurator getSearchConfigurator() {
                ITaxonServiceConfigurator configurator = initializeSearchConfigurator();
-               
-               configurator.setDoTaxa(getPreferenceStore().getBoolean(TAXON_SERVICE_CONFIGURATOR_TAXA));
-               configurator.setDoSynonyms(getPreferenceStore().getBoolean(TAXON_SERVICE_CONFIGURATOR_SYNONYMS));
-               configurator.setDoNamesWithoutTaxa(getPreferenceStore().getBoolean(TAXON_SERVICE_CONFIGURATOR_NAMES));
-               configurator.setDoTaxaByCommonNames(getPreferenceStore().getBoolean(TAXON_SERVICE_CONFIGURATOR_COMMON_NAMES));
+
+               configurator.setDoTaxa(getPreferenceStore().getBoolean(
+                               TAXON_SERVICE_CONFIGURATOR_TAXA));
+               configurator.setDoSynonyms(getPreferenceStore().getBoolean(
+                               TAXON_SERVICE_CONFIGURATOR_SYNONYMS));
+               configurator.setDoNamesWithoutTaxa(getPreferenceStore().getBoolean(
+                               TAXON_SERVICE_CONFIGURATOR_NAMES));
+               configurator.setDoTaxaByCommonNames(getPreferenceStore().getBoolean(
+                               TAXON_SERVICE_CONFIGURATOR_COMMON_NAMES));
 
                return configurator;
        }
 
                return configurator;
        }
-       
+
        /**
         * create new preferences, setting all search options to true
        /**
         * create new preferences, setting all search options to true
-        *
-        * @return a {@link eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator} object.
+        * 
+        * @return a
+        *         {@link eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator}
+        *         object.
         */
         */
-       public static ITaxonServiceConfigurator initializeSearchConfigurator(){
-               ITaxonServiceConfigurator configurator = TaxonServiceConfiguratorImpl.NewInstance();
-               
+       public static ITaxonServiceConfigurator initializeSearchConfigurator() {
+               ITaxonServiceConfigurator configurator = TaxonServiceConfiguratorImpl
+                               .NewInstance();
+
                configurator.setDoTaxa(true);
                configurator.setDoSynonyms(true);
                configurator.setDoNamesWithoutTaxa(true);
                configurator.setDoTaxaByCommonNames(true);
                configurator.setDoTaxa(true);
                configurator.setDoSynonyms(true);
                configurator.setDoNamesWithoutTaxa(true);
                configurator.setDoTaxaByCommonNames(true);
-               
-               configurator.setTaxonPropertyPath(Arrays.asList("$", 
-                               "titleCache", "name", "name.$", "relationsFromThisTaxon.$"));
-               
-               configurator.setSynonymPropertyPath(Arrays.asList("$", 
-                               "titleCache", "name", "name.$", "synonymRelations.relatedTo.*"));
-               
-               // DEFAULT VALUES               
-               // match mode is a simple like, actually all other match modes are kind of bogus
-               configurator.setMatchMode(eu.etaxonomy.cdm.persistence.query.MatchMode.LIKE);
+
+               configurator.setTaxonPropertyPath(Arrays.asList("$", "titleCache",
+                               "name", "name.$", "relationsFromThisTaxon.$"));
+
+               configurator.setSynonymPropertyPath(Arrays.asList("$", "titleCache",
+                               "name", "name.$", "synonymRelations.relatedTo.*"));
+
+               // DEFAULT VALUES
+               // match mode is a simple like, actually all other match modes are kind
+               // of bogus
+               configurator
+                               .setMatchMode(eu.etaxonomy.cdm.persistence.query.MatchMode.LIKE);
                // we set page number and size here as this should always be unlimited
                configurator.setPageNumber(0);
                // TODO currently limit results to 10000
                configurator.setPageSize(10000);
                // we set page number and size here as this should always be unlimited
                configurator.setPageNumber(0);
                // TODO currently limit results to 10000
                configurator.setPageSize(10000);
-               
+
                return configurator;
        }
                return configurator;
        }
-       
+
        /**
         * Store search preferences
        /**
         * Store search preferences
-        *
-        * @param configurator a {@link eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator} object.
+        * 
+        * @param configurator
+        *            a
+        *            {@link eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator}
+        *            object.
         */
         */
-       public static void setSearchConfigurator(ITaxonServiceConfigurator configurator){
-               getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_TAXA, configurator.isDoTaxa());
-               getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_SYNONYMS, configurator.isDoSynonyms());
-               getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_NAMES, configurator.isDoNamesWithoutTaxa());
-               getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_COMMON_NAMES, configurator.isDoTaxaByCommonNames());
+       public static void setSearchConfigurator(
+                       ITaxonServiceConfigurator configurator) {
+               getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_TAXA,
+                               configurator.isDoTaxa());
+               getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_SYNONYMS,
+                               configurator.isDoSynonyms());
+               getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_NAMES,
+                               configurator.isDoNamesWithoutTaxa());
+               getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_COMMON_NAMES,
+                               configurator.isDoTaxaByCommonNames());
        }
 
        /**
        }
 
        /**
-        * <p>firePreferencesChanged</p>
-        *
-        * @param clazz a {@link java.lang.Class} object.
+        * <p>
+        * firePreferencesChanged
+        * </p>
+        * 
+        * @param clazz
+        *            a {@link java.lang.Class} object.
         */
        public static void firePreferencesChanged(Class clazz) {
         */
        public static void firePreferencesChanged(Class clazz) {
-               getPreferenceStore().firePropertyChangeEvent(PREFERRED_TERMS_CHANGE, null, clazz);
+               getPreferenceStore().firePropertyChangeEvent(PREFERRED_TERMS_CHANGE,
+                               null, clazz);
        }
 
        /**
        }
 
        /**
@@ -295,40 +340,53 @@ public class PreferencesUtil implements IPreferenceKeys{
         */
        public static void setDefaults() {
                getPreferenceStore().setDefault(TAXON_SERVICE_CONFIGURATOR_TAXA, true);
         */
        public static void setDefaults() {
                getPreferenceStore().setDefault(TAXON_SERVICE_CONFIGURATOR_TAXA, true);
-               getPreferenceStore().setDefault(TAXON_SERVICE_CONFIGURATOR_SYNONYMS, true);
-               getPreferenceStore().setDefault(EDIT_MAP_SERVICE_ACCES_POINT, "http://edit.br.fgov.be/edit_wp5/v1/areas.php");
-               getPreferenceStore().setDefault(SHOULD_CONNECT_AT_STARTUP, true);       
-               getPreferenceStore().setDefault(OPENURL_ACCESS_POINT, "http://www.biodiversitylibrary.org/openurl");
+               getPreferenceStore().setDefault(TAXON_SERVICE_CONFIGURATOR_SYNONYMS,
+                               true);
+               getPreferenceStore().setDefault(EDIT_MAP_SERVICE_ACCES_POINT,
+                               "http://edit.br.fgov.be/edit_wp5/v1/areas.php");
+               getPreferenceStore().setDefault(SHOULD_CONNECT_AT_STARTUP, true);
+               getPreferenceStore().setDefault(OPENURL_ACCESS_POINT,
+                               "http://www.biodiversitylibrary.org/openurl");
                getPreferenceStore().setDefault(OPENURL_IMAGE_MAX_WIDTH, "1000");
                getPreferenceStore().setDefault(OPENURL_IMAGE_MAX_HEIGHT, "1000");
        }
 
        /**
                getPreferenceStore().setDefault(OPENURL_IMAGE_MAX_WIDTH, "1000");
                getPreferenceStore().setDefault(OPENURL_IMAGE_MAX_HEIGHT, "1000");
        }
 
        /**
-        * <p>checkNomenclaturalCode</p>
+        * <p>
+        * checkNomenclaturalCode
+        * </p>
         */
         */
-       public static void checkNomenclaturalCode() {   
+       public static void checkNomenclaturalCode() {
                // First time Editor is opened, no nomenclatural code has been set
                if (PreferencesUtil.getPreferredNomenclaturalCode() == null) {
 
                        StoreUtil.info("No nomencatural code set.");
                // First time Editor is opened, no nomenclatural code has been set
                if (PreferencesUtil.getPreferredNomenclaturalCode() == null) {
 
                        StoreUtil.info("No nomencatural code set.");
-                       
+
                        Shell shell = StoreUtil.getShell();
                        Shell shell = StoreUtil.getShell();
-                       
+
                        // Query user re: preferred nom. code
                        Dialog dialog = new InitNomenclaturalCodePrefDialog(shell);
                        dialog.open();
                        // Query user re: preferred nom. code
                        Dialog dialog = new InitNomenclaturalCodePrefDialog(shell);
                        dialog.open();
-                       
+
                        // Short message confirming user's choice
                        // Short message confirming user's choice
-                       NomenclaturalCode code = PreferencesUtil.getPreferredNomenclaturalCode();
-                       MessageDialog.openInformation(shell, "Nomenclatural code set", 
-                                       "The following has been set as your preferred nomenclatural code:\n\n\t" + 
-                                       NomenclaturalCodeHelper.getDescription(code) + "\n\nYou can change the nomenclatural code at any time in the \"Preferences\" menu.");
+                       NomenclaturalCode code = PreferencesUtil
+                                       .getPreferredNomenclaturalCode();
+                       MessageDialog
+                                       .openInformation(
+                                                       shell,
+                                                       "Nomenclatural code set",
+                                                       "The following has been set as your preferred nomenclatural code:\n\n\t"
+                                                                       + NomenclaturalCodeHelper
+                                                                                       .getDescription(code)
+                                                                       + "\n\nYou can change the nomenclatural code at any time in the \"Preferences\" menu.");
                }
        }
 
        /**
                }
        }
 
        /**
-        * <p>getMapServiceAccessPoint</p>
-        *
+        * <p>
+        * getMapServiceAccessPoint
+        * </p>
+        * 
         * @return a {@link java.lang.String} object.
         */
        public static String getMapServiceAccessPoint() {
         * @return a {@link java.lang.String} object.
         */
        public static String getMapServiceAccessPoint() {
@@ -336,8 +394,10 @@ public class PreferencesUtil implements IPreferenceKeys{
        }
 
        /**
        }
 
        /**
-        * <p>shouldConnectAtStartUp</p>
-        *
+        * <p>
+        * shouldConnectAtStartUp
+        * </p>
+        * 
         * @return a boolean.
         */
        public static boolean shouldConnectAtStartUp() {
         * @return a boolean.
         */
        public static boolean shouldConnectAtStartUp() {
@@ -345,60 +405,77 @@ public class PreferencesUtil implements IPreferenceKeys{
        }
 
        /**
        }
 
        /**
-        * <p>getDefaultFeatureTreeForTextualDescription</p>
-        *
+        * <p>
+        * getDefaultFeatureTreeForTextualDescription
+        * </p>
+        * 
         * @return a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
         */
        public static FeatureTree getDefaultFeatureTreeForTextualDescription() {
         * @return a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
         */
        public static FeatureTree getDefaultFeatureTreeForTextualDescription() {
-               String uuidString = getPreferenceStore().getString(FEATURE_TREE_DEFAULT_TEXT);
-               return CdmUtils.isEmpty(uuidString) ? null : CdmStore.getService(IFeatureTreeService.class).load(UUID.fromString(uuidString));
+               String uuidString = getPreferenceStore().getString(
+                               FEATURE_TREE_DEFAULT_TEXT);
+               return CdmUtils.isEmpty(uuidString) ? null : CdmStore.getService(
+                               IFeatureTreeService.class).load(UUID.fromString(uuidString));
        }
 
        /**
        }
 
        /**
-        * <p>getDefaultFeatureTreeForStructuredDescription</p>
-        *
+        * <p>
+        * getDefaultFeatureTreeForStructuredDescription
+        * </p>
+        * 
         * @return a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
         */
        public static FeatureTree getDefaultFeatureTreeForStructuredDescription() {
         * @return a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
         */
        public static FeatureTree getDefaultFeatureTreeForStructuredDescription() {
-               String uuidString = getPreferenceStore().getString(FEATURE_TREE_DEFAULT_STRUCTURE);
-               return CdmUtils.isEmpty(uuidString) ? null : CdmStore.getService(IFeatureTreeService.class).load(UUID.fromString(uuidString));
+               String uuidString = getPreferenceStore().getString(
+                               FEATURE_TREE_DEFAULT_STRUCTURE);
+               return CdmUtils.isEmpty(uuidString) ? null : CdmStore.getService(
+                               IFeatureTreeService.class).load(UUID.fromString(uuidString));
        }
 
        /**
        }
 
        /**
-        * <p>setSortRanksHierarchichally</p>
-        *
-        * @param selection a boolean.
+        * <p>
+        * setSortRanksHierarchichally
+        * </p>
+        * 
+        * @param selection
+        *            a boolean.
         */
        public static void setSortRanksHierarchichally(boolean selection) {
                getPreferenceStore().setValue(SORT_RANKS_HIERARCHICHALLY, selection);
         */
        public static void setSortRanksHierarchichally(boolean selection) {
                getPreferenceStore().setValue(SORT_RANKS_HIERARCHICHALLY, selection);
-       }       
-       
+       }
+
        /**
        /**
-        * <p>getSortRanksHierarchichally</p>
-        *
+        * <p>
+        * getSortRanksHierarchichally
+        * </p>
+        * 
         * @return a boolean.
         */
         * @return a boolean.
         */
-       public static boolean getSortRanksHierarchichally(){
+       public static boolean getSortRanksHierarchichally() {
                return getPreferenceStore().getBoolean(SORT_RANKS_HIERARCHICHALLY);
        }
 
        public static boolean isMultilanguageTextEditingCapability() {
                return getPreferenceStore().getBoolean(SORT_RANKS_HIERARCHICHALLY);
        }
 
        public static boolean isMultilanguageTextEditingCapability() {
-               return getPreferenceStore().getBoolean(MULTILANGUAGE_TEXT_EDITING_CAPABILITY);
+               return getPreferenceStore().getBoolean(
+                               MULTILANGUAGE_TEXT_EDITING_CAPABILITY);
        }
        }
-       
-       public static Language getGlobalLanguage(){
-               String languageUuidString = getPreferenceStore().getString(GLOBAL_LANGUAGE_UUID);
-                               
-               if(CdmUtils.isEmpty(languageUuidString)){
+
+       public static Language getGlobalLanguage() {
+               String languageUuidString = getPreferenceStore().getString(
+                               GLOBAL_LANGUAGE_UUID);
+
+               if (CdmUtils.isEmpty(languageUuidString)) {
                        return Language.DEFAULT();
                }
                        return Language.DEFAULT();
                }
-               
+
                UUID languageUuid = UUID.fromString(languageUuidString);
                UUID languageUuid = UUID.fromString(languageUuidString);
-               return (Language) CdmStore.getService(ITermService.class).load(languageUuid);
+               return (Language) CdmStore.getService(ITermService.class).load(
+                               languageUuid);
        }
        }
-       
-       public static void setGlobalLanguage(Language language){
-               getPreferenceStore().setValue(GLOBAL_LANGUAGE_UUID, language.getUuid().toString());
+
+       public static void setGlobalLanguage(Language language) {
+               getPreferenceStore().setValue(GLOBAL_LANGUAGE_UUID,
+                               language.getUuid().toString());
                CdmStore.setDefaultLanguage(language);
        }
 
                CdmStore.setDefaultLanguage(language);
        }
 
@@ -406,17 +483,18 @@ public class PreferencesUtil implements IPreferenceKeys{
         * @return
         */
        public static Map<MarkerType, Boolean> getEditMarkerTypePreferences() {
         * @return
         */
        public static Map<MarkerType, Boolean> getEditMarkerTypePreferences() {
-               List<MarkerType> markerTypes = CdmStore.getTermManager().getPreferredMarkerTypes();
-               
+               List<MarkerType> markerTypes = CdmStore.getTermManager()
+                               .getPreferredMarkerTypes();
+
                Map<MarkerType, Boolean> result = new HashMap<MarkerType, Boolean>();
                Map<MarkerType, Boolean> result = new HashMap<MarkerType, Boolean>();
-               
-               for(MarkerType markerType : markerTypes){
+
+               for (MarkerType markerType : markerTypes) {
                        String name = getMarkerTypeEditingPreferenceKey(markerType);
                        Boolean value = getPreferenceStore().getBoolean(name);
                        String name = getMarkerTypeEditingPreferenceKey(markerType);
                        Boolean value = getPreferenceStore().getBoolean(name);
-                       
+
                        result.put(markerType, value);
                }
                        result.put(markerType, value);
                }
-               
+
                return result;
        }
 
                return result;
        }
 
@@ -425,34 +503,44 @@ public class PreferencesUtil implements IPreferenceKeys{
         */
        public static void setEditMarkerTypePreferences(
                        Map<MarkerType, Boolean> markerTypeEditingMap) {
         */
        public static void setEditMarkerTypePreferences(
                        Map<MarkerType, Boolean> markerTypeEditingMap) {
-               for(MarkerType markerType : markerTypeEditingMap.keySet()){
+               for (MarkerType markerType : markerTypeEditingMap.keySet()) {
                        String name = getMarkerTypeEditingPreferenceKey(markerType);
                        String name = getMarkerTypeEditingPreferenceKey(markerType);
-                       getPreferenceStore().setValue(name, markerTypeEditingMap.get(markerType));
+                       getPreferenceStore().setValue(name,
+                                       markerTypeEditingMap.get(markerType));
                }
                }
-               
+
        }
        }
-       
-       private static String getMarkerTypeEditingPreferenceKey(MarkerType markerType){
+
+       private static String getMarkerTypeEditingPreferenceKey(
+                       MarkerType markerType) {
                markerType = (MarkerType) HibernateProxyHelper.deproxy(markerType);
                return markerType.getClass().getName() + EDIT_MARKER_TYPE_PREFIX;
        }
                markerType = (MarkerType) HibernateProxyHelper.deproxy(markerType);
                return markerType.getClass().getName() + EDIT_MARKER_TYPE_PREFIX;
        }
-       
+
        /**
        /**
-        * <p>setEditMarkerTypePreference</p>
-        *
-        * @param input a {@link org.eclipse.ui.IEditorInput} object.
-        * @param markerType a {@link eu.etaxonomy.cdm.model.common.MarkerType} object.
-        * @param edit a boolean.
+        * <p>
+        * setEditMarkerTypePreference
+        * </p>
+        * 
+        * @param input
+        *            a {@link org.eclipse.ui.IEditorInput} object.
+        * @param markerType
+        *            a {@link eu.etaxonomy.cdm.model.common.MarkerType} object.
+        * @param edit
+        *            a boolean.
         */
         */
-       public static void setEditMarkerTypePreference(MarkerType markerType, boolean edit) {
-               getPreferenceStore().setValue(getMarkerTypeEditingPreferenceKey(markerType), edit); 
+       public static void setEditMarkerTypePreference(MarkerType markerType,
+                       boolean edit) {
+               getPreferenceStore().setValue(
+                               getMarkerTypeEditingPreferenceKey(markerType), edit);
        }
 
        /**
         * @return
         */
        public static DerivedUnitFacadeConfigurator getDerivedUnitConfigurator() {
        }
 
        /**
         * @return
         */
        public static DerivedUnitFacadeConfigurator getDerivedUnitConfigurator() {
-               DerivedUnitFacadeConfigurator configurator = DerivedUnitFacadeConfigurator.NewInstance();
+               DerivedUnitFacadeConfigurator configurator = DerivedUnitFacadeConfigurator
+                               .NewInstance();
                configurator.setMoveDerivedUnitMediaToGallery(true);
                configurator.setMoveFieldObjectMediaToGallery(true);
                return configurator;
                configurator.setMoveDerivedUnitMediaToGallery(true);
                configurator.setMoveFieldObjectMediaToGallery(true);
                return configurator;
index c7d11ba6485c2225f29da757e3a9ccb9a1eb0996..92a530963d47788e2ef33c8202e83992ea95aadc 100644 (file)
 // $Id$
 /**
 // $Id$
 /**
-* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy 
-* http://www.e-taxonomy.eu
-* 
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
+ * Copyright (C) 2007 EDIT
+ * European Distributed Institute of Taxonomy 
+ * http://www.e-taxonomy.eu
+ 
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * See LICENSE.TXT at the top of this package for the full license terms.
+ */
 
 package eu.etaxonomy.taxeditor.preference;
 
 
 package eu.etaxonomy.taxeditor.preference;
 
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Text;
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.StringFieldEditor;
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.IWorkbenchPreferencePage;
 
 /**
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.IWorkbenchPreferencePage;
 
 /**
- * <p>TaxonomicEditorGeneralPreferences class.</p>
- *
+ * <p>
+ * TaxonomicEditorGeneralPreferences class.
+ * </p>
+ * 
  * @author n.hoffmann
  * @created Sep 1, 2009
  * @version 1.0
  */
  * @author n.hoffmann
  * @created Sep 1, 2009
  * @version 1.0
  */
-public class TaxonomicEditorGeneralPreferences extends PreferencePage implements
-               IWorkbenchPreferencePage {
-
-       boolean showUuidInSupplementalView;
-
-       private String editMapServiceAccessPoint;
-
-       private boolean shouldConnectAtStartup;
-
-       private boolean shouldExpandSectionWhenDataAvailable;
+public class TaxonomicEditorGeneralPreferences extends
+               FieldEditorPreferencePage implements IWorkbenchPreferencePage {
 
 
-       private boolean shouldShowExperimentalFeatures;
-
-       
-       /* (non-Javadoc)
-        * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors
+        * ()
         */
         */
-       /** {@inheritDoc} */
        @Override
        @Override
-       protected Control createContents(Composite parent) {
-               Composite container = new Composite(parent, SWT.NULL);
-               final GridLayout gridLayout = new GridLayout();
-               container.setLayout(gridLayout);
-               
-               createShowUuidInSupplementalView(container);
-               createMapServiceAccessPoint(container);
-               createShouldConnectAtStartUp(container);
-               createShouldExpandSectionWhenDataAvailable(container);
-               
-               createShowExperimentalFeatures(container);
-               
-               return container;
-       }
-
-
-       private void createShouldExpandSectionWhenDataAvailable(Composite container) {
-               shouldExpandSectionWhenDataAvailable = getPreferenceStore().getBoolean(IPreferenceKeys.SHOULD_EXPAND_SECTION_WHEN_DATA_AVAILABLE);
-               
-               final Composite composite = createComposite(container);
-               
-               final Button button = new Button(composite, SWT.CHECK);
-               button.setText("Should expand sections when data is available (Details View)");
-               
-               button.setSelection(shouldExpandSectionWhenDataAvailable);
-               
-               button.addSelectionListener(new SelectionAdapter(){
-                       @Override
-                       public void widgetSelected(SelectionEvent e) {
-                               shouldExpandSectionWhenDataAvailable = button.getSelection();
-                       }
-               });
-               
-       }
+       protected void createFieldEditors() {
+               addField(new BooleanFieldEditor(PreferencesUtil.SHOW_DEBUG_INFORMATION,
+                               "Show UUID and object ID in supplemental data view.",
+                               getFieldEditorParent()));
+               addField(new BooleanFieldEditor(
+                               IPreferenceKeys.SHOULD_EXPAND_SECTION_WHEN_DATA_AVAILABLE,
+                               "Should expand sections when data is available (Details View)",
+                               getFieldEditorParent()));
+               addField(new StringFieldEditor(
+                               IPreferenceKeys.EDIT_MAP_SERVICE_ACCES_POINT,
+                               "EDIT Map Service Access Point:", getFieldEditorParent()));
+               addField(new BooleanFieldEditor(
+                               IPreferenceKeys.SHOULD_CONNECT_AT_STARTUP,
+                               "Connect to last used datasource when launching",
+                               getFieldEditorParent()));
+               addField(new BooleanFieldEditor(
+                               IPreferenceKeys.SHOW_EXPERIMENTAL_FEATURES,
+                               "Show experimental features", getFieldEditorParent()));
 
 
-       private void createMapServiceAccessPoint(Composite composite) {
-               editMapServiceAccessPoint = PreferencesUtil.getMapServiceAccessPoint();
-               
-//             Composite composite = createComposite(parent);
-               
-               final CLabel label = new CLabel(composite, SWT.NULL);
-               label.setText("EDIT Map Service Access Point:");
-               
-               final Text text = new Text(composite, SWT.BORDER);
-               text.setText(editMapServiceAccessPoint);
-               text.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
-               
-               text.addModifyListener(new ModifyListener() {
-                       
-                       public void modifyText(ModifyEvent e) {
-                               editMapServiceAccessPoint = text.getText();
-                       }
-               });
        }
        }
-       
 
 
-
-       private void createShowUuidInSupplementalView(Composite parent){
-               showUuidInSupplementalView = getPreferenceStore().getBoolean(PreferencesUtil.SHOW_DEBUG_INFORMATION);
-               
-               final Composite composite = createComposite(parent);
-               
-               final Button button_toggle = new Button(composite, SWT.CHECK);          
-               
-               
-               button_toggle.setText("Show UUID and object ID in supplemental data view.");
-               
-               button_toggle.setSelection(showUuidInSupplementalView);
-               
-               
-               button_toggle.addSelectionListener(new SelectionAdapter(){
-                       /* (non-Javadoc)
-                        * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
-                        */
-                       @Override
-                       public void widgetSelected(SelectionEvent e) {
-                               showUuidInSupplementalView = button_toggle.getSelection();
-                       }
-               });
-               
-       }
-       
-       private void createShouldConnectAtStartUp(Composite parent){
-               shouldConnectAtStartup = getPreferenceStore().getBoolean(IPreferenceKeys.SHOULD_CONNECT_AT_STARTUP);
-               
-               final Composite composite = createComposite(parent);
-               
-               final Button button_toggle = new Button(composite, SWT.CHECK);          
-               
-               
-               button_toggle.setText("Connect to last used datasource when launching.");
-               
-               button_toggle.setSelection(shouldConnectAtStartup);
-               
-               
-               button_toggle.addSelectionListener(new SelectionAdapter(){
-                       /* (non-Javadoc)
-                        * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
-                        */
-                       @Override
-                       public void widgetSelected(SelectionEvent e) {
-                               shouldConnectAtStartup = button_toggle.getSelection();
-                       }
-               });
-       }
-       
-       /**
-        * @param container
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
         */
         */
-       private void createShowExperimentalFeatures(Composite parent) {
-               shouldShowExperimentalFeatures = getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_EXPERIMENTAL_FEATURES);
-               final Composite composite = createComposite(parent);
-               
-               final Button button_toggle = new Button(composite, SWT.CHECK);          
-               
-               
-               button_toggle.setText("Show experimental features-");
-               
-               button_toggle.setSelection(shouldShowExperimentalFeatures);
-               
-               
-               button_toggle.addSelectionListener(new SelectionAdapter(){
-                       /* (non-Javadoc)
-                        * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
-                        */
-                       @Override
-                       public void widgetSelected(SelectionEvent e) {
-                               shouldShowExperimentalFeatures = button_toggle.getSelection();
-                       }
-               });
-       }
-       
-       private Composite createComposite(Composite parent){
-               Composite composite = new Composite(parent, SWT.NULL);
-               composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
-               composite.setLayout(new RowLayout(SWT.HORIZONTAL));
-               return composite;
-       }
-       
-       /* (non-Javadoc)
-        * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
-        */
-       /** {@inheritDoc} */
+       @Override
        public void init(IWorkbench workbench) {
                setPreferenceStore(PreferencesUtil.getPreferenceStore());
        }
 
        public void init(IWorkbench workbench) {
                setPreferenceStore(PreferencesUtil.getPreferenceStore());
        }
 
-       /** {@inheritDoc} */
-       @Override
-       public boolean performOk() {            
-               
-               getPreferenceStore().setValue(IPreferenceKeys.SHOW_DEBUG_INFORMATION, showUuidInSupplementalView);
-               getPreferenceStore().setValue(IPreferenceKeys.EDIT_MAP_SERVICE_ACCES_POINT, editMapServiceAccessPoint);
-               getPreferenceStore().setValue(IPreferenceKeys.SHOULD_CONNECT_AT_STARTUP, shouldConnectAtStartup);
-               getPreferenceStore().setValue(IPreferenceKeys.SHOULD_EXPAND_SECTION_WHEN_DATA_AVAILABLE, shouldExpandSectionWhenDataAvailable);
-               getPreferenceStore().setValue(IPreferenceKeys.SHOW_EXPERIMENTAL_FEATURES, shouldShowExperimentalFeatures);
-                               
-               return super.performOk();
-       }
-       
 }
 }
index 3417e3704515f7e85c68e8dcb03e55c1a6d85c9f..b0492bf8453503fb106d28521f83a29f4fe8e181 100644 (file)
@@ -1,11 +1,11 @@
 /**
 /**
-* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy 
-* http://www.e-taxonomy.eu
-* 
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
+ * Copyright (C) 2007 EDIT
+ * European Distributed Institute of Taxonomy 
+ * http://www.e-taxonomy.eu
+ 
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * See LICENSE.TXT at the top of this package for the full license terms.
+ */
 
 package eu.etaxonomy.taxeditor.store;
 
 
 package eu.etaxonomy.taxeditor.store;
 
@@ -36,86 +36,94 @@ import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
 import eu.etaxonomy.taxeditor.view.datasource.CdmDataSourceViewPart;
 
 /**
 import eu.etaxonomy.taxeditor.view.datasource.CdmDataSourceViewPart;
 
 /**
- * This implementation of ICdmDataRepository depends on hibernate sessions to store the data correctly
- * for the current session. No state is held in this class.
- *
- * Only methods that either get or manipulate data are exposed here. So this class acts as a facade
- * for the methods in cdmlib-service.
- *
+ * This implementation of ICdmDataRepository depends on hibernate sessions to
+ * store the data correctly for the current session. No state is held in this
+ * class.
+ * 
+ * Only methods that either get or manipulate data are exposed here. So this
+ * class acts as a facade for the methods in cdmlib-service.
+ * 
  * @author n.hoffmann
  * @created 17.03.2009
  * @version 1.0
  */
  * @author n.hoffmann
  * @created 17.03.2009
  * @version 1.0
  */
-public class CdmStore{
-       
-       private static final Resource DEFAULT_APPLICATION_CONTEXT = new ClassPathResource("/eu/etaxonomy/cdm/editorApplicationContext.xml", TaxeditorStorePlugin.class);
+public class CdmStore {
+
+       private static final Resource DEFAULT_APPLICATION_CONTEXT = new ClassPathResource(
+                       "/eu/etaxonomy/cdm/editorApplicationContext.xml",
+                       TaxeditorStorePlugin.class);
        private static final DbSchemaValidation DEFAULT_DB_SCHEMA_VALIDATION = DbSchemaValidation.VALIDATE;
        private static final DbSchemaValidation DEFAULT_DB_SCHEMA_VALIDATION = DbSchemaValidation.VALIDATE;
-       
+
        private static CdmStore instance;
        private static CdmStore instance;
-               
-       private CdmApplicationController applicationController;
-
-       private static LoginManager loginManager;
-       
-       private static ImportManager importManager;
-       
-       private static ExportManager exportManager;
-       
-       private static ContextManager contextManager;
-       
+
+       private final CdmApplicationController applicationController;
+
+       private static LoginManager loginManager = new LoginManager();
+
+       private static ContextManager contextManager = new ContextManager();;
+
        private static TermManager termManager = new TermManager();
        private static TermManager termManager = new TermManager();
-       
-       private static SearchManager searchManager;
-       
-       private static EditorManager editorManager;
-       
+
+       private static SearchManager searchManager = new SearchManager();
+
+       private static EditorManager editorManager = new EditorManager();
+
        private static CdmStoreConnector job;
        private static CdmStoreConnector job;
-       
+
        private Language language;
        private Language language;
-       
+
        private ICdmDataSource cdmDatasource;
        private ICdmDataSource cdmDatasource;
-       
+
        private boolean isConnected;
        private boolean isConnected;
-       
+
        /**
        /**
-        * <p>getDefault</p>
-        *
+        * <p>
+        * getDefault
+        * </p>
+        * 
         * @return a {@link eu.etaxonomy.taxeditor.store.CdmStore} object.
         */
         * @return a {@link eu.etaxonomy.taxeditor.store.CdmStore} object.
         */
-       protected static CdmStore getDefault(){
-               if(instance != null && instance.isConnected){
+       protected static CdmStore getDefault() {
+               if (instance != null && instance.isConnected) {
                        return instance;
                        return instance;
-               }else if(instance == null || !instance.isConnected){
-                                               
-                       StoreUtil.warningDialog("Application is not connected to a datastore", instance, "The requested operation is only available when " +
-                                       "connected to a datasource. You may choose a datasource to connect to or create a new one in the datasource view.");
-                       
+               } else if (instance == null || !instance.isConnected) {
+
+                       StoreUtil
+                                       .warningDialog(
+                                                       "Application is not connected to a datastore",
+                                                       instance,
+                                                       "The requested operation is only available when "
+                                                                       + "connected to a datasource. You may choose a datasource to connect to or create a new one in the datasource view.");
+
                        StoreUtil.showView(CdmDataSourceViewPart.ID);
                        StoreUtil.showView(CdmDataSourceViewPart.ID);
-                       
-               }       
-               
+
+               }
+
                throw new RuntimeException();
        }
                throw new RuntimeException();
        }
-       
+
        /**
         * Initialize the with the last edited datasource
         */
        public static void connect() {
        /**
         * Initialize the with the last edited datasource
         */
        public static void connect() {
-               
-               ICdmDataSource datasource = CdmDataSourceRepository.getCurrentDataSource();
-               
+
+               ICdmDataSource datasource = CdmDataSourceRepository
+                               .getCurrentDataSource();
+
                connect(datasource);
        }
                connect(datasource);
        }
-       
+
        /**
         * Initialize with a specific datasource
        /**
         * Initialize with a specific datasource
-        *
-        * @param datasource a {@link eu.etaxonomy.cdm.database.ICdmDataSource} object.
+        * 
+        * @param datasource
+        *            a {@link eu.etaxonomy.cdm.database.ICdmDataSource} object.
         */
        public static void connect(ICdmDataSource datasource) {
         */
        public static void connect(ICdmDataSource datasource) {
-               connect(datasource, DEFAULT_DB_SCHEMA_VALIDATION, DEFAULT_APPLICATION_CONTEXT);
+               connect(datasource, DEFAULT_DB_SCHEMA_VALIDATION,
+                               DEFAULT_APPLICATION_CONTEXT);
        }
        }
-       
+
        /**
         * Initialize and provide
         * 
        /**
         * Initialize and provide
         * 
@@ -123,36 +131,42 @@ public class CdmStore{
         * @param dbSchemaValidation
         * @param applicationContextBean
         */
         * @param dbSchemaValidation
         * @param applicationContextBean
         */
-       private static void connect(final ICdmDataSource datasource, final DbSchemaValidation dbSchemaValidation, final Resource applicationContextBean){       
+       private static void connect(final ICdmDataSource datasource,
+                       final DbSchemaValidation dbSchemaValidation,
+                       final Resource applicationContextBean) {
                StoreUtil.info("Connecting to datasource: " + datasource);
                StoreUtil.info("Connecting to datasource: " + datasource);
-                       
-               job = new CdmStoreConnector(Display.getDefault(), datasource, dbSchemaValidation, applicationContextBean);
+
+               job = new CdmStoreConnector(Display.getDefault(), datasource,
+                               dbSchemaValidation, applicationContextBean);
                job.setUser(true);
                job.setPriority(Job.BUILD);
                job.schedule();
                job.setUser(true);
                job.setPriority(Job.BUILD);
                job.schedule();
-                       
+
        }
 
        }
 
-       public static boolean isConnecting(){
+       public static boolean isConnecting() {
                return job != null && job.getState() == Job.RUNNING;
        }
 
        /**
         * Closes the current application context
                return job != null && job.getState() == Job.RUNNING;
        }
 
        /**
         * Closes the current application context
-        *
-        * @param monitor a {@link org.eclipse.core.runtime.IProgressMonitor} object.
+        * 
+        * @param monitor
+        *            a {@link org.eclipse.core.runtime.IProgressMonitor} object.
         */
         */
-       public static void close(final IProgressMonitor monitor){
-               Display.getDefault().asyncExec(new Runnable(){
-                       /* (non-Javadoc)
+       public static void close(final IProgressMonitor monitor) {
+               Display.getDefault().asyncExec(new Runnable() {
+                       /*
+                        * (non-Javadoc)
+                        * 
                         * @see java.lang.Runnable#run()
                         */
                        @Override
                        public void run() {
                                getContextManager().notifyContextAboutToStop(monitor);
                         * @see java.lang.Runnable#run()
                         */
                        @Override
                        public void run() {
                                getContextManager().notifyContextAboutToStop(monitor);
-                               if((monitor == null || (!monitor.isCanceled()) && isActive())){
+                               if ((monitor == null || (!monitor.isCanceled()) && isActive())) {
                                        getContextManager().notifyContextStop(monitor);
                                        getContextManager().notifyContextStop(monitor);
-                                       if(instance.getApplicationController() != null){
+                                       if (instance.getApplicationController() != null) {
                                                instance.getApplicationController().close();
                                        }
                                        instance.close();
                                                instance.getApplicationController().close();
                                        }
                                        instance.close();
@@ -165,38 +179,44 @@ public class CdmStore{
                isConnected = false;
                cdmDatasource = null;
        }
                isConnected = false;
                cdmDatasource = null;
        }
-       
-       static void setInstance(CdmApplicationController applicationController, ICdmDataSource dataSource){
+
+       static void setInstance(CdmApplicationController applicationController,
+                       ICdmDataSource dataSource) {
                instance = new CdmStore(applicationController, dataSource);
        }
                instance = new CdmStore(applicationController, dataSource);
        }
-       
-       private CdmStore(CdmApplicationController applicationController, ICdmDataSource dataSource){
+
+       private CdmStore(CdmApplicationController applicationController,
+                       ICdmDataSource dataSource) {
                this.applicationController = applicationController;
                this.cdmDatasource = dataSource;
                isConnected = true;
        }
                this.applicationController = applicationController;
                this.cdmDatasource = dataSource;
                isConnected = true;
        }
-       
+
        /**
        /**
-        * All calls to the datastore require 
+        * All calls to the datastore require
         * 
         * @return
         */
         * 
         * @return
         */
-       private CdmApplicationController getApplicationController(){
-               try{
+       private CdmApplicationController getApplicationController() {
+               try {
                        return applicationController;
                        return applicationController;
-               }catch(Exception e){
+               } catch (Exception e) {
                        StoreUtil.error(CdmStore.class, e);
                }
                return null;
        }
                        StoreUtil.error(CdmStore.class, e);
                }
                return null;
        }
-       
+
        /**
        /**
-        * <p>getCurrentApplicationController</p>
-        *
-        * @return a {@link eu.etaxonomy.cdm.api.application.CdmApplicationController} object.
+        * <p>
+        * getCurrentApplicationController
+        * </p>
+        * 
+        * @return a
+        *         {@link eu.etaxonomy.cdm.api.application.CdmApplicationController}
+        *         object.
         */
         */
-       public static CdmApplicationController getCurrentApplicationController(){
-               if(getDefault() != null){
+       public static CdmApplicationController getCurrentApplicationController() {
+               if (getDefault() != null) {
                        return getDefault().getApplicationController();
                }
                return null;
                        return getDefault().getApplicationController();
                }
                return null;
@@ -207,39 +227,42 @@ public class CdmStore{
         */
 
        /**
         */
 
        /**
-        * Creates a new conversation, binds resources to the conversation and
-        * start a transaction for this conversation.
-        *
-        * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
+        * Creates a new conversation, binds resources to the conversation and start
+        * a transaction for this conversation.
+        * 
+        * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
+        *         object.
         */
        public static ConversationHolder createConversation() {
         */
        public static ConversationHolder createConversation() {
-               ConversationHolder conversation = getCurrentApplicationController().NewConversation();
-               
+               ConversationHolder conversation = getCurrentApplicationController()
+                               .NewConversation();
+
                conversation.startTransaction();
                return conversation;
        }
                conversation.startTransaction();
                return conversation;
        }
-       
+
        /**
        /**
-        * Generic method that will return an implementation of the given service interface
-        * or <code>null</code> if the 
+        * Generic method that will return an implementation of the given service
+        * interface or <code>null</code> if the
         * 
         * @param <T>
         * @param serviceClass
         * @return
         */
         * 
         * @param <T>
         * @param serviceClass
         * @return
         */
-       public static <T extends IService> T getService(Class<T> serviceClass){
-               ICdmApplicationConfiguration controller = getCurrentApplicationController();
-               
-               Method[] methods = ICdmApplicationConfiguration.class.getDeclaredMethods();
-               
+       public static <T extends IService> T getService(Class<T> serviceClass) {
+               ICdmApplicationConfiguration configuration = getCurrentApplicationController();
+
+               Method[] methods = ICdmApplicationConfiguration.class
+                               .getDeclaredMethods();
+
                T service = null;
                T service = null;
-               
-               for(Method method : methods){
+
+               for (Method method : methods) {
                        Type type = method.getGenericReturnType();
                        Type type = method.getGenericReturnType();
-                       
-                       if(type.equals(serviceClass)){
+
+                       if (type.equals(serviceClass)) {
                                try {
                                try {
-                                       service =  (T) method.invoke(controller, null);
+                                       service = (T) method.invoke(configuration, null);
                                        break;
                                } catch (IllegalArgumentException e) {
                                        StoreUtil.error(CdmStore.class, e);
                                        break;
                                } catch (IllegalArgumentException e) {
                                        StoreUtil.error(CdmStore.class, e);
@@ -250,51 +273,65 @@ public class CdmStore{
                                }
                        }
                }
                                }
                        }
                }
-               
+
                return service;
        }
                return service;
        }
-       
+
        /**
        /**
-        * <p>getAuthenticationManager</p>
-        *
-        * @return a {@link org.springframework.security.authentication.ProviderManager} object.
+        * <p>
+        * getAuthenticationManager
+        * </p>
+        * 
+        * @return a
+        *         {@link org.springframework.security.authentication.ProviderManager}
+        *         object.
         */
         */
-       public static ProviderManager getAuthenticationManager() { return getCurrentApplicationController().getAuthenticationManager();}
-       
+       public static ProviderManager getAuthenticationManager() {
+               return getCurrentApplicationController().getAuthenticationManager();
+       }
+
        /**
        /**
-        * <p>getGeoService</p>
-        *
+        * <p>
+        * getGeoService
+        * </p>
+        * 
         * @return a {@link eu.etaxonomy.cdm.ext.geo.IEditGeoService} object.
         */
         * @return a {@link eu.etaxonomy.cdm.ext.geo.IEditGeoService} object.
         */
-       public static IEditGeoService getGeoService(){
-               return (IEditGeoService) getCurrentApplicationController().getBean("editGeoService");
+       public static IEditGeoService getGeoService() {
+               return (IEditGeoService) getCurrentApplicationController().getBean(
+                               "editGeoService");
        }
        }
-       
+
        /*
         * LANGUAGE
         */
        /*
         * LANGUAGE
         */
-       
+
        /**
        /**
-        * <p>getDefaultLanguage</p>
-        *
+        * <p>
+        * getDefaultLanguage
+        * </p>
+        * 
         * @return a {@link eu.etaxonomy.cdm.model.common.Language} object.
         */
         * @return a {@link eu.etaxonomy.cdm.model.common.Language} object.
         */
-       public static Language getDefaultLanguage(){
-               if(getDefault().getLanguage() == null){
+       public static Language getDefaultLanguage() {
+               if (getDefault().getLanguage() == null) {
                        getDefault().setLanguage(PreferencesUtil.getGlobalLanguage());
                }
                return getDefault().getLanguage();
        }
 
        /**
                        getDefault().setLanguage(PreferencesUtil.getGlobalLanguage());
                }
                return getDefault().getLanguage();
        }
 
        /**
-        * <p>setDefaultLanguage</p>
-        *
-        * @param language a {@link eu.etaxonomy.cdm.model.common.Language} object.
+        * <p>
+        * setDefaultLanguage
+        * </p>
+        * 
+        * @param language
+        *            a {@link eu.etaxonomy.cdm.model.common.Language} object.
         */
         */
-       public static void setDefaultLanguage(Language language){
+       public static void setDefaultLanguage(Language language) {
                getDefault().setLanguage(language);
        }
                getDefault().setLanguage(language);
        }
-       
+
        /**
         * @return the language
         */
        /**
         * @return the language
         */
@@ -303,108 +340,100 @@ public class CdmStore{
        }
 
        /**
        }
 
        /**
-        * @param language the language to set
+        * @param language
+        *            the language to set
         */
        private void setLanguage(Language language) {
                this.language = language;
        }
         */
        private void setLanguage(Language language) {
                this.language = language;
        }
-       
+
        /*
         * LOGIN
         */
        /*
         * LOGIN
         */
-       
+
        /**
        /**
-        * <p>Getter for the field <code>loginManager</code>.</p>
-        *
+        * <p>
+        * Getter for the field <code>loginManager</code>.
+        * </p>
+        * 
         * @return a {@link eu.etaxonomy.taxeditor.store.LoginManager} object.
         */
         * @return a {@link eu.etaxonomy.taxeditor.store.LoginManager} object.
         */
-       public static LoginManager getLoginManager(){
-               if(loginManager == null){
-                       loginManager = new LoginManager();
-               }
+       public static LoginManager getLoginManager() {
                return loginManager;
        }
                return loginManager;
        }
-       
+
        /**
        /**
-        * <p>Getter for the field <code>contextManager</code>.</p>
-        *
+        * <p>
+        * Getter for the field <code>contextManager</code>.
+        * </p>
+        * 
         * @return a {@link eu.etaxonomy.taxeditor.store.ContextManager} object.
         */
         * @return a {@link eu.etaxonomy.taxeditor.store.ContextManager} object.
         */
-       public static ContextManager getContextManager(){
-               if(contextManager == null){
-                       contextManager = new ContextManager();
-               }
+       public static ContextManager getContextManager() {
                return contextManager;
        }
                return contextManager;
        }
-       
-       public static TermManager getTermManager(){
+
+       public static TermManager getTermManager() {
                return termManager;
        }
                return termManager;
        }
-       
-       public static SearchManager getSearchManager(){
-               if(searchManager == null){
-                       searchManager = new SearchManager();
-               }
+
+       public static SearchManager getSearchManager() {
                return searchManager;
        }
                return searchManager;
        }
-       
+
        public static EditorManager getEditorManager() {
        public static EditorManager getEditorManager() {
-               if(editorManager == null){
-                       editorManager = new EditorManager();
-               }
-               
                return editorManager;
        }
                return editorManager;
        }
-       
+
        /*
         * IMPORT/EXPORT FACTORIES
         */
        /*
         * IMPORT/EXPORT FACTORIES
         */
-       
+
        /**
        /**
-        * <p>Getter for the field <code>importHandler</code>.</p>
-        *
+        * <p>
+        * Getter for the field <code>importHandler</code>.
+        * </p>
+        * 
         * @return a {@link eu.etaxonomy.taxeditor.io.ImportManager} object.
         */
         * @return a {@link eu.etaxonomy.taxeditor.io.ImportManager} object.
         */
-       public static ImportManager getImportManager(){
-               if(importManager == null){
-                       importManager = ImportManager.NewInstance(getCurrentApplicationController());
-               }
-               return importManager;
+       public static ImportManager getImportManager() {
+               return ImportManager.NewInstance(getCurrentApplicationController());
        }
        }
-       
+
        /**
        /**
-        * <p>Getter for the field <code>exportHandler</code>.</p>
-        *
+        * <p>
+        * Getter for the field <code>exportHandler</code>.
+        * </p>
+        * 
         * @return a {@link eu.etaxonomy.taxeditor.io.ExportManager} object.
         */
         * @return a {@link eu.etaxonomy.taxeditor.io.ExportManager} object.
         */
-       public static ExportManager getExportManager(){
-               if(exportManager == null){
-                       exportManager = ExportManager.NewInstance(getCurrentApplicationController());
-               }
-               return exportManager;
+       public static ExportManager getExportManager() {
+               return ExportManager.NewInstance(getCurrentApplicationController());
        }
        }
-       
+
        /**
         * Whether this CdmStore is currently connected to a datasource
        /**
         * Whether this CdmStore is currently connected to a datasource
-        *
+        * 
         * @return a boolean.
         */
         * @return a boolean.
         */
-       public static boolean isActive(){
+       public static boolean isActive() {
                return instance != null && instance.isConnected;
        }
 
        /**
                return instance != null && instance.isConnected;
        }
 
        /**
-        * <p>getDataSource</p>
-        *
+        * <p>
+        * getDataSource
+        * </p>
+        * 
         * @return a {@link eu.etaxonomy.cdm.database.ICdmDataSource} object.
         */
         * @return a {@link eu.etaxonomy.cdm.database.ICdmDataSource} object.
         */
-       public static ICdmDataSource getDataSource(){
-               if(isActive()){
+       public static ICdmDataSource getDataSource() {
+               if (isActive()) {
                        return instance.getDatasource();
                }
                return null;
        }
                        return instance.getDatasource();
                }
                return null;
        }
-       
+
        /**
         * @return
         */
        /**
         * @return
         */