2 * Copyright (C) 2007 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.
10 package eu
.etaxonomy
.taxeditor
.newWizard
;
12 import org
.eclipse
.e4
.ui
.workbench
.IWorkbench
;
13 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
14 import org
.eclipse
.jface
.wizard
.Wizard
;
15 import org
.eclipse
.swt
.widgets
.Display
;
17 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
18 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
19 import eu
.etaxonomy
.cdm
.persistence
.hibernate
.CdmDataChangeMap
;
20 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
21 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
26 * @created Jun 1, 2010
29 public abstract class AbstractNewEntityWizard
<T
> extends Wizard
implements
30 IConversationEnabled
{
32 protected ConversationHolder conversation
;
34 protected CdmFormFactory formFactory
;
38 protected IStructuredSelection selection
;
40 public AbstractNewEntityWizard(){
41 setWindowTitle(String
.format("New %s", getEntityName()));
45 * FIXME there might be a smarter way to do this,
49 protected abstract String
getEntityName();
53 public boolean performFinish() {
56 conversation
.commit();
62 public T
getEntity() {
66 public void setEntity(T entity
){
71 * Adds the entity to the current persistence context
73 protected abstract void saveEntity();
76 public void init(IWorkbench workbench
, IStructuredSelection selection
) {
77 formFactory
= new CdmFormFactory(Display
.getCurrent(), null);
78 conversation
= CdmStore
.createConversation();
79 this.selection
= selection
;
80 entity
= createNewEntity();
84 protected abstract T
createNewEntity();
87 public ConversationHolder
getConversationHolder() {
93 public void update(CdmDataChangeMap changeEvents
) {}
95 public IStructuredSelection
getSelection() {