3 * Copyright (C) 2007 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.
11 package eu
.etaxonomy
.taxeditor
.editor
.newWizard
;
13 import org
.apache
.log4j
.Logger
;
14 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
15 import org
.eclipse
.jface
.wizard
.Wizard
;
16 import org
.eclipse
.swt
.widgets
.Display
;
17 import org
.eclipse
.ui
.INewWizard
;
18 import org
.eclipse
.ui
.IWorkbench
;
20 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
21 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
22 import eu
.etaxonomy
.cdm
.model
.common
.IAnnotatableEntity
;
23 import eu
.etaxonomy
.cdm
.persistence
.hibernate
.CdmDataChangeMap
;
24 import eu
.etaxonomy
.taxeditor
.forms
.CdmFormFactory
;
25 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
28 * <p>Abstract AbstractNewEntityWizard class.</p>
31 * @created Jun 1, 2010
34 public abstract class AbstractNewEntityWizard
<T
extends IAnnotatableEntity
> extends Wizard
implements
35 INewWizard
, IConversationEnabled
{
36 private static final Logger logger
= Logger
37 .getLogger(AbstractNewEntityWizard
.class);
39 private ConversationHolder conversation
;
41 protected CdmFormFactory formFactory
;
45 private IWorkbench workbench
;
47 protected IStructuredSelection selection
;
50 * <p>Constructor for AbstractNewEntityWizard.</p>
52 * @param <T> a T object.
54 public AbstractNewEntityWizard(){
55 setWindowTitle("New Entity");
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
;
101 this.selection
= selection
;
102 formFactory
= new CdmFormFactory(Display
.getCurrent(), null);
103 entity
= createNewEntity();
104 conversation
= CdmStore
.createConversation();
108 * <p>createNewEntity</p>
110 * @return a T object.
112 protected abstract T
createNewEntity();
115 * <p>getConversationHolder</p>
117 * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
119 public ConversationHolder
getConversationHolder() {
124 public void update(CdmDataChangeMap changeEvents
) {}