- applied coding conventions
authorPatric Plitzner <p.plitzner@bgbm.org>
Wed, 29 Oct 2014 10:38:11 +0000 (10:38 +0000)
committerPatric Plitzner <p.plitzner@bgbm.org>
Wed, 29 Oct 2014 10:38:11 +0000 (10:38 +0000)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/menu/AbstractMenuPreferences.java

index acf22fdb817f525016477f62757f37e0720a723f..c8a7fc5b2fd1cfe72070784482bc38c0b2756e31 100644 (file)
@@ -1,9 +1,9 @@
 // $Id$
 /**
  * Copyright (C) 2007 EDIT
- * European Distributed Institute of Taxonomy 
+ * 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.
  */
@@ -44,11 +44,11 @@ import eu.etaxonomy.cdm.model.common.DefinedTermBase;
 import eu.etaxonomy.cdm.model.common.TermType;
 import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
 import eu.etaxonomy.taxeditor.editor.definedterm.DefinedTermEditor;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 import eu.etaxonomy.taxeditor.preference.wizard.VocabularyTermWizard;
 import eu.etaxonomy.taxeditor.store.CdmStore;
-import eu.etaxonomy.taxeditor.store.StoreUtil;
 import eu.etaxonomy.taxeditor.store.TermStore;
 
 /**
@@ -63,17 +63,17 @@ public abstract class AbstractMenuPreferences<T extends DefinedTermBase> extends
 
        private Button toggleButton;
        protected HashMap<DefinedTermBase<T>, Button> menuButtons;
-       
+
        protected Button newButton;
        protected Button editButton;
        protected Button removeButton;
-               
+
        protected CheckboxTableViewer tableViewer;
-       
+
        private boolean state = true;
-       private boolean vocabularyIsEditable;
+       private final boolean vocabularyIsEditable;
        private ConversationHolder conversation;
-       
+
        /**
         * Constructs a new menu preference page.
         *
@@ -93,7 +93,7 @@ public abstract class AbstractMenuPreferences<T extends DefinedTermBase> extends
                vocabularyIsEditable = editable;
                setDescription(description);
        }
-       
+
        protected List<T> getTerms(){
                return TermStore.getTerms(getTermClass());
        }
@@ -105,38 +105,40 @@ public abstract class AbstractMenuPreferences<T extends DefinedTermBase> extends
         */
        @Override
        public Control createContents(Composite parent) {
-               
+
                Composite container = new Composite(parent, SWT.NULL);
                final GridLayout gridLayout = new GridLayout();
                gridLayout.numColumns = 2;
                container.setLayout(gridLayout);
-       
+
                tableViewer = CheckboxTableViewer.newCheckList(container, SWT.NULL);
                GridData tableLayoutData = new GridData(SWT.FILL, SWT.FILL, true, false);
                tableLayoutData.heightHint = 300;
                tableViewer.getTable().setLayoutData(tableLayoutData);
-               
+
                tableViewer.setContentProvider(new DefinedTermBaseContentProvider());
                tableViewer.setLabelProvider(new DefinedTermBaseLabelProvider());
 
                refresh(getTerms());
-               
+
                tableViewer.addCheckStateListener(new ICheckStateListener() {
-                       
+
                        @Override
                        public void checkStateChanged(CheckStateChangedEvent arg0) {
                                checkNoneChecked();
                        }
                });
-               
+
                Composite buttonContainer = new Composite(container, SWT.NULL);
                GridData buttonContainerLayoutData = new GridData();
                buttonContainerLayoutData.verticalAlignment = SWT.TOP;
                buttonContainer.setLayoutData(buttonContainerLayoutData);
                buttonContainer.setLayout(new GridLayout());
-               
-               if(vocabularyIsEditable) createEditButtons(buttonContainer);
-               
+
+               if(vocabularyIsEditable) {
+            createEditButtons(buttonContainer);
+        }
+
                toggleButton = new Button(buttonContainer, SWT.PUSH);
                toggleButton.setText("Toggle");
                toggleButton.addSelectionListener(new SelectionAdapter(){
@@ -150,9 +152,9 @@ public abstract class AbstractMenuPreferences<T extends DefinedTermBase> extends
                                checkNoneChecked();
                        }
                });
-               
+
                createAdditionalContent(container);
-               
+
                return container;
        }
 
@@ -175,7 +177,7 @@ public abstract class AbstractMenuPreferences<T extends DefinedTermBase> extends
         * @param container a {@link org.eclipse.swt.widgets.Composite} object.
         */
        protected void createAdditionalContent(Composite container) {
-               // implement where needed               
+               // implement where needed
        }
 
        /* (non-Javadoc)
@@ -206,18 +208,18 @@ public abstract class AbstractMenuPreferences<T extends DefinedTermBase> extends
                         */
                        @Override
                        public void widgetSelected(SelectionEvent e) {
-                               VocabularyTermWizard<T> wizard = new VocabularyTermWizard<T>(getTermClass(), getConversationHolder()); 
-                               
-                               WizardDialog dialog = new WizardDialog(StoreUtil.getShell(), wizard);
+                               VocabularyTermWizard<T> wizard = new VocabularyTermWizard<T>(getTermClass(), getConversationHolder());
+
+                               WizardDialog dialog = new WizardDialog(AbstractUtility.getShell(), wizard);
                            if(dialog.open() == IStatus.OK){
                                tableViewer.setInput(getTerms());
                            }
                        }
 
-                       
+
                });
        }
-       
+
        /**
         * Implement this method in MenuPreference Pages where the vocabulary should be editable, editable flag
         * is set.
@@ -229,23 +231,23 @@ public abstract class AbstractMenuPreferences<T extends DefinedTermBase> extends
                         */
                        @Override
                        public void widgetSelected(SelectionEvent event) {
-                               
-                               ICommandService commandService = (ICommandService)  StoreUtil.getService(ICommandService.class);
+
+                               ICommandService commandService = (ICommandService)  AbstractUtility.getService(ICommandService.class);
 
                                Command command = commandService.getCommand(DefinedTermEditor.OPEN_COMMAND_ID);
-                               
+
                                IParameter parameter;
                                try {
                                        parameter = command.getParameter("eu.etaxonomy.taxeditor.store.openDefinedTermEditor.termTypeUuid");
-                               
+
                                        Parameterization[] parameterizations = new Parameterization[]{
                                                        new Parameterization(parameter, TermType.valueOf(getTermClass().getSimpleName()).getUuid().toString())
                                        };
-                                       
+
                                        ParameterizedCommand pCommand = new ParameterizedCommand(command, parameterizations);
-                                       
+
                                        if (command.isEnabled()) {
-                                               IHandlerService handlerService = (IHandlerService) StoreUtil.getService(IHandlerService.class);
+                                               IHandlerService handlerService = (IHandlerService) AbstractUtility.getService(IHandlerService.class);
                                                try {
                                                        handlerService.executeCommand(pCommand, null);
                                                } catch (NotDefinedException e) {
@@ -264,13 +266,14 @@ public abstract class AbstractMenuPreferences<T extends DefinedTermBase> extends
                                                        "An exception occured while trying to open the Term Editor",
                                                        e);
                                }
-                               
+
                        }
                });
        }
 
        /** {@inheritDoc} */
-       public void init(IWorkbench workbench) {
+       @Override
+    public void init(IWorkbench workbench) {
                setPreferenceStore(PreferencesUtil.getPreferenceStore());
                getConversationHolder().bind();
        }
@@ -282,7 +285,8 @@ public abstract class AbstractMenuPreferences<T extends DefinedTermBase> extends
        /**
         * <p>performDefaults</p>
         */
-       protected void performDefaults() {
+       @Override
+    protected void performDefaults() {
                tableViewer.setAllChecked(true);
        }
 
@@ -304,23 +308,23 @@ public abstract class AbstractMenuPreferences<T extends DefinedTermBase> extends
                if(checkNoneChecked()){
                        return false;
                }
-               
+
                getConversationHolder().commit(true);
-               
+
                List<T> preferredTerms = new ArrayList<T>();
                for (Object element : getTableViewer().getCheckedElements()){
                        preferredTerms.add((T) element);
                }
-               
+
                CdmStore.getTermManager().setPreferredTerms(preferredTerms, getTerms());
-               
+
                PreferencesUtil.firePreferencesChanged(this.getClass());
-               
+
                return true;
        }
-       
+
        private boolean checkNoneChecked(){
-               
+
                if(tableViewer.getCheckedElements().length == 0){
                        setMessage("Please check at least one item", WARNING);
                        return true;
@@ -329,14 +333,14 @@ public abstract class AbstractMenuPreferences<T extends DefinedTermBase> extends
                        return false;
                }
        }
-       
+
        /**
         * <p>getTermClass</p>
         *
         * @return a {@link java.lang.Class} object.
         */
        protected abstract Class<T> getTermClass();
-       
+
        /* (non-Javadoc)
         * @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
         */
@@ -347,7 +351,7 @@ public abstract class AbstractMenuPreferences<T extends DefinedTermBase> extends
                }
                return conversation;
        }
-       
+
        /* (non-Javadoc)
         * @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
         */