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.
9 package eu
.etaxonomy
.taxeditor
.newWizard
;
11 import org
.eclipse
.e4
.ui
.workbench
.IWorkbench
;
12 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
13 import org
.eclipse
.jface
.wizard
.Wizard
;
14 import org
.eclipse
.swt
.widgets
.Display
;
16 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
17 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
18 import eu
.etaxonomy
.cdm
.persistence
.hibernate
.CdmDataChangeMap
;
19 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
20 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
24 * @created Jun 1, 2010
26 public abstract class AbstractNewEntityWizard
<T
>
28 implements IConversationEnabled
{
30 protected ConversationHolder conversation
;
32 protected CdmFormFactory formFactory
;
36 protected IStructuredSelection selection
;
38 public AbstractNewEntityWizard(){
39 setWindowTitle(String
.format("New %s", getEntityName()));
43 * FIXME there might be a smarter way to do this,
45 protected abstract String
getEntityName();
48 public boolean performFinish() {
51 conversation
.commit();
57 public T
getEntity() {
61 public void setEntity(T entity
){
66 * Adds the entity to the current persistence context
68 protected abstract void saveEntity();
70 public void init(IWorkbench workbench
, IStructuredSelection selection
) {
71 formFactory
= new CdmFormFactory(Display
.getCurrent(), null);
72 conversation
= CdmStore
.createConversation();
73 this.selection
= selection
;
74 entity
= createNewEntity();
78 protected abstract T
createNewEntity();
81 public ConversationHolder
getConversationHolder() {
86 public void update(CdmDataChangeMap changeEvents
) {}
88 public IStructuredSelection
getSelection() {