MoveDescriptionToOtherTaxonOperation, MultiPageTaxonEditor, ChangeSynonymToAcceptedTa...
authorCherian Mathew <c.mathew@bgbm.org>
Thu, 5 Feb 2015 09:28:09 +0000 (09:28 +0000)
committerCherian Mathew <c.mathew@bgbm.org>
Thu, 5 Feb 2015 09:28:09 +0000 (09:28 +0000)
PolytomousKeyEditorInput, TaxonNameEditor : implements ICdmEntitySessionEnabled

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/MultiPageTaxonEditor.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyEditorInput.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/TaxonNameEditor.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/ChangeSynonymToAcceptedTaxonHandler.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/DeleteTaxonBaseHandler.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeSynonymToAcceptedTaxonOperation.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteTaxonBaseOperation.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteTaxonOperation.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/MoveDescriptionToOtherTaxonHandler.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/MoveDescriptionToOtherTaxonOperation.java

index 164ed003754e187e91dfa9ce91fe3ef3f23c4b00..1d6ab76ef195043f5aed2c0eb9fb84aa6acad021 100644 (file)
@@ -42,6 +42,8 @@ import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData;
 import eu.etaxonomy.taxeditor.model.IPartContentHasMedia;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
 
 /**
  *
@@ -54,77 +56,81 @@ import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
  * @version 1.0
  */
 public class MultiPageTaxonEditor extends FormEditor implements
-        IPartContentHasFactualData, IConversationEnabled, IPostOperationEnabled,
-               IDirtyMarkable, IPartContentHasDetails, ISecuredEditor, IPartContentHasMedia {
-
-       /** Constant <code>ID="eu.etaxonomy.taxeditor.editor.taxon"{trunked}</code> */
-       public static final String ID = "eu.etaxonomy.taxeditor.editor.taxon";
-
-       private boolean dirty;
-
-       private ConversationHolder conversation;
-       private IDataChangeBehavior dataChangeBehavior;
-       private IUndoContext undoContext;
-
-       private TaxonEditorInput input;
-
-       /**
-        * <p>
-        * Constructor for MultiPageTaxonEditor.
-        * </p>
-        */
-       public MultiPageTaxonEditor() {
-               super();
-               undoContext = new UndoContext();
-       }
-
-       /** {@inheritDoc} */
-       @Override
-       public void dispose() {
-               conversation.unregisterForDataStoreChanges(this);
-               conversation.close();
-               super.dispose();
-       }
-
-       /*
-        * (non-Javadoc)
-        *
-        * @see org.eclipse.ui.forms.editor.FormEditor#addPages()
-        */
-       /** {@inheritDoc} */
-       @Override
-       protected void addPages() {
-               input = (TaxonEditorInput) getEditorInput();
-               conversation = input.getConversationHolder();
-               conversation.registerForDataStoreChanges(this);
-
-               try {
-                       addPage(Page.NAME.getIndex(), new TaxonNameEditor(this),
-                                       getEditorInput());
-                       // setPageText(Page.NAME.getIndex(), Page.NAME.getTitle());
-
-                       // TODO lazy create
-                       // addPage(Page.DESCRIPTIVE.getIndex(), new
-                       // TaxonDescriptionTreeEditor(this), getEditorInput());
-                       // setPageText(Page.DESCRIPTIVE.getIndex(),
-                       // Page.DESCRIPTIVE.getTitle());
-
-                       // EditorUtil.showPropertySheet();
-
-               } catch (PartInitException e) {
-                       MessagingUtils.error(getClass(), e);
-               }
-       }
-
-       /** {@inheritDoc} */
-       @Override
-       public void doSave(IProgressMonitor monitor) {
-               monitor.beginTask("Saving Editor", 4);
-               try {
-                       if (!conversation.isBound()) {
-                               conversation.bind();
-                       }
-                       monitor.worked(1);
+IPartContentHasFactualData, IConversationEnabled, ICdmEntitySessionEnabled, IPostOperationEnabled,
+IDirtyMarkable, IPartContentHasDetails, ISecuredEditor, IPartContentHasMedia {
+
+    /** Constant <code>ID="eu.etaxonomy.taxeditor.editor.taxon"{trunked}</code> */
+    public static final String ID = "eu.etaxonomy.taxeditor.editor.taxon";
+
+    private boolean dirty;
+
+    private ICdmEntitySession cdmEntitySession;
+    private ConversationHolder conversation;
+    private IDataChangeBehavior dataChangeBehavior;
+    private IUndoContext undoContext;
+
+    private TaxonEditorInput input;
+
+    /**
+     * <p>
+     * Constructor for MultiPageTaxonEditor.
+     * </p>
+     */
+    public MultiPageTaxonEditor() {
+        super();
+        undoContext = new UndoContext();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void dispose() {
+        if(cdmEntitySession != null) {
+            cdmEntitySession.dispose();
+        }
+        conversation.unregisterForDataStoreChanges(this);
+        conversation.close();
+        super.dispose();
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.eclipse.ui.forms.editor.FormEditor#addPages()
+     */
+    /** {@inheritDoc} */
+    @Override
+    protected void addPages() {
+        input = (TaxonEditorInput) getEditorInput();
+        conversation = input.getConversationHolder();
+        conversation.registerForDataStoreChanges(this);
+
+        try {
+            addPage(Page.NAME.getIndex(), new TaxonNameEditor(this),
+                    getEditorInput());
+            // setPageText(Page.NAME.getIndex(), Page.NAME.getTitle());
+
+            // TODO lazy create
+            // addPage(Page.DESCRIPTIVE.getIndex(), new
+            // TaxonDescriptionTreeEditor(this), getEditorInput());
+            // setPageText(Page.DESCRIPTIVE.getIndex(),
+            // Page.DESCRIPTIVE.getTitle());
+
+            // EditorUtil.showPropertySheet();
+
+        } catch (PartInitException e) {
+            MessagingUtils.error(getClass(), e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void doSave(IProgressMonitor monitor) {
+        monitor.beginTask("Saving Editor", 4);
+        try {
+            if (!conversation.isBound()) {
+                conversation.bind();
+            }
+            monitor.worked(1);
 
             for (IEditorPart editorPage : getPages()) {
                 if (editorPage instanceof TaxonNameEditor) {
@@ -140,9 +146,9 @@ public class MultiPageTaxonEditor extends FormEditor implements
                 monitor.worked(1);
             }
 
-                       // commit the conversation and start a new transaction immediately
-                       conversation.commit(true);
-                       monitor.worked(1);
+            // commit the conversation and start a new transaction immediately
+            conversation.commit(true);
+            monitor.worked(1);
 
             this.setDirty(false);
             monitor.worked(1);
@@ -153,141 +159,141 @@ public class MultiPageTaxonEditor extends FormEditor implements
         } finally {
             monitor.done();
         }
-       }
-
-       private void disableEditor(boolean isOnError) {
-               for (IMultiPageTaxonEditorPage editorPage : getPages()) {
-                       if(isOnError){
-                               editorPage.setOnError();
-                       }else {
-                               editorPage.setDisabled();
-                       }
-               }
-               conversation.unregisterForDataStoreChanges(this);
-               conversation.close();
-               setDirty(false);
-       }
-
-       private void setDirty(boolean dirty) {
-               this.dirty = dirty;
-               firePropertyChange(PROP_DIRTY);
-       }
-
-       /*
-        * (non-Javadoc)
-        *
-        * @see org.eclipse.ui.part.MultiPageEditorPart#isDirty()
-        */
-       /**
-        * <p>
-        * isDirty
-        * </p>
-        *
-        * @return a boolean.
-        */
-       @Override
+    }
+
+    private void disableEditor(boolean isOnError) {
+        for (IMultiPageTaxonEditorPage editorPage : getPages()) {
+            if(isOnError){
+                editorPage.setOnError();
+            }else {
+                editorPage.setDisabled();
+            }
+        }
+        conversation.unregisterForDataStoreChanges(this);
+        conversation.close();
+        setDirty(false);
+    }
+
+    private void setDirty(boolean dirty) {
+        this.dirty = dirty;
+        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() {
-               dirty = true;
-               super.editorDirtyStateChanged();
-       }
-
-       /**
-        * {@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
-        * <code>super.handlePropertyChange(int propertyId)</code>.
-        */
-       /*
-        * (non-Javadoc)
-        *
-        * @see org.eclipse.ui.part.MultiPageEditorPart#handlePropertyChange(int)
-        */
-       @Override
+        return dirty;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.eclipse.ui.forms.editor.FormEditor#editorDirtyStateChanged()
+     */
+    /** {@inheritDoc} */
+    @Override
+    public void editorDirtyStateChanged() {
+        dirty = true;
+        super.editorDirtyStateChanged();
+    }
+
+    /**
+     * {@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
+     * <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) {
-                       setDirty(true);
-               }
-               super.handlePropertyChange(propertyId);
-       }
-
-       /** {@inheritDoc} */
-       @Override
-       public void doSaveAs() {
-       }
-
-       /** {@inheritDoc} */
-       @Override
-       public boolean isSaveAsAllowed() {
-               return false;
-       }
-
-       /** {@inheritDoc} */
-       @Override
-       public void init(IEditorSite site, IEditorInput input)
-                       throws PartInitException {
-
-               if (!(input instanceof TaxonEditorInput)) {
+        if (propertyId == PROP_DIRTY) {
+            setDirty(true);
+        }
+        super.handlePropertyChange(propertyId);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void doSaveAs() {
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public boolean isSaveAsAllowed() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void init(IEditorSite site, IEditorInput input)
+            throws PartInitException {
+
+        if (!(input instanceof TaxonEditorInput)) {
             throw new PartInitException(
-                                       "Invalid Input: Must be TaxonEditorInput");
+                    "Invalid Input: Must be TaxonEditorInput");
+        }
+
+        this.input = (TaxonEditorInput) input;
+
+        // try {
+        // // Listen for name changes,
+        // // change tab for this taxon editor accordingly
+        // getTaxon().addPropertyChangeListener("name",
+        // new PropertyChangeListener() {
+        // public void propertyChange(PropertyChangeEvent e) {
+        // setPartName();
+        // }
+        // });
+        // } catch (NullPointerException e) {
+        // EditorUtil.warn(getClass(),
+        // "Caught an NPE while initing an editor. This is most " +
+        // "likely due to the unsuccesful attempt to restore the former " +
+        // "state of the application. We ignore this because the workbench " +
+        // "will simply be reset.");
+        // }
+        setPartName();
+
+        super.init(site, input);
+    }
+
+    /**
+     * Calls <code>MultiPageEditorPart.setPartName(String partName)</code> with
+     * text appropriate to the state of the taxon: any taxon that has been saved
+     * will by necessity have a name to display; a new taxon should display
+     * "New taxon" in the editor tab.
+     */
+    protected void setPartName() {
+
+        String partName = null;
+        TaxonNameBase<?, ?> name = getTaxon().getName();
+
+        if (name != null) {
+            partName = name.getTitleCache();
         }
 
-               this.input = (TaxonEditorInput) input;
-
-               // try {
-               // // Listen for name changes,
-               // // change tab for this taxon editor accordingly
-               // getTaxon().addPropertyChangeListener("name",
-               // new PropertyChangeListener() {
-               // public void propertyChange(PropertyChangeEvent e) {
-               // setPartName();
-               // }
-               // });
-               // } catch (NullPointerException e) {
-               // EditorUtil.warn(getClass(),
-               // "Caught an NPE while initing an editor. This is most " +
-               // "likely due to the unsuccesful attempt to restore the former " +
-               // "state of the application. We ignore this because the workbench " +
-               // "will simply be reset.");
-               // }
-               setPartName();
-
-               super.init(site, input);
-       }
-
-       /**
-        * Calls <code>MultiPageEditorPart.setPartName(String partName)</code> with
-        * text appropriate to the state of the taxon: any taxon that has been saved
-        * will by necessity have a name to display; a new taxon should display
-        * "New taxon" in the editor tab.
-        */
-       protected void setPartName() {
-
-               String partName = null;
-               TaxonNameBase<?, ?> name = getTaxon().getName();
-
-               if (name != null) {
-                       partName = name.getTitleCache();
-               }
-
-               if (partName == null || partName.equals("")) {
-                       partName = ("New taxon");
-               }
-
-               setPartName(partName);
-       }
+        if (partName == null || partName.equals("")) {
+            partName = ("New taxon");
+        }
+
+        setPartName(partName);
+    }
 
     /**
      * {@inheritDoc}
@@ -317,82 +323,85 @@ public class MultiPageTaxonEditor extends FormEditor implements
         changed(null);
     }
 
-       /**
-        * The accepted taxon that is the input for this editor
-        *
-        * @return the accepted taxon
-        */
-       public Taxon getTaxon() {
-               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
+    /**
+     * The accepted taxon that is the input for this editor
+     *
+     * @return the accepted taxon
+     */
+    public Taxon getTaxon() {
+        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;
-       }
-
-       /** {@inheritDoc} */
-       @Override
-       public void setFocus() {
-               // logger.warn("Setting focus to editor");
-               // bind the conversation
-               getConversationHolder().bind();
-               // pass focus to the active editor page
-               getActiveEditor().setFocus();
-       }
+        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;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void setFocus() {
+        // logger.warn("Setting focus to editor");
+        // bind the conversation
+        getConversationHolder().bind();
+        if(cdmEntitySession != null) {
+            cdmEntitySession.bind();
+        }
+        // pass focus to the active editor page
+        getActiveEditor().setFocus();
+    }
 
     /*
      * (non-Javadoc)
@@ -435,75 +444,75 @@ public class MultiPageTaxonEditor extends FormEditor implements
         return false;
     }
 
-       /**
-        * Returns an <code>IEditorPart</code> implementation by type
-        *
-        * @param page
-        *            the page type
-        * @return a {@link eu.etaxonomy.taxeditor.editor.IMultiPageTaxonEditorPage}
-        *         object.
-        */
-       public IMultiPageTaxonEditorPage getPage(Page page) {
-               for (IEditorPart editor : this.getPages()) {
-                       if (editor.getClass().equals(page.getClazz())) {
-                               return (IMultiPageTaxonEditorPage) editor;
-                       }
-               }
-               return null;
-       }
-
-       /**
-        * 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() {
-               ArrayList<IMultiPageTaxonEditorPage> editors = new ArrayList<IMultiPageTaxonEditorPage>();
-               for (int i = 0; i < this.getPageCount(); i++) {
-
-                       editors.add((IMultiPageTaxonEditorPage) this.getEditor(i));
-               }
-               return editors;
-       }
-
-       /**
-        * Refreshes a certain page of the MultipageTaxonEditor
-        *
-        * @param page
-        *            a {@link eu.etaxonomy.taxeditor.editor.Page} object.
-        * @return a boolean.
-        */
-       public boolean redraw(Page page) {
-               return redraw(page, true);
-       }
-
-       /**
-        * 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
-        *            a boolean.
-        * @return a boolean.
-        */
-       public boolean redraw(Page page, boolean focus) {
-               IMultiPageTaxonEditorPage editorPage = getPage(page);
-               return editorPage != null && editorPage.redraw(focus);
-       }
-
-       /**
-        * <p>
-        * onComplete
-        * </p>
-        *
-        * @return a boolean.
-        */
-       @Override
+    /**
+     * Returns an <code>IEditorPart</code> implementation by type
+     *
+     * @param page
+     *            the page type
+     * @return a {@link eu.etaxonomy.taxeditor.editor.IMultiPageTaxonEditorPage}
+     *         object.
+     */
+    public IMultiPageTaxonEditorPage getPage(Page page) {
+        for (IEditorPart editor : this.getPages()) {
+            if (editor.getClass().equals(page.getClazz())) {
+                return (IMultiPageTaxonEditorPage) editor;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 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() {
+        ArrayList<IMultiPageTaxonEditorPage> editors = new ArrayList<IMultiPageTaxonEditorPage>();
+        for (int i = 0; i < this.getPageCount(); i++) {
+
+            editors.add((IMultiPageTaxonEditorPage) this.getEditor(i));
+        }
+        return editors;
+    }
+
+    /**
+     * Refreshes a certain page of the MultipageTaxonEditor
+     *
+     * @param page
+     *            a {@link eu.etaxonomy.taxeditor.editor.Page} object.
+     * @return a boolean.
+     */
+    public boolean redraw(Page page) {
+        return redraw(page, true);
+    }
+
+    /**
+     * 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
+     *            a boolean.
+     * @return a boolean.
+     */
+    public boolean redraw(Page page, boolean focus) {
+        IMultiPageTaxonEditorPage editorPage = getPage(page);
+        return editorPage != null && editorPage.redraw(focus);
+    }
+
+    /**
+     * <p>
+     * onComplete
+     * </p>
+     *
+     * @return a boolean.
+     */
+    @Override
     public boolean onComplete() {
-               return false;
-       }
+        return false;
+    }
 
     /**
      * Reloads the data for this
@@ -533,17 +542,26 @@ public class MultiPageTaxonEditor extends FormEditor implements
         }
     }
 
-       @Override
-       public String toString() {
-               return String.format("%s[%s]", this.getClass().getSimpleName(), getEditorInput());
-       }
+    @Override
+    public String toString() {
+        return String.format("%s[%s]", this.getClass().getSimpleName(), getEditorInput());
+    }
+
+    @Override
+    public boolean permissionsSatisfied() {
+        IEditorPart activeEditor = getActiveEditor();
+        if(activeEditor != null && ISecuredEditor.class.isAssignableFrom(activeEditor.getClass())){
+            return ((ISecuredEditor)activeEditor).permissionsSatisfied();
+        }
+        return true;
+    }
 
-       @Override
-       public boolean permissionsSatisfied() {
-               IEditorPart activeEditor = getActiveEditor();
-               if(activeEditor != null && ISecuredEditor.class.isAssignableFrom(activeEditor.getClass())){
-                       return ((ISecuredEditor)activeEditor).permissionsSatisfied();
-               }
-               return true;
-       }
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getCdmEntitySession()
+     */
+    @Override
+    public ICdmEntitySession getCdmEntitySession() {
+        // TODO Auto-generated method stub
+        return null;
+    }
 }
index 9ab9fbf80c46753f893e46c4217c39b9478fd2bf..fd74ece68966f1d7fa4f855c3cc4865d185526e6 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * 
+ *
  */
 package eu.etaxonomy.taxeditor.editor.key.polytomous;
 
@@ -9,43 +9,45 @@ import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
 import eu.etaxonomy.cdm.api.service.IPolytomousKeyService;
 import eu.etaxonomy.cdm.model.description.PolytomousKey;
 import eu.etaxonomy.taxeditor.editor.key.AbstractIdentificationEditorInput;
-import eu.etaxonomy.taxeditor.session.ISessionEventListener;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 
 /**
  * @author n.hoffmann
  *
  */
-public class PolytomousKeyEditorInput extends AbstractIdentificationEditorInput<PolytomousKey> implements ISessionEventListener {
+public class PolytomousKeyEditorInput extends AbstractIdentificationEditorInput<PolytomousKey> implements ICdmEntitySessionEnabled {
 
-       private PolytomousKey key;
+       private final PolytomousKey key;
+       private final ICdmEntitySession cdmEntitySession;
 
        protected PolytomousKeyEditorInput(ConversationHolder conversation,
                        PolytomousKey key) {
                super(conversation);
-               CdmStore.getCurrentSessionManager().bind(this);
-               CdmStore.getCurrentSessionManager().load(key);
+               cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
+
                this.key = key;
        }
-       
-       
+
+
 
        public static PolytomousKeyEditorInput NewInstance(UUID polytomousKeyUuid) throws Exception{
                try{
                        ConversationHolder conversation = CdmStore.createConversation();
-                       
+
                        return NewInstance(polytomousKeyUuid, conversation);
                }catch(Exception e){
                        throw e;
                }
        }
-       
+
        public static PolytomousKeyEditorInput NewInstance(UUID polytomousKeyUuid, ConversationHolder conversation) throws Exception{
                PolytomousKey polytomousKey = CdmStore.getService(IPolytomousKeyService.class).load(polytomousKeyUuid, null);
-                       
+
                return new PolytomousKeyEditorInput(conversation, polytomousKey);
        }
-       
+
        /* (non-Javadoc)
         * @see org.eclipse.ui.IEditorInput#getName()
         */
@@ -53,12 +55,12 @@ public class PolytomousKeyEditorInput extends AbstractIdentificationEditorInput<
        public String getName() {
                return key.getTitleCache();
        }
-       
+
        @Override
        public PolytomousKey getKey() {
                return key;
        }
-       
+
        /* (non-Javadoc)
         * @see java.lang.Object#equals(java.lang.Object)
         */
@@ -72,8 +74,18 @@ public class PolytomousKeyEditorInput extends AbstractIdentificationEditorInput<
                }
                return super.equals(object);
        }
-       
+
        public void dispose() {
                CdmStore.getCurrentSessionManager().dispose(this);
        }
+
+
+
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getCdmEntitySession()
+     */
+    @Override
+    public ICdmEntitySession getCdmEntitySession() {
+        return cdmEntitySession;
+    }
 }
index 24ea70f115b96167c99dd03d563d7a841512f8d8..5040d557a1e4b1d43cbd23ef400335ac1d1f879c 100644 (file)
@@ -53,7 +53,6 @@ import eu.etaxonomy.cdm.model.taxon.TaxonBase;
 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
 import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
 import eu.etaxonomy.taxeditor.editor.CdmDataTransfer;
-import eu.etaxonomy.taxeditor.editor.EditorUtil;
 import eu.etaxonomy.taxeditor.editor.IDropTargetable;
 import eu.etaxonomy.taxeditor.editor.IMultiPageTaxonEditorPage;
 import eu.etaxonomy.taxeditor.editor.ISecuredEditor;
@@ -74,8 +73,9 @@ import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
 import eu.etaxonomy.taxeditor.model.TaxeditorPartService;
 import eu.etaxonomy.taxeditor.preference.Resources;
 import eu.etaxonomy.taxeditor.security.RequiredPermissions;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
 import eu.etaxonomy.taxeditor.store.CdmStore;
-import eu.etaxonomy.taxeditor.store.StoreUtil;
 
 /**
  * <p>
@@ -88,7 +88,7 @@ import eu.etaxonomy.taxeditor.store.StoreUtil;
  * @version 1.0
  */
 public class TaxonNameEditor extends EditorPart implements
-               IMultiPageTaxonEditorPage, IConversationEnabled,
+               IMultiPageTaxonEditorPage, IConversationEnabled, ICdmEntitySessionEnabled,
                IPartContentHasDetails, IPartChangeListener,
                ISelectionListener, IDropTargetable, ISecuredEditor {
 
@@ -947,4 +947,13 @@ public class TaxonNameEditor extends EditorPart implements
                Color background =  AbstractUtility.getColor(enabled ? Resources.COLOR_COMPOSITE_BACKGROUND : Resources.COLOR_TEXT_DISABLED_BACKGROUND);
                setEnabled(enabled, background);
        }
+
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getCdmEntitySession()
+     */
+    @Override
+    public ICdmEntitySession getCdmEntitySession() {
+        // TODO Auto-generated method stub
+        return null;
+    }
 }
index e76b8475e3a91bd43d8587fadb357dc6e94bd129..6dadfb8dace9ec8c39314cdefe31f95de4af694b 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.
 */
@@ -51,16 +51,17 @@ public class ChangeSynonymToAcceptedTaxonHandler extends AbstractHandler impleme
        private static final Logger logger = Logger
                        .getLogger(ChangeSynonymToAcceptedTaxonHandler.class);
        private MultiPageTaxonEditor editor;
-       
+
        /* (non-Javadoc)
         * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
         */
        /** {@inheritDoc} */
-       public Object execute(ExecutionEvent event) throws ExecutionException {
+       @Override
+    public Object execute(ExecutionEvent event) throws ExecutionException {
                editor =  (MultiPageTaxonEditor) HandlerUtil.getActiveEditor(event);
                Shell shell = HandlerUtil.getActiveShell(event);
                IEditorInput input = editor.getEditorInput();
-               
+
                if (!(input instanceof TaxonEditorInput)) {
                        logger.error("Editor input is not TaxonEditorInput");
                        return null;
@@ -74,7 +75,7 @@ public class ChangeSynonymToAcceptedTaxonHandler extends AbstractHandler impleme
                }
 
                Synonym synonym = (Synonym) selection.getFirstElement();
-               
+
                // Force user to save taxon - not really necessary though, is it?
                if (!EditorUtil.forceUserSave(editor, shell)) {
                        return null;
@@ -82,25 +83,25 @@ public class ChangeSynonymToAcceptedTaxonHandler extends AbstractHandler impleme
 
                // Get taxon
                Taxon taxon = ((TaxonEditorInput) input).getTaxon();
-               
+
                TaxonNode parentNode = (TaxonNode) HibernateProxyHelper.deproxy(((TaxonEditorInput) input).getTaxonNode().getParent());
-               
+
                List<UUID> excludeTaxa = null;
-               
+
                TaxonNode newParentNode = TaxonNodeSelectionDialog.select(HandlerUtil.getActiveShell(event), editor.getConversationHolder(), "Select parent", excludeTaxa, null, null);
-               
+
                if(newParentNode != null){
-                       
+
                        // TODO get synonyms from homotypical group and add them as homotypic synonyms to new accepted taxon
                        // apply confirmation dialog
                        HomotypicalGroup group = synonym.getHomotypicGroup();
                        Set<TaxonNameBase> namesInGroup = group.getTypifiedNames();
                        // FIXME with this implementation we can not create a taxonNode that is a direct child of the classification node
-                       AbstractPostOperation operation = new ChangeSynonymToAcceptedTaxonOperation("Change synonym to accepted taxon", EditorUtil.getUndoContext(), 
-                                       taxon, newParentNode, synonym, namesInGroup, this, editor); //$NON-NLS-1$
+                       AbstractPostOperation operation = new ChangeSynonymToAcceptedTaxonOperation("Change synonym to accepted taxon", EditorUtil.getUndoContext(),
+                                       taxon, newParentNode, synonym, namesInGroup, this, editor, editor); //$NON-NLS-1$
                        EditorUtil.executeOperation(operation);
                }
-               
+
                return null;
        }
 
@@ -108,19 +109,20 @@ public class ChangeSynonymToAcceptedTaxonHandler extends AbstractHandler impleme
         * @see eu.etaxonomy.taxeditor.operations.IPostOperationEnabled#postOperation(eu.etaxonomy.cdm.model.common.CdmBase)
         */
        /** {@inheritDoc} */
-       public boolean postOperation(CdmBase objectAffectedByOperation) {
-               
+       @Override
+    public boolean postOperation(CdmBase objectAffectedByOperation) {
+
                // Redraw existing editor
                ((IPostOperationEnabled) editor).postOperation(null);
-               
+
                editor.doSave(EditorUtil.getMonitor());
-               
+
                if (objectAffectedByOperation instanceof TaxonNode) {
-               
+
                        // Open new unsaved editor with existing taxon's parent as temporary parent
                        TaxonNode newNode = (TaxonNode) objectAffectedByOperation;
 //                     TaxonNode newNode = parentNode.addChild(newTaxon);
-                                       
+
                        try {
                                // TODO
                                /*
@@ -129,7 +131,7 @@ public class ChangeSynonymToAcceptedTaxonHandler extends AbstractHandler impleme
                                 *  doesn't work yet.
                                 */
                                EditorUtil.openTaxonNode(newNode.getUuid());
-                               
+
                        } catch (PartInitException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
@@ -145,7 +147,8 @@ public class ChangeSynonymToAcceptedTaxonHandler extends AbstractHandler impleme
         *
         * @return a boolean.
         */
-       public boolean onComplete() {
+       @Override
+    public boolean onComplete() {
                // TODO Auto-generated method stub
                return false;
        }
index ed85b64c00acdb64cf79575bc147cb35fb9d14b0..c3f92f58d0462966120af9900ec2726d5794df74 100644 (file)
@@ -91,7 +91,15 @@ public class DeleteTaxonBaseHandler extends AbstractHandler implements IHandler,
 
                        IWorkbenchPage activePage = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
 
-                       operation = new DeleteTaxonOperation(commandName, editor.getUndoContext(),(Taxon) selectedElement, new TaxonDeletionConfigurator(), null, activePage, this, editor);
+                       operation = new DeleteTaxonOperation(commandName,
+                               editor.getUndoContext(),
+                               (Taxon) selectedElement,
+                               new TaxonDeletionConfigurator(),
+                               null,
+                               activePage,
+                               this,
+                               editor,
+                               editor);
                        //editor.dispose();
 
                }
index 1b5349173beab2afb4e424aa76c5b6a784279ac0..7f80174c19240a548b70db0f52cc270f48b227b8 100644 (file)
@@ -28,6 +28,7 @@ import eu.etaxonomy.cdm.model.taxon.TaxonNode;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.operation.AbstractPersistentPostOperation;
 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 
 /**
@@ -40,7 +41,7 @@ import eu.etaxonomy.taxeditor.store.CdmStore;
 public class ChangeSynonymToAcceptedTaxonOperation extends AbstractPersistentPostOperation {
 
        private Taxon newTaxon;
-       private Synonym synonym;
+       private final Synonym synonym;
        private final ITaxonTreeNode parentNode;
 
        private TaxonNode newNode;
@@ -59,9 +60,16 @@ public class ChangeSynonymToAcceptedTaxonOperation extends AbstractPersistentPos
         * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
         * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
         */
-       public ChangeSynonymToAcceptedTaxonOperation(String label, IUndoContext undoContext,
-                       Taxon taxon, ITaxonTreeNode parentNode, Synonym synonym, Set<TaxonNameBase> namesInHomotypicalGroup, IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled) {
-               super(label, undoContext, postOperationEnabled, conversationEnabled);
+       public ChangeSynonymToAcceptedTaxonOperation(String label,
+               IUndoContext undoContext,
+                       Taxon taxon,
+                       ITaxonTreeNode parentNode,
+                       Synonym synonym,
+                       Set<TaxonNameBase> namesInHomotypicalGroup,
+                       IPostOperationEnabled postOperationEnabled,
+                       IConversationEnabled conversationEnabled,
+                       ICdmEntitySessionEnabled cdmEntitySessionEnabled) {
+               super(label, undoContext, postOperationEnabled, conversationEnabled, cdmEntitySessionEnabled);
 
                this.element = taxon;
                this.parentNode = parentNode;
@@ -92,7 +100,7 @@ public class ChangeSynonymToAcceptedTaxonOperation extends AbstractPersistentPos
                        Taxon taxon = newNode.getTaxon();
                        for (TaxonNameBase synonymName : namesInHomotypicGroup){
                                taxon.addHomotypicSynonymName(synonymName, null, null);
-                               
+
                        }
                }*/
 
index c65dda535e5f559e04d9da813723b6cab3b6d58f..5d4c6f945ec16770717989b6bf22ab8a411e6580 100644 (file)
@@ -11,15 +11,20 @@ import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
 import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;\r
 import eu.etaxonomy.taxeditor.operation.AbstractPersistentPostOperation;\r
 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;\r
+import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;\r
 \r
 public class DeleteTaxonBaseOperation extends AbstractPersistentPostOperation {\r
 \r
        protected TaxonDeletionConfigurator configurator;\r
 \r
-       public DeleteTaxonBaseOperation(String label, IUndoContext undoContext,\r
-               TaxonDeletionConfigurator configurator, IWorkbenchPage activePage, IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled) {\r
-               super(label, undoContext, postOperationEnabled,\r
-                                conversationEnabled);\r
+       public DeleteTaxonBaseOperation(String label,\r
+               IUndoContext undoContext,\r
+               TaxonDeletionConfigurator configurator,\r
+               IWorkbenchPage activePage,\r
+               IPostOperationEnabled postOperationEnabled,\r
+               IConversationEnabled conversationEnabled,\r
+               ICdmEntitySessionEnabled cdmEntitySessionEnabled) {\r
+               super(label, undoContext, postOperationEnabled, conversationEnabled, cdmEntitySessionEnabled);\r
                this.configurator = configurator;\r
 \r
        }\r
index e7cd64a7ec18092c53e40af40a99353d30a04200..d1c910abca46c53134edc470aabc12b9ad7a6a5c 100644 (file)
@@ -20,15 +20,23 @@ import eu.etaxonomy.cdm.model.taxon.Classification;
 import eu.etaxonomy.cdm.model.taxon.Taxon;\r
 import eu.etaxonomy.cdm.model.taxon.TaxonNode;\r
 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;\r
+import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;\r
 import eu.etaxonomy.taxeditor.store.CdmStore;\r
 \r
 public class DeleteTaxonOperation extends DeleteTaxonBaseOperation{\r
 \r
     private final Classification classification;\r
 \r
-       public DeleteTaxonOperation(String label, IUndoContext undoContext,\r
-                       Taxon taxon, TaxonDeletionConfigurator configurator, Classification classification, IWorkbenchPage activePage, IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled) {\r
-               super(label, undoContext, configurator, activePage, postOperationEnabled, conversationEnabled);\r
+       public DeleteTaxonOperation(String label,\r
+               IUndoContext undoContext,\r
+                       Taxon taxon,\r
+                       TaxonDeletionConfigurator configurator,\r
+                       Classification classification,\r
+                       IWorkbenchPage activePage,\r
+                       IPostOperationEnabled postOperationEnabled,\r
+                       IConversationEnabled conversationEnabled,\r
+            ICdmEntitySessionEnabled cdmEntitySessionEnabled) {\r
+               super(label, undoContext, configurator, activePage, postOperationEnabled, conversationEnabled, cdmEntitySessionEnabled);\r
                this.element = taxon;\r
 \r
                Set<TaxonNode> nodes = taxon.getTaxonNodes();\r
index ab67cf8c6221f297bd97db55a4176b697e168e5d..8e7eea97dc37013cf98cdde5466d63656c02a245 100644 (file)
@@ -95,7 +95,12 @@ public class MoveDescriptionToOtherTaxonHandler extends AbstractHandler
                        try {
                                for(TaxonDescription description : descriptions){
                                        operation = new MoveDescriptionToOtherTaxonOperation(event.getCommand().getName(),
-                                                                                       editor.getUndoContext(), description, newAcceptedTaxonNode, this, editor);
+                                                                                       editor.getUndoContext(),
+                                                                                       description,
+                                                                                       newAcceptedTaxonNode,
+                                                                                       this,
+                                                                                       editor,
+                                                                                       editor);
                                        AbstractUtility.executeOperation(operation);
                                }
 
index 8ab3fe60b5235e890a0223edc1650b4aa5361ad5..84146211ed2a6fa33ece6486d62908b6a143b5d2 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.
 */
@@ -27,6 +27,7 @@ import eu.etaxonomy.cdm.model.taxon.TaxonNode;
 import eu.etaxonomy.taxeditor.editor.EditorUtil;
 import eu.etaxonomy.taxeditor.operation.AbstractPersistentPostOperation;
 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 
 /**
@@ -37,11 +38,11 @@ import eu.etaxonomy.taxeditor.store.CdmStore;
  */
 public class MoveDescriptionToOtherTaxonOperation extends
                AbstractPersistentPostOperation {
-       
-       private TaxonNode newAcceptedTaxonNode;
 
-       private TaxonDescription description;
-       
+       private final TaxonNode newAcceptedTaxonNode;
+
+       private final TaxonDescription description;
+
        /**
         * <p>Constructor for ChangeAcceptedTaxonToSynonymOperation.</p>
         *
@@ -53,9 +54,13 @@ public class MoveDescriptionToOtherTaxonOperation extends
         * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
         */
        public MoveDescriptionToOtherTaxonOperation(String label,
-                       IUndoContext undoContext, TaxonDescription description, TaxonNode targetTaxonNode,
-                       IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled) {
-               super(label, undoContext, postOperationEnabled, conversationEnabled); // FIXME is this the right constructor ???
+                       IUndoContext undoContext,
+                       TaxonDescription description,
+                       TaxonNode targetTaxonNode,
+                       IPostOperationEnabled postOperationEnabled,
+                       IConversationEnabled conversationEnabled,
+            ICdmEntitySessionEnabled cdmEntitySessionEnabled) {
+               super(label, undoContext, postOperationEnabled, conversationEnabled, cdmEntitySessionEnabled); // FIXME is this the right constructor ???
                this.description = description;
                this.newAcceptedTaxonNode = targetTaxonNode;
        }
@@ -71,7 +76,7 @@ public class MoveDescriptionToOtherTaxonOperation extends
 
                monitor.worked(20);
                bind();
-               
+
                String moveMessage = String.format("Description moved from %s", EditorUtil.getActiveMultiPageTaxonEditor().getTaxon());
                if(description.isProtectedTitleCache()){
                        String separator = "";
@@ -84,9 +89,9 @@ public class MoveDescriptionToOtherTaxonOperation extends
                annotation.setAnnotationType(AnnotationType.TECHNICAL());
                description.addAnnotation(annotation);
                newAcceptedTaxonNode.getTaxon().addDescription(description);
-               CdmStore.getService(IDescriptionService.class).saveOrUpdate(description);       
+               CdmStore.getService(IDescriptionService.class).saveOrUpdate(description);
                monitor.worked(40);
-        
+
                return postExecute(description);
        }