Use wizard to create new specimen
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / MultiPageTaxonEditor.java
index a55a03de33824865111ca34a73e4c317c899628a..74e264dc5ec66cf1fb4a4b8ac7ed7e2c1dcb6cc8 100644 (file)
@@ -30,14 +30,16 @@ import eu.etaxonomy.cdm.model.name.TaxonNameBase;
 import eu.etaxonomy.cdm.model.taxon.Taxon;
 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
 import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
+import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin;
 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;
+import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
 import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
 import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData;
+import eu.etaxonomy.taxeditor.model.IPartContentHasMedia;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
 
@@ -53,7 +55,7 @@ import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
  */
 public class MultiPageTaxonEditor extends FormEditor implements
         IPartContentHasFactualData, IConversationEnabled, IPostOperationEnabled,
-               IDirtyMarkableSelectionProvider, IPartContentHasDetails, ISecuredEditor {
+               IDirtyMarkable, IPartContentHasDetails, ISecuredEditor, IPartContentHasMedia {
 
        /** Constant <code>ID="eu.etaxonomy.taxeditor.editor.taxon"{trunked}</code> */
        public static final String ID = "eu.etaxonomy.taxeditor.editor.taxon";
@@ -84,11 +86,6 @@ public class MultiPageTaxonEditor extends FormEditor implements
                super.dispose();
        }
 
-       /*
-        * (non-Javadoc)
-        *
-        * @see org.eclipse.ui.forms.editor.FormEditor#addPages()
-        */
        /** {@inheritDoc} */
        @Override
        protected void addPages() {
@@ -143,10 +140,10 @@ public class MultiPageTaxonEditor extends FormEditor implements
                        monitor.worked(1);
 
             this.setDirty(false);
-            monitor.worked(1);            
+            monitor.worked(1);
         } catch (Exception e) {
             setFocus();
-            MessagingUtils.operationDialog(this, e, "saving a taxon", " Please close and reopen the taxon again.");
+            MessagingUtils.operationDialog(this, e, TaxeditorEditorPlugin.PLUGIN_ID,"saving a taxon", " Please close and reopen the taxon again.");
             disableEditor(true);
         } finally {
             monitor.done();
@@ -171,28 +168,11 @@ public class MultiPageTaxonEditor extends FormEditor implements
                firePropertyChange(PROP_DIRTY);
        }
 
-       /*
-        * (non-Javadoc)
-        *
-        * @see org.eclipse.ui.part.MultiPageEditorPart#isDirty()
-        */
-       /**
-        * <p>
-        * isDirty
-        * </p>
-        *
-        * @return a boolean.
-        */
        @Override
     public boolean isDirty() {
                return dirty;
        }
 
-       /*
-        * (non-Javadoc)
-        *
-        * @see org.eclipse.ui.forms.editor.FormEditor#editorDirtyStateChanged()
-        */
        /** {@inheritDoc} */
        @Override
        public void editorDirtyStateChanged() {
@@ -208,11 +188,6 @@ public class MultiPageTaxonEditor extends FormEditor implements
         * place before passing property change along to
         * <code>super.handlePropertyChange(int propertyId)</code>.
         */
-       /*
-        * (non-Javadoc)
-        *
-        * @see org.eclipse.ui.part.MultiPageEditorPart#handlePropertyChange(int)
-        */
        @Override
     protected void handlePropertyChange(int propertyId) {
                if (propertyId == PROP_DIRTY) {
@@ -305,6 +280,14 @@ public class MultiPageTaxonEditor extends FormEditor implements
                 container.refresh();
             }
         }
+        //refresh part title
+        //TODO: refresh taxon node in taxon navigator
+        setPartName();
+    }
+
+    @Override
+    public void forceDirty() {
+        changed(null);
     }
 
        /**
@@ -316,60 +299,19 @@ public class MultiPageTaxonEditor extends FormEditor implements
                return input.getTaxon();
        }
 
-       /*
-        * (non-Javadoc)
-        *
-        * @see
-        * eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder
-        * ()
-        */
-       /**
-        * <p>
-        * getConversationHolder
-        * </p>
-        *
-        * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
-        *         object.
-        */
        @Override
     public ConversationHolder getConversationHolder() {
                return conversation;
        }
 
-       /**
-        * <p>
-        * setConversationHolder
-        * </p>
-        *
-        * @param conversation
-        *            a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
-        *            object.
-        */
        public void setConversationHolder(ConversationHolder conversation) {
                this.conversation = conversation;
        }
 
-       /**
-        * <p>
-        * Getter for the field <code>undoContext</code>.
-        * </p>
-        *
-        * @return a {@link org.eclipse.core.commands.operations.IUndoContext}
-        *         object.
-        */
        public IUndoContext getUndoContext() {
                return undoContext;
        }
 
-       /**
-        * <p>
-        * Setter for the field <code>undoContext</code>.
-        * </p>
-        *
-        * @param undoContext
-        *            a {@link org.eclipse.core.commands.operations.IUndoContext}
-        *            object.
-        */
        public void setUndoContext(IUndoContext undoContext) {
                this.undoContext = undoContext;
        }
@@ -384,14 +326,7 @@ 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} */
+       /** {@inheritDoc} */
     @Override
     public void update(CdmDataChangeMap events) {
         if (dataChangeBehavior == null) {
@@ -401,17 +336,10 @@ public class MultiPageTaxonEditor extends FormEditor implements
         DataChangeBridge.handleDataChange(events, dataChangeBehavior);
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * eu.etaxonomy.taxeditor.store.operations.IPostOperationEnabled#postOperation
-     * ()
-     */
     /** {@inheritDoc} */
     @Override
     public boolean postOperation(CdmBase objectAffectedByOperation) {
-        setDirty(true);
+               setDirty(true);
 
         for (IEditorPart editor : this.getPages()) {
             if (editor instanceof IPostOperationEnabled) {
@@ -483,13 +411,6 @@ public class MultiPageTaxonEditor extends FormEditor implements
                return editorPage != null && editorPage.redraw(focus);
        }
 
-       /**
-        * <p>
-        * onComplete
-        * </p>
-        *
-        * @return a boolean.
-        */
        @Override
     public boolean onComplete() {
                return false;
@@ -536,4 +457,9 @@ public class MultiPageTaxonEditor extends FormEditor implements
                }
                return true;
        }
+
+       @Override
+       public boolean canAttachMedia() {
+           return true;
+       }
 }