import org.eclipse.ui.PartInitException;
import org.eclipse.ui.forms.editor.FormEditor;
-import eu.etaxonomy.cdm.api.application.CdmApplicationState;
-import eu.etaxonomy.cdm.api.application.CdmChangeEvent;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
import eu.etaxonomy.cdm.model.taxon.Taxon;
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.internal.TaxeditorEditorPlugin;
import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
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;
/**
*
* @version 1.0
*/
public class MultiPageTaxonEditor extends FormEditor implements
-IPartContentHasFactualData, IConversationEnabled, ICdmEntitySessionEnabled, IPostOperationEnabled,
+IPartContentHasFactualData, IConversationEnabled, IPostOperationEnabled,
IDirtyMarkable, IPartContentHasDetails, ISecuredEditor, IPartContentHasMedia {
/** Constant <code>ID="eu.etaxonomy.taxeditor.editor.taxon"{trunked}</code> */
private boolean dirty;
- private ICdmEntitySession cdmEntitySession;
private ConversationHolder conversation;
private IDataChangeBehavior dataChangeBehavior;
private IUndoContext undoContext;
/** {@inheritDoc} */
@Override
public void dispose() {
- if(cdmEntitySession != null) {
- cdmEntitySession.dispose();
- }
+ input.dispose();
conversation.unregisterForDataStoreChanges(this);
conversation.close();
super.dispose();
input = (TaxonEditorInput) getEditorInput();
conversation = input.getConversationHolder();
conversation.registerForDataStoreChanges(this);
- CdmApplicationState.getCurrentDataChangeService().register(this);
+
try {
addPage(Page.NAME.getIndex(), new TaxonNameEditor(this),
getEditorInput());
// commit the conversation and start a new transaction immediately
- input.update();
+ input.merge();
conversation.commit(true);
monitor.worked(1);
editorPage.setDisabled();
}
}
- CdmApplicationState.getCurrentDataChangeService().unregister(this);
+
conversation.unregisterForDataStoreChanges(this);
conversation.close();
setDirty(false);
}
this.input = (TaxonEditorInput) input;
- cdmEntitySession = this.input.getCdmEntitySession();
+
// try {
// // Listen for name changes,
@Override
public void changed(Object element) {
// setDirty(true);
- dirty = true;
- super.editorDirtyStateChanged();
+ // if the attribute is null then do not set the dirty flag -> hotfix for the problem that for tasks done in service methods the changes are saved automatically
+ if (element != null){
+ dirty = true;
+ super.editorDirtyStateChanged();
+ }
+
if (element instanceof TaxonBase) {
TaxonNameEditor page = (TaxonNameEditor) getPage(Page.NAME);
AbstractGroupedContainer container = page.getContainer((TaxonBase) element);
// logger.warn("Setting focus to editor");
// bind the conversation
getConversationHolder().bind();
- if(cdmEntitySession != null) {
- cdmEntitySession.bind();
- }
+ input.bind();
// pass focus to the active editor page
getActiveEditor().setFocus();
}
}
/* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getCdmEntitySession()
- */
- @Override
- public ICdmEntitySession getCdmEntitySession() {
- return cdmEntitySession;
- }
-
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities()
+ * @see eu.etaxonomy.taxeditor.model.IPartContentHasMedia#canAttachMedia()
*/
@Override
- public List<TaxonNode> getRootEntities() {
- return input.getRootEntities();
+ public boolean canAttachMedia() {
+ return true;
}
- /* (non-Javadoc)
- * @see eu.etaxonomy.cdm.api.application.ICdmChangeListener#onChange(eu.etaxonomy.cdm.api.application.CdmChangeEvent)
- */
- @Override
- public void onChange(CdmChangeEvent event) {
- // TODO Auto-generated method stub
-
- }
}