3 * Copyright (C) 2016 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.ui
.section
.classification
;
13 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
14 import org
.eclipse
.jface
.wizard
.Wizard
;
15 import org
.eclipse
.swt
.widgets
.Display
;
16 import org
.eclipse
.ui
.INewWizard
;
17 import org
.eclipse
.ui
.IWorkbench
;
19 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
20 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
21 import eu
.etaxonomy
.cdm
.persistence
.hibernate
.CdmDataChangeMap
;
22 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
23 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
24 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
30 public abstract class AbstractEditWizard
<T
> extends Wizard
implements
31 INewWizard
, IConversationEnabled
{
33 private ConversationHolder conversation
;
35 protected CdmFormFactory formFactory
;
39 private IWorkbench workbench
;
44 * <p>Constructor for AbstractNewEntityWizard.</p>
46 * @param <T> a T object.
48 public AbstractEditWizard(){
49 setWindowTitle(String
.format("New %s", getEntityName()));
53 * FIXME there might be a smarter way to do this,
57 protected abstract String
getEntityName();
60 * @see org.eclipse.jface.wizard.Wizard#performFinish()
64 public boolean performFinish() {
67 conversation
.commit();
73 * <p>Getter for the field <code>entity</code>.</p>
77 public T
getEntity() {
82 * <p>Setter for the field <code>entity</code>.</p>
84 * @param entity a T object.
86 public void setEntity(T entity
){
91 * Adds the entity to the current persistence context
93 protected abstract void saveEntity();
96 * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
100 public void init(IWorkbench workbench
, IStructuredSelection selection
) {
101 this.workbench
= workbench
!= null ? workbench
: AbstractUtility
.getWorkbench();
104 formFactory
= new CdmFormFactory(Display
.getCurrent(), null);
105 conversation
= CdmStore
.createConversation();
113 * <p>getConversationHolder</p>
115 * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
118 public ConversationHolder
getConversationHolder() {
124 public void update(CdmDataChangeMap changeEvents
) {}
127 * @return the workbench
129 public IWorkbench
getWorkbench() {