2 * Copyright (C) 2016 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.taxeditor
.ui
.section
.classification
;
12 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
13 import org
.eclipse
.jface
.wizard
.Wizard
;
14 import org
.eclipse
.swt
.widgets
.Display
;
15 import org
.eclipse
.ui
.INewWizard
;
16 import org
.eclipse
.ui
.IWorkbench
;
18 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
19 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
20 import eu
.etaxonomy
.cdm
.persistence
.hibernate
.CdmDataChangeMap
;
21 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
22 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
23 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
29 public abstract class AbstractEditWizard
<T
> extends Wizard
implements
30 INewWizard
, IConversationEnabled
{
32 private ConversationHolder conversation
;
34 protected CdmFormFactory formFactory
;
38 private IWorkbench workbench
;
43 * <p>Constructor for AbstractNewEntityWizard.</p>
45 * @param <T> a T object.
47 public AbstractEditWizard(){
48 setWindowTitle(String
.format("New %s", getEntityName()));
52 * FIXME there might be a smarter way to do this,
56 protected abstract String
getEntityName();
59 * @see org.eclipse.jface.wizard.Wizard#performFinish()
63 public boolean performFinish() {
66 conversation
.commit();
72 * <p>Getter for the field <code>entity</code>.</p>
76 public T
getEntity() {
81 * <p>Setter for the field <code>entity</code>.</p>
83 * @param entity a T object.
85 public void setEntity(T entity
){
90 * Adds the entity to the current persistence context
92 protected abstract void saveEntity();
95 * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
99 public void init(IWorkbench workbench
, IStructuredSelection selection
) {
100 this.workbench
= workbench
!= null ? workbench
: AbstractUtility
.getWorkbench();
103 formFactory
= new CdmFormFactory(Display
.getCurrent(), null);
104 conversation
= CdmStore
.createConversation();
112 * <p>getConversationHolder</p>
114 * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
117 public ConversationHolder
getConversationHolder() {
123 public void update(CdmDataChangeMap changeEvents
) {}
126 * @return the workbench
128 public IWorkbench
getWorkbench() {