- simplified code for opening editor in TaxonNavigator
authorPatric Plitzner <p.plitzner@bgbm.org>
Fri, 7 Jun 2013 08:17:03 +0000 (08:17 +0000)
committerPatric Plitzner <p.plitzner@bgbm.org>
Fri, 7 Jun 2013 08:17:03 +0000 (08:17 +0000)
 - used IPartContentHasXYZ interfaces for selectionChanged() in Supplemental- and DetailsViewPart

 - formatted code
 - fixed warnings

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/MultiPageTaxonEditor.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/UsesViewPart.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/AbstractCdmEditorViewPart.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/AbstractCdmViewPart.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewPart.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/supplementaldata/SupplementalDataViewPart.java

index 669c354dc6d268f6a44b04402f8d47f805c64af5..207b5d2f031da8a784189d35170f4b1e942ba22c 100644 (file)
@@ -1,8 +1,8 @@
 /**
  * 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.
  */
@@ -32,6 +32,7 @@ import eu.etaxonomy.cdm.model.taxon.TaxonBase;
 import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
 import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
 import eu.etaxonomy.taxeditor.editor.name.container.AbstractGroupedContainer;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.model.DataChangeBridge;
 import eu.etaxonomy.taxeditor.model.IDataChangeBehavior;
 import eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider;
@@ -39,10 +40,10 @@ import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
 
 /**
- * 
+ *
  * Generates the tabbed editor with <code>TaxonNameEditor</code> on top and tabs
  * for "Descriptions", "Concepts", "Geography", etc.
- * 
+ *
  * @author p.ciardelli
  * @author n.hoffmann
  * @created 15.05.2008
@@ -83,7 +84,7 @@ public class MultiPageTaxonEditor extends FormEditor implements
 
        /*
         * (non-Javadoc)
-        * 
+        *
         * @see org.eclipse.ui.forms.editor.FormEditor#addPages()
         */
        /** {@inheritDoc} */
@@ -107,7 +108,7 @@ public class MultiPageTaxonEditor extends FormEditor implements
                        // EditorUtil.showPropertySheet();
 
                } catch (PartInitException e) {
-                       EditorUtil.error(getClass(), e);
+                       AbstractUtility.error(getClass(), e);
                }
        }
 
@@ -121,41 +122,34 @@ public class MultiPageTaxonEditor extends FormEditor implements
                        }
                        monitor.worked(1);
 
-                       for (IEditorPart editorPage : getPages()) {
-                               if (editorPage instanceof TaxonNameEditor) {
-                                       if (((TaxonNameEditor) editorPage).checkForEmptyNames()) {
-                                               MessageDialog
-                                                               .openWarning(
-                                                                               EditorUtil.getShell(),
-                                                                               "No Name Specified",
-                                                                               "An attempt was made to save a taxon or synonym with "
-                                                                                               + "an empty name. Operation was cancelled.");
-                                               return;
-                                       }
-                               }
-
-                               editorPage.doSave(monitor);
-                               monitor.worked(1);
-                       }
+            for (IEditorPart editorPage : getPages()) {
+                if (editorPage instanceof TaxonNameEditor) {
+                    if (((TaxonNameEditor) editorPage).checkForEmptyNames()) {
+                        MessageDialog.openWarning(AbstractUtility.getShell(), "No Name Specified",
+                                "An attempt was made to save a taxon or synonym with "
+                                        + "an empty name. Operation was cancelled.");
+                        return;
+                    }
+                }
+
+                editorPage.doSave(monitor);
+                monitor.worked(1);
+            }
 
                        // commit the conversation and start a new transaction immediately
                        conversation.commit(true);
                        monitor.worked(1);
 
-                       this.setDirty(false);
-                       monitor.worked(1);
-               } catch (Exception e) {
-                       setFocus();
-                       EditorUtil
-                                       .errorDialog(
-                                                       "An error occurred while saving",
-                                                       getClass(),
-                                                       "An error occurred while saving the editor. Please close and reopen the taxon again.",
-                                                       e);
-                       disableEditor(true);
-               } finally {
-                       monitor.done();
-               }
+            this.setDirty(false);
+            monitor.worked(1);
+        } catch (Exception e) {
+            setFocus();
+            AbstractUtility.errorDialog("An error occurred while saving", getClass(),
+                    "An error occurred while saving the editor. Please close and reopen the taxon again.", e);
+            disableEditor(true);
+        } finally {
+            monitor.done();
+        }
        }
 
        private void disableEditor(boolean isOnError) {
@@ -163,7 +157,7 @@ public class MultiPageTaxonEditor extends FormEditor implements
                        if(isOnError){
                                editorPage.setOnError();
                        }else {
-                               editorPage.setDisabled();                               
+                               editorPage.setDisabled();
                        }
                }
                conversation.unregisterForDataStoreChanges(this);
@@ -178,23 +172,24 @@ public class MultiPageTaxonEditor extends FormEditor implements
 
        /*
         * (non-Javadoc)
-        * 
+        *
         * @see org.eclipse.ui.part.MultiPageEditorPart#isDirty()
         */
        /**
         * <p>
         * isDirty
         * </p>
-        * 
+        *
         * @return a boolean.
         */
-       public boolean isDirty() {
+       @Override
+    public boolean isDirty() {
                return dirty;
        }
 
        /*
         * (non-Javadoc)
-        * 
+        *
         * @see org.eclipse.ui.forms.editor.FormEditor#editorDirtyStateChanged()
         */
        /** {@inheritDoc} */
@@ -206,7 +201,7 @@ public class MultiPageTaxonEditor extends FormEditor implements
 
        /**
         * {@inheritDoc}
-        * 
+        *
         * Checks whether nested editors are calling
         * <code>firePropertyChange(PROP_DIRTY)</code> to signal an edit has taken
         * place before passing property change along to
@@ -214,10 +209,11 @@ public class MultiPageTaxonEditor extends FormEditor implements
         */
        /*
         * (non-Javadoc)
-        * 
+        *
         * @see org.eclipse.ui.part.MultiPageEditorPart#handlePropertyChange(int)
         */
-       protected void handlePropertyChange(int propertyId) {
+       @Override
+    protected void handlePropertyChange(int propertyId) {
                if (propertyId == PROP_DIRTY) {
                        setDirty(true);
                }
@@ -240,9 +236,10 @@ public class MultiPageTaxonEditor extends FormEditor implements
        public void init(IEditorSite site, IEditorInput input)
                        throws PartInitException {
 
-               if (!(input instanceof TaxonEditorInput))
-                       throw new PartInitException(
+               if (!(input instanceof TaxonEditorInput)) {
+            throw new PartInitException(
                                        "Invalid Input: Must be TaxonEditorInput");
+        }
 
                this.input = (TaxonEditorInput) input;
 
@@ -289,29 +286,29 @@ public class MultiPageTaxonEditor extends FormEditor implements
                setPartName(partName);
        }
 
-       /**
-        * {@inheritDoc}
-        * 
-        * Editor pages call this in their postOperation to notify the
-        * MultiPageTaxonEditor of unsaved changes
-        */
-       public void changed(Object element) {
-               // setDirty(true);
-               dirty = true;
-               super.editorDirtyStateChanged();
-               if (element instanceof TaxonBase) {
-                       TaxonNameEditor page = (TaxonNameEditor) getPage(Page.NAME);
-                       AbstractGroupedContainer container = page
-                                       .getContainer((TaxonBase) element);
-                       if (container != null) {
-                               container.refresh();
-                       }
-               }
-       }
+    /**
+     * {@inheritDoc}
+     *
+     * Editor pages call this in their postOperation to notify the
+     * MultiPageTaxonEditor of unsaved changes
+     */
+    @Override
+    public void changed(Object element) {
+        // setDirty(true);
+        dirty = true;
+        super.editorDirtyStateChanged();
+        if (element instanceof TaxonBase) {
+            TaxonNameEditor page = (TaxonNameEditor) getPage(Page.NAME);
+            AbstractGroupedContainer container = page.getContainer((TaxonBase) element);
+            if (container != null) {
+                container.refresh();
+            }
+        }
+    }
 
        /**
         * The accepted taxon that is the input for this editor
-        * 
+        *
         * @return the accepted taxon
         */
        public Taxon getTaxon() {
@@ -320,7 +317,7 @@ public class MultiPageTaxonEditor extends FormEditor implements
 
        /*
         * (non-Javadoc)
-        * 
+        *
         * @see
         * eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder
         * ()
@@ -329,11 +326,12 @@ public class MultiPageTaxonEditor extends FormEditor implements
         * <p>
         * getConversationHolder
         * </p>
-        * 
+        *
         * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
         *         object.
         */
-       public ConversationHolder getConversationHolder() {
+       @Override
+    public ConversationHolder getConversationHolder() {
                return conversation;
        }
 
@@ -341,7 +339,7 @@ public class MultiPageTaxonEditor extends FormEditor implements
         * <p>
         * setConversationHolder
         * </p>
-        * 
+        *
         * @param conversation
         *            a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
         *            object.
@@ -354,7 +352,7 @@ public class MultiPageTaxonEditor extends FormEditor implements
         * <p>
         * Getter for the field <code>undoContext</code>.
         * </p>
-        * 
+        *
         * @return a {@link org.eclipse.core.commands.operations.IUndoContext}
         *         object.
         */
@@ -366,7 +364,7 @@ public class MultiPageTaxonEditor extends FormEditor implements
         * <p>
         * Setter for the field <code>undoContext</code>.
         * </p>
-        * 
+        *
         * @param undoContext
         *            a {@link org.eclipse.core.commands.operations.IUndoContext}
         *            object.
@@ -385,53 +383,50 @@ public class MultiPageTaxonEditor extends FormEditor implements
                getActiveEditor().setFocus();
        }
 
-       /*
-        * (non-Javadoc)
-        * 
-        * @see
-        * eu.etaxonomy.cdm.persistence.hibernate.ICdmPostCrudObserver#update(eu
-        * .etaxonomy.cdm.persistence.hibernate.CdmCrudEvent)
-        */
-       /** {@inheritDoc} */
-       public void update(CdmDataChangeMap events) {
-               if (dataChangeBehavior == null) {
-                       dataChangeBehavior = new MultiPageTaxonEditorDataChangeBehaviour(
-                                       this);
-               }
-
-               DataChangeBridge.handleDataChange(events, dataChangeBehavior);
-       }
-
-       /*
-        * (non-Javadoc)
-        * 
-        * @see
-        * eu.etaxonomy.taxeditor.store.operations.IPostOperationEnabled#postOperation
-        * ()
-        */
-       /** {@inheritDoc} */
-       public boolean postOperation(CdmBase objectAffectedByOperation) {
-               setDirty(true);
-
-               for (IEditorPart editor : this.getPages()) {
-                       if (editor instanceof IPostOperationEnabled) {
-                               ((IPostOperationEnabled) editor)
-                                               .postOperation(objectAffectedByOperation);
-                       } else {
-                               EditorUtil.warn(getClass(),
-                                               "postOperation not enabled for editor " + editor);
-                       }
-               }
-               EditorUtil
-                               .warn(getClass(),
-                                               "postOperation called on MultiPageTaxonEditor. Can you make it more specific?");
-
-               return false;
-       }
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * eu.etaxonomy.cdm.persistence.hibernate.ICdmPostCrudObserver#update(eu
+     * .etaxonomy.cdm.persistence.hibernate.CdmCrudEvent)
+     */
+    /** {@inheritDoc} */
+    @Override
+    public void update(CdmDataChangeMap events) {
+        if (dataChangeBehavior == null) {
+            dataChangeBehavior = new MultiPageTaxonEditorDataChangeBehaviour(this);
+        }
+
+        DataChangeBridge.handleDataChange(events, dataChangeBehavior);
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * eu.etaxonomy.taxeditor.store.operations.IPostOperationEnabled#postOperation
+     * ()
+     */
+    /** {@inheritDoc} */
+    @Override
+    public boolean postOperation(CdmBase objectAffectedByOperation) {
+        setDirty(true);
+
+        for (IEditorPart editor : this.getPages()) {
+            if (editor instanceof IPostOperationEnabled) {
+                ((IPostOperationEnabled) editor).postOperation(objectAffectedByOperation);
+            } else {
+                AbstractUtility.warn(getClass(), "postOperation not enabled for editor " + editor);
+            }
+        }
+        AbstractUtility.warn(getClass(), "postOperation called on MultiPageTaxonEditor. Can you make it more specific?");
+
+        return false;
+    }
 
        /**
         * Returns an <code>IEditorPart</code> implementation by type
-        * 
+        *
         * @param page
         *            the page type
         * @return a {@link eu.etaxonomy.taxeditor.editor.IMultiPageTaxonEditorPage}
@@ -449,7 +444,7 @@ public class MultiPageTaxonEditor extends FormEditor implements
        /**
         * Return a list of <code>AbstractTaxonEditor</code>s registered with this
         * <code>MultiPageTaxonEditor</code>.
-        * 
+        *
         * @return a {@link java.util.List} object.
         */
        public List<IMultiPageTaxonEditorPage> getPages() {
@@ -463,7 +458,7 @@ public class MultiPageTaxonEditor extends FormEditor implements
 
        /**
         * Refreshes a certain page of the MultipageTaxonEditor
-        * 
+        *
         * @param page
         *            a {@link eu.etaxonomy.taxeditor.editor.Page} object.
         * @return a boolean.
@@ -475,7 +470,7 @@ public class MultiPageTaxonEditor extends FormEditor implements
        /**
         * Refreshes a certain page of the MultipageTaxonEditor and sets focus to
         * that page
-        * 
+        *
         * @param page
         *            a {@link eu.etaxonomy.taxeditor.editor.Page} object.
         * @param focus
@@ -491,46 +486,42 @@ public class MultiPageTaxonEditor extends FormEditor implements
         * <p>
         * onComplete
         * </p>
-        * 
+        *
         * @return a boolean.
         */
-       public boolean onComplete() {
+       @Override
+    public boolean onComplete() {
                return false;
        }
 
-       /**
-        * Reloads the data for this
-        */
-       public void reload() {
-               if (isDirty()) {
-                       EditorUtil
-                                       .warningDialog(
-                                                       "Editor has unsaved data",
-                                                       getClass(),
-                                                       "This editor can not be "
-                                                                       + "refreshed because it contains unsaved data. Refreshing "
-                                                                       + "this editor would discard the changes. Please save this editor, "
-                                                                       + "close and reopen it manually in order to get the latest content");
-               } else {
-                       TaxonEditorInput input = (TaxonEditorInput) getEditorInput();
-
-                       UUID uuid = input.getTaxonNode().getUuid();
-
-                       conversation.clear();
-
-                       try {
-                               TaxonEditorInput newInput = TaxonEditorInput.NewInstance(uuid);
-                               setInput(newInput);
-                               for (IMultiPageTaxonEditorPage editorPart : getPages()) {
-                                       editorPart.redraw();
-                               }
-                       } catch (Exception e) {
-                               EditorUtil.errorDialog("Error refreshing editor", getClass(),
-                                               "Could not refresh this editor", e);
-                       }
-               }
-       }
-       
+    /**
+     * Reloads the data for this
+     */
+    public void reload() {
+        if (isDirty()) {
+            AbstractUtility.warningDialog("Editor has unsaved data", getClass(), "This editor can not be "
+                    + "refreshed because it contains unsaved data. Refreshing "
+                    + "this editor would discard the changes. Please save this editor, "
+                    + "close and reopen it manually in order to get the latest content");
+        } else {
+            TaxonEditorInput input = (TaxonEditorInput) getEditorInput();
+
+            UUID uuid = input.getTaxonNode().getUuid();
+
+            conversation.clear();
+
+            try {
+                TaxonEditorInput newInput = TaxonEditorInput.NewInstance(uuid);
+                setInput(newInput);
+                for (IMultiPageTaxonEditorPage editorPart : getPages()) {
+                    editorPart.redraw();
+                }
+            } catch (Exception e) {
+                AbstractUtility.errorDialog("Error refreshing editor", getClass(), "Could not refresh this editor", e);
+            }
+        }
+    }
+
        @Override
        public String toString() {
                return String.format("%s[%s]", this.getClass().getSimpleName(), getEditorInput());
index 16fa9b076ea3bc843909a9bc6a3dad2a863bf0e2..403a6b25c51b5d1b156a5d3df6d5570e1d22bf8d 100644 (file)
@@ -1,8 +1,8 @@
 /**\r
  * Copyright (C) 2011 EDIT\r
- * European Distributed Institute of Taxonomy \r
+ * European Distributed Institute of Taxonomy\r
  * http://www.e-taxonomy.eu\r
- * \r
+ *\r
  * The contents of this file are subject to the Mozilla Public License Version 1.1\r
  * See LICENSE.TXT at the top of this package for the full license terms.\r
  */\r
@@ -19,58 +19,56 @@ import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementDragList
 import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementDropAdapter;\r
 import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementTransfer;\r
 import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewPart;\r
-import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;\r
-import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;\r
 \r
 \r
 /**\r
- * The Class create a speific Use View to keep the taxonomic view clean\r
- * @author a.theys     \r
+ * The Class create a specific Use View to keep the taxonomic view clean\r
+ * @author a.theys\r
  * @created mar 13, 2012\r
  * @version 1.0\r
  */\r
-public class UsesViewPart extends DescriptiveViewPart implements IPartContentHasDetails, IPartContentHasSupplementalData {\r
+public class UsesViewPart extends DescriptiveViewPart {\r
 \r
        /** Constant <code>ID="eu.etaxonomy.taxeditor.editor.view.uses"</code> */\r
        public static final String ID = "eu.etaxonomy.taxeditor.editor.view.uses";\r
        /** {@inheritDoc} */\r
        @Override\r
        public void createViewer(Composite parent) {\r
-               \r
+\r
                viewer = new TreeViewer(new Tree(parent, SWT.MULTI | SWT.H_SCROLL\r
                                | SWT.V_SCROLL | SWT.FULL_SELECTION));\r
                viewer.setContentProvider(new UsesContentProvider(featureNodeContainerCache));\r
                viewer.setLabelProvider(new UsesLabelProvider());\r
                viewer.setAutoExpandLevel(2);\r
-               \r
-               \r
-               \r
+\r
+\r
+\r
                Transfer[] transfers = new Transfer[] { DescriptionElementTransfer.getInstance() };\r
                viewer.addDragSupport(dndOperations, transfers, new DescriptionElementDragListener(\r
                                this));\r
                viewer.addDropSupport(dndOperations, transfers,\r
                                new DescriptionElementDropAdapter(viewer));\r
-                                               \r
+\r
                // Propagate selection from viewer\r
                getSite().setSelectionProvider(viewer);\r
-               \r
-               showAllElementsAction = new ToggleDescriptionAction(false);             \r
+\r
+               showAllElementsAction = new ToggleDescriptionAction(false);\r
                hideAllElementsAction = new ToggleDescriptionAction(true);\r
-               \r
+\r
                // Add context menu to tree\r
                createMenu();\r
-               \r
+\r
                createToolbar();\r
 \r
        }\r
-       \r
+\r
        /** {@inheritDoc} */\r
        @Override\r
        public boolean postOperation(CdmBase objectAffectedByOperation) {\r
                viewer.refresh();\r
                return super.postOperation(objectAffectedByOperation);\r
        }\r
-       \r
+\r
 \r
 \r
 }\r
index 1c4c3e82d5ee8a3ff17fac5811f5d7f846a89421..8d1f9ad9d6bd7cb678f7b18bfbb77491f5f1d8ad 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * 
+ *
  */
 package eu.etaxonomy.taxeditor.view;
 
@@ -7,14 +7,14 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.ui.IEditorPart;
 
 import eu.etaxonomy.taxeditor.editor.ISecuredEditor;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider;
-import eu.etaxonomy.taxeditor.store.StoreUtil;
 
 /**
  * <p>
  * Abstract AbstractCdmEditorViewPart class.
  * </p>
- * 
+ *
  * @author n.hoffmann
  * @created Sep 21, 2010
  * @version 1.0
@@ -23,7 +23,7 @@ public abstract class AbstractCdmEditorViewPart extends AbstractCdmViewPart {
 
        /*
         * (non-Javadoc)
-        * 
+        *
         * @see
         * eu.etaxonomy.taxeditor.model.AbstractCdmViewPart#createPartControl(org
         * .eclipse.swt.widgets.Composite)
@@ -31,47 +31,42 @@ public abstract class AbstractCdmEditorViewPart extends AbstractCdmViewPart {
        /** {@inheritDoc} */
        @Override
        public void createPartControl(Composite parent) {
-
                super.createPartControl(parent);
-
        }
 
        /**
         * <p>
         * getEditor
         * </p>
-        * 
+        *
         * @return the currently active editor
         */
        public IEditorPart getEditor() {
-               return StoreUtil.getActiveEditor();
+               return AbstractUtility.getActiveEditor();
        }
-       
+
        /** {@inheritDoc} */
        @Override
        public void setFocus() {
                super.setFocus();
-               
-               if(getEditor() != null && ISecuredEditor.class.isAssignableFrom(getEditor().getClass())){       
+
+               if(getEditor() != null && ISecuredEditor.class.isAssignableFrom(getEditor().getClass())){
                        boolean doEnable = ((ISecuredEditor)getEditor()).permissionsSatisfied();
                        setEnabled(doEnable);
                }
-       }
+    }
 
-       /** {@inheritDoc} */
-       @Override
-       public void changed(Object object) {
-               if (part instanceof AbstractCdmViewPart) {
-                       ((AbstractCdmViewPart) part).changed(object);
-               } else {
-                       IEditorPart editor = getEditor();
-                       if (editor != null
-                                       && editor instanceof IDirtyMarkableSelectionProvider) {
-
-                               ((IDirtyMarkableSelectionProvider) editor).changed(object);
-
-                       }
-               }
-       }
+    /** {@inheritDoc} */
+    @Override
+    public void changed(Object object) {
+        if (part instanceof AbstractCdmViewPart) {
+            ((AbstractCdmViewPart) part).changed(object);
+        } else {
+            IEditorPart editor = getEditor();
+            if (editor != null && editor instanceof IDirtyMarkableSelectionProvider) {
+                ((IDirtyMarkableSelectionProvider) editor).changed(object);
+            }
+        }
+    }
 
 }
index bca55078a7771c5b282142a037beb5c2c2dcbb45..88d8449c484889e012acab9d0e91fad63b626ec1 100644 (file)
@@ -28,9 +28,9 @@ import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
 import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
 import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider;
 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
-import eu.etaxonomy.taxeditor.store.StoreUtil;
 
 /**
  * <p>Abstract AbstractCdmViewPart class.</p>
@@ -73,7 +73,7 @@ public abstract class AbstractCdmViewPart extends ViewPart implements ISelection
         *
         */
        private void setInitialSelection() {
-               selectionChanged(StoreUtil.getActivePart(), getInitialSelection());
+               selectionChanged(AbstractUtility.getActivePart(), getInitialSelection());
        }
 
        /**
index cc9ea6f48951d0595e0a595f305332c902c7e9a1..3ef1c37e74a072ade9db70f3bf3b9c85b23ef333 100644 (file)
@@ -19,11 +19,11 @@ import org.eclipse.ui.IWorkbenchPart;
 
 import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.description.Feature;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
+import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
 import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
-import eu.etaxonomy.taxeditor.store.StoreUtil;
 import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;
-import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart;
 
 /**
  * <p>DetailsViewPart class.</p>
@@ -51,7 +51,7 @@ public class DetailsViewPart extends AbstractCdmEditorViewPart implements IPartC
        /** {@inheritDoc} */
        @Override
     public void selectionChanged(IWorkbenchPart part, ISelection selection) {
-               if(StoreUtil.getActiveEditor() == null){
+               if(AbstractUtility.getActiveEditor() == null){
                        showEmptyPage();
                        return;
                }
@@ -66,7 +66,7 @@ public class DetailsViewPart extends AbstractCdmEditorViewPart implements IPartC
 
                IStructuredSelection structuredSelection = (IStructuredSelection) selection;
 
-               if((part instanceof IEditorPart) || (part instanceof AbstractCdmViewPart)) {
+               if((part instanceof IEditorPart) || (part instanceof IPartContentHasDetails)) {
                        if(structuredSelection.size() != 1){
                                showEmptyPage();
                                return;
index 28ad2a86ccae86972e3b8c010b76d25c8c00c8a3..18e07cb06259da04554adc530ee428a345be4ce0 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.
 */
@@ -20,11 +20,10 @@ import org.eclipse.ui.part.EditorPart;
 
 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
 import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
-import eu.etaxonomy.taxeditor.store.StoreUtil;
+import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
 import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;
-import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart;
-import eu.etaxonomy.taxeditor.view.detail.CdmSectionPart;
 
 
 /**
@@ -40,7 +39,7 @@ public class SupplementalDataViewPart extends AbstractCdmEditorViewPart {
        public static final String ID = "eu.etaxonomy.taxeditor.view.supplementalData";
 
        private SupplementalDataViewer viewer;
-       
+
        /* (non-Javadoc)
         * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
         */
@@ -52,36 +51,42 @@ public class SupplementalDataViewPart extends AbstractCdmEditorViewPart {
 
 
        /** {@inheritDoc} */
-       public void selectionChanged(IWorkbenchPart part, ISelection selection) {
-               if(StoreUtil.getActiveEditor() == null){
+       @Override
+    public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+               if(AbstractUtility.getActiveEditor() == null){
                        showEmptyPage();
                        return;
                }
-               
-               if(((part instanceof EditorPart) || (part instanceof AbstractCdmViewPart)) && selection instanceof IStructuredSelection) {
-                       IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+
+        if(!(selection instanceof IStructuredSelection)){
+            return;
+        }
+
+        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+
+               if((part instanceof EditorPart || part instanceof IPartContentHasSupplementalData)) {
                        if(structuredSelection.size() != 1){
                                showEmptyPage();
                                return;
                        }
-                       
+
                        // do not show supplemental data for feature nodes
                        if(structuredSelection.getFirstElement() instanceof FeatureNodeContainer){
                                showEmptyPage();
                                return;
                        }
-                       if(structuredSelection.getFirstElement() instanceof DerivedUnitFacade){
+                       else if(structuredSelection.getFirstElement() instanceof DerivedUnitFacade){
                                return;
                        }
-                       if(structuredSelection.getFirstElement() instanceof PolytomousKeyNode){
+                       else if(structuredSelection.getFirstElement() instanceof PolytomousKeyNode){
                            structuredSelection = new StructuredSelection(((PolytomousKeyNode)structuredSelection.getFirstElement()).getKey());
             }
                        showViewer(part, structuredSelection);
                }else{
-                       showEmptyPage();                
+                       showEmptyPage();
                }
        }
-       
+
        /** {@inheritDoc} */
        @Override
        public void dispose() {
@@ -101,10 +106,11 @@ public class SupplementalDataViewPart extends AbstractCdmEditorViewPart {
         *
         * @return a boolean.
         */
-       public boolean onComplete() {
+       @Override
+    public boolean onComplete() {
                // TODO Auto-generated method stub
                return false;
        }
-       
-       
+
+
 }