From: Cherian Mathew Date: Thu, 5 Feb 2015 09:28:09 +0000 (+0000) Subject: MoveDescriptionToOtherTaxonOperation, MultiPageTaxonEditor, ChangeSynonymToAcceptedTa... X-Git-Tag: remoting-3.9.0~210 X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/commitdiff_plain/1842d7af5bfbb67547880cd335be3f2a170efd21 MoveDescriptionToOtherTaxonOperation, MultiPageTaxonEditor, ChangeSynonymToAcceptedTaxonHandler, DeleteTaxonBaseHandler, ChangeSynonymToAcceptedTaxonOperation, DeleteTaxonBaseOperation, DeleteTaxonOperation, MoveDescriptionToOtherTaxonHandler : indentation PolytomousKeyEditorInput, TaxonNameEditor : implements ICdmEntitySessionEnabled --- diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/MultiPageTaxonEditor.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/MultiPageTaxonEditor.java index 164ed0037..1d6ab76ef 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/MultiPageTaxonEditor.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/MultiPageTaxonEditor.java @@ -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 ID="eu.etaxonomy.taxeditor.editor.taxon"{trunked} */ - 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; - - /** - *

- * Constructor for MultiPageTaxonEditor. - *

- */ - 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 ID="eu.etaxonomy.taxeditor.editor.taxon"{trunked} */ + 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; + + /** + *

+ * Constructor for MultiPageTaxonEditor. + *

+ */ + 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() - */ - /** - *

- * isDirty - *

- * - * @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() + */ + /** + *

+ * isDirty + *

+ * + * @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 - * firePropertyChange(PROP_DIRTY) to signal an edit has taken - * place before passing property change along to - * super.handlePropertyChange(int propertyId). - */ - /* - * (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 + * firePropertyChange(PROP_DIRTY) to signal an edit has taken + * place before passing property change along to + * super.handlePropertyChange(int propertyId). + */ + /* + * (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 MultiPageEditorPart.setPartName(String partName) 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 MultiPageEditorPart.setPartName(String partName) 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 - * () - */ - /** - *

- * getConversationHolder - *

- * - * @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 + * () + */ + /** + *

+ * getConversationHolder + *

+ * + * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} + * object. + */ + @Override public ConversationHolder getConversationHolder() { - return conversation; - } - - /** - *

- * setConversationHolder - *

- * - * @param conversation - * a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} - * object. - */ - public void setConversationHolder(ConversationHolder conversation) { - this.conversation = conversation; - } - - /** - *

- * Getter for the field undoContext. - *

- * - * @return a {@link org.eclipse.core.commands.operations.IUndoContext} - * object. - */ - public IUndoContext getUndoContext() { - return undoContext; - } - - /** - *

- * Setter for the field undoContext. - *

- * - * @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; + } + + /** + *

+ * setConversationHolder + *

+ * + * @param conversation + * a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} + * object. + */ + public void setConversationHolder(ConversationHolder conversation) { + this.conversation = conversation; + } + + /** + *

+ * Getter for the field undoContext. + *

+ * + * @return a {@link org.eclipse.core.commands.operations.IUndoContext} + * object. + */ + public IUndoContext getUndoContext() { + return undoContext; + } + + /** + *

+ * Setter for the field undoContext. + *

+ * + * @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 IEditorPart 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 AbstractTaxonEditors registered with this - * MultiPageTaxonEditor. - * - * @return a {@link java.util.List} object. - */ - public List getPages() { - ArrayList editors = new ArrayList(); - 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); - } - - /** - *

- * onComplete - *

- * - * @return a boolean. - */ - @Override + /** + * Returns an IEditorPart 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 AbstractTaxonEditors registered with this + * MultiPageTaxonEditor. + * + * @return a {@link java.util.List} object. + */ + public List getPages() { + ArrayList editors = new ArrayList(); + 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); + } + + /** + *

+ * onComplete + *

+ * + * @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; + } } diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyEditorInput.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyEditorInput.java index 9ab9fbf80..fd74ece68 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyEditorInput.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyEditorInput.java @@ -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 implements ISessionEventListener { +public class PolytomousKeyEditorInput extends AbstractIdentificationEditorInput 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; + } } diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/TaxonNameEditor.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/TaxonNameEditor.java index 24ea70f11..5040d557a 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/TaxonNameEditor.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/TaxonNameEditor.java @@ -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; /** *

@@ -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; + } } diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/ChangeSynonymToAcceptedTaxonHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/ChangeSynonymToAcceptedTaxonHandler.java index e76b8475e..6dadfb8da 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/ChangeSynonymToAcceptedTaxonHandler.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/ChangeSynonymToAcceptedTaxonHandler.java @@ -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 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 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; } diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/DeleteTaxonBaseHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/DeleteTaxonBaseHandler.java index ed85b64c0..c3f92f58d 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/DeleteTaxonBaseHandler.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/DeleteTaxonBaseHandler.java @@ -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(); } diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeSynonymToAcceptedTaxonOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeSynonymToAcceptedTaxonOperation.java index 1b5349173..7f80174c1 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeSynonymToAcceptedTaxonOperation.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeSynonymToAcceptedTaxonOperation.java @@ -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 namesInHomotypicalGroup, IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled) { - super(label, undoContext, postOperationEnabled, conversationEnabled); + public ChangeSynonymToAcceptedTaxonOperation(String label, + IUndoContext undoContext, + Taxon taxon, + ITaxonTreeNode parentNode, + Synonym synonym, + Set 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); - + } }*/ diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteTaxonBaseOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteTaxonBaseOperation.java index c65dda535..5d4c6f945 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteTaxonBaseOperation.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteTaxonBaseOperation.java @@ -11,15 +11,20 @@ import eu.etaxonomy.cdm.api.conversation.IConversationEnabled; import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator; import eu.etaxonomy.taxeditor.operation.AbstractPersistentPostOperation; import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; +import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled; public class DeleteTaxonBaseOperation extends AbstractPersistentPostOperation { protected TaxonDeletionConfigurator configurator; - public DeleteTaxonBaseOperation(String label, IUndoContext undoContext, - TaxonDeletionConfigurator configurator, IWorkbenchPage activePage, IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled) { - super(label, undoContext, postOperationEnabled, - conversationEnabled); + public DeleteTaxonBaseOperation(String label, + IUndoContext undoContext, + TaxonDeletionConfigurator configurator, + IWorkbenchPage activePage, + IPostOperationEnabled postOperationEnabled, + IConversationEnabled conversationEnabled, + ICdmEntitySessionEnabled cdmEntitySessionEnabled) { + super(label, undoContext, postOperationEnabled, conversationEnabled, cdmEntitySessionEnabled); this.configurator = configurator; } diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteTaxonOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteTaxonOperation.java index e7cd64a7e..d1c910abc 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteTaxonOperation.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteTaxonOperation.java @@ -20,15 +20,23 @@ import eu.etaxonomy.cdm.model.taxon.Classification; import eu.etaxonomy.cdm.model.taxon.Taxon; import eu.etaxonomy.cdm.model.taxon.TaxonNode; import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; +import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled; import eu.etaxonomy.taxeditor.store.CdmStore; public class DeleteTaxonOperation extends DeleteTaxonBaseOperation{ private final Classification classification; - public DeleteTaxonOperation(String label, IUndoContext undoContext, - Taxon taxon, TaxonDeletionConfigurator configurator, Classification classification, IWorkbenchPage activePage, IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled) { - super(label, undoContext, configurator, activePage, postOperationEnabled, conversationEnabled); + public DeleteTaxonOperation(String label, + IUndoContext undoContext, + Taxon taxon, + TaxonDeletionConfigurator configurator, + Classification classification, + IWorkbenchPage activePage, + IPostOperationEnabled postOperationEnabled, + IConversationEnabled conversationEnabled, + ICdmEntitySessionEnabled cdmEntitySessionEnabled) { + super(label, undoContext, configurator, activePage, postOperationEnabled, conversationEnabled, cdmEntitySessionEnabled); this.element = taxon; Set nodes = taxon.getTaxonNodes(); diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/MoveDescriptionToOtherTaxonHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/MoveDescriptionToOtherTaxonHandler.java index ab67cf8c6..8e7eea97d 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/MoveDescriptionToOtherTaxonHandler.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/MoveDescriptionToOtherTaxonHandler.java @@ -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); } diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/MoveDescriptionToOtherTaxonOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/MoveDescriptionToOtherTaxonOperation.java index 8ab3fe60b..84146211e 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/MoveDescriptionToOtherTaxonOperation.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/MoveDescriptionToOtherTaxonOperation.java @@ -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; + /** *

Constructor for ChangeAcceptedTaxonToSynonymOperation.

* @@ -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); }