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
.forms
.selection
;
13 import org
.eclipse
.core
.runtime
.IStatus
;
14 import org
.eclipse
.jface
.wizard
.Wizard
;
15 import org
.eclipse
.jface
.wizard
.WizardDialog
;
16 import org
.eclipse
.swt
.events
.SelectionEvent
;
17 import org
.eclipse
.swt
.events
.SelectionListener
;
19 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
20 import eu
.etaxonomy
.cdm
.model
.agent
.Person
;
21 import eu
.etaxonomy
.cdm
.model
.agent
.Team
;
22 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableEntity
;
23 import eu
.etaxonomy
.cdm
.model
.name
.NonViralName
;
24 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnitBase
;
25 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
26 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
27 import eu
.etaxonomy
.taxeditor
.forms
.AbstractCdmEntityWizardPage
;
28 import eu
.etaxonomy
.taxeditor
.forms
.CdmFormFactory
;
29 import eu
.etaxonomy
.taxeditor
.section
.agent
.PersonWizardPage
;
30 import eu
.etaxonomy
.taxeditor
.section
.agent
.TeamWizardPage
;
31 import eu
.etaxonomy
.taxeditor
.section
.name
.NonViralNameWizardPage
;
32 import eu
.etaxonomy
.taxeditor
.section
.occurrence
.DerivedUnitFacadeWizardPage
;
33 import eu
.etaxonomy
.taxeditor
.section
.reference
.ReferenceWizardPage
;
36 * <p>EditFromSelectionWizard class.</p>
39 * @created Jun 1, 2010
42 public class EditFromSelectionWizard
extends Wizard
implements SelectionListener
{
44 private AbstractSelectionElement selectionElement
;
47 AbstractCdmEntityWizardPage page
;
50 * <p>Constructor for EditFromSelectionWizard.</p>
52 * @param selectionElement a {@link eu.etaxonomy.taxeditor.forms.selection.AbstractSelectionElement} object.
54 public EditFromSelectionWizard(AbstractSelectionElement selectionElement
){
55 this.selectionElement
= selectionElement
;
56 this.setWindowTitle("Edit Entity");
61 public void addPages() {
63 CdmFormFactory formFactory
= selectionElement
.getFormFactory();
64 IdentifiableEntity entity
= (IdentifiableEntity
) HibernateProxyHelper
.deproxy(selectionElement
.getEntity());
66 if(entity
instanceof Reference
){
67 page
= new ReferenceWizardPage(formFactory
, selectionElement
.getConversationHolder(), (Reference
) entity
);
69 else if(entity
instanceof Team
){
70 page
= new TeamWizardPage(formFactory
, selectionElement
.getConversationHolder(), (Team
) entity
);
72 else if(entity
instanceof Person
){
73 page
= new PersonWizardPage(formFactory
, selectionElement
.getConversationHolder(), (Person
) entity
);
75 else if(entity
instanceof NonViralName
){
76 page
= new NonViralNameWizardPage(formFactory
, selectionElement
.getConversationHolder(), (NonViralName
) entity
);
78 else if (entity
instanceof DerivedUnitBase
){
79 page
= new DerivedUnitFacadeWizardPage(formFactory
, selectionElement
.getConversationHolder(), (DerivedUnitBase
) entity
);
82 EditorUtil
.warningDialog("Missing interface", this, "No detail element for current selection");
89 * @see org.eclipse.jface.wizard.Wizard#performFinish()
93 public boolean performFinish() {
99 public void widgetSelected(SelectionEvent e
) {
100 WizardDialog dialog
= new WizardDialog(selectionElement
.getShell(), this);
101 if(dialog
.open() == IStatus
.OK
){
102 selectionElement
.updateFromWizard();
107 public void widgetDefaultSelected(SelectionEvent e
) {}