// $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.
*/
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.store.CdmStore;
import eu.etaxonomy.taxeditor.store.StoreUtil;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
INewWizard, IConversationEnabled {
private ConversationHolder conversation;
-
+
protected CdmFormFactory formFactory;
private T entity;
private IWorkbench workbench;
private IStructuredSelection selection;
-
+
/**
* <p>Constructor for AbstractNewEntityWizard.</p>
*
public AbstractNewEntityWizard(){
setWindowTitle(String.format("New %s", getEntityName()));
}
-
+
/**
* FIXME there might be a smarter way to do this,
- *
+ *
* @return
*/
protected abstract String getEntityName();
@Override
public boolean performFinish() {
saveEntity();
-
+
conversation.commit();
conversation.close();
return true;
}
-
+
/**
* <p>Getter for the field <code>entity</code>.</p>
*
public T getEntity() {
return entity;
}
-
+
/**
* <p>Setter for the field <code>entity</code>.</p>
*
public void setEntity(T entity){
this.entity = entity;
}
-
+
/**
* Adds the entity to the current persistence context
*/
/** {@inheritDoc} */
@Override
public void init(IWorkbench workbench, IStructuredSelection selection) {
- this.workbench = workbench != null ? workbench : StoreUtil.getWorkbench();
-
+ this.workbench = workbench != null ? workbench : AbstractUtility.getWorkbench();
+
if(selection == null){
- ISelectionService service = (ISelectionService) this.workbench.getActiveWorkbenchWindow().getSelectionService();
+ ISelectionService service = this.workbench.getActiveWorkbenchWindow().getSelectionService();
if(service.getSelection() instanceof IStructuredSelection){
selection = (IStructuredSelection) service.getSelection();
}
}
this.selection = selection;
-
+
formFactory = new CdmFormFactory(Display.getCurrent(), null);
conversation = CdmStore.createConversation();
entity = createNewEntity();
-
+
}
-
+
/**
* <p>createNewEntity</p>
*
* @return a T object.
*/
protected abstract T createNewEntity();
-
+
/**
* <p>getConversationHolder</p>
*
* @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
*/
- public ConversationHolder getConversationHolder() {
+ @Override
+ public ConversationHolder getConversationHolder() {
return conversation;
}
-
+
/** {@inheritDoc} */
- public void update(CdmDataChangeMap changeEvents) {}
+ @Override
+ public void update(CdmDataChangeMap changeEvents) {}
/**
* @return the workbench