1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
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.
|
9
|
*/
|
10
|
|
11
|
package eu.etaxonomy.taxeditor.forms.selection;
|
12
|
|
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;
|
18
|
|
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;
|
34
|
|
35
|
/**
|
36
|
* <p>EditFromSelectionWizard class.</p>
|
37
|
*
|
38
|
* @author n.hoffmann
|
39
|
* @created Jun 1, 2010
|
40
|
* @version 1.0
|
41
|
*/
|
42
|
public class EditFromSelectionWizard extends Wizard implements SelectionListener {
|
43
|
|
44
|
private AbstractSelectionElement selectionElement;
|
45
|
|
46
|
|
47
|
AbstractCdmEntityWizardPage page;
|
48
|
|
49
|
/**
|
50
|
* <p>Constructor for EditFromSelectionWizard.</p>
|
51
|
*
|
52
|
* @param selectionElement a {@link eu.etaxonomy.taxeditor.forms.selection.AbstractSelectionElement} object.
|
53
|
*/
|
54
|
public EditFromSelectionWizard(AbstractSelectionElement selectionElement){
|
55
|
this.selectionElement = selectionElement;
|
56
|
this.setWindowTitle("Edit Entity");
|
57
|
}
|
58
|
|
59
|
/** {@inheritDoc} */
|
60
|
@Override
|
61
|
public void addPages() {
|
62
|
|
63
|
CdmFormFactory formFactory = selectionElement.getFormFactory();
|
64
|
IdentifiableEntity entity = (IdentifiableEntity) HibernateProxyHelper.deproxy(selectionElement.getEntity());
|
65
|
|
66
|
if(entity instanceof Reference){
|
67
|
page = new ReferenceWizardPage(formFactory, selectionElement.getConversationHolder(), (Reference) entity);
|
68
|
}
|
69
|
else if(entity instanceof Team){
|
70
|
page = new TeamWizardPage(formFactory, selectionElement.getConversationHolder(), (Team) entity);
|
71
|
}
|
72
|
else if(entity instanceof Person){
|
73
|
page = new PersonWizardPage(formFactory, selectionElement.getConversationHolder(), (Person) entity);
|
74
|
}
|
75
|
else if(entity instanceof NonViralName){
|
76
|
page = new NonViralNameWizardPage(formFactory, selectionElement.getConversationHolder(), (NonViralName) entity);
|
77
|
}
|
78
|
else if (entity instanceof DerivedUnitBase){
|
79
|
page = new DerivedUnitFacadeWizardPage(formFactory, selectionElement.getConversationHolder(), (DerivedUnitBase) entity);
|
80
|
}
|
81
|
else{
|
82
|
EditorUtil.warningDialog("Missing interface", this, "No detail element for current selection");
|
83
|
}
|
84
|
|
85
|
addPage(page);
|
86
|
}
|
87
|
|
88
|
/* (non-Javadoc)
|
89
|
* @see org.eclipse.jface.wizard.Wizard#performFinish()
|
90
|
*/
|
91
|
/** {@inheritDoc} */
|
92
|
@Override
|
93
|
public boolean performFinish() {
|
94
|
page.dispose();
|
95
|
return true;
|
96
|
}
|
97
|
|
98
|
/** {@inheritDoc} */
|
99
|
public void widgetSelected(SelectionEvent e) {
|
100
|
WizardDialog dialog = new WizardDialog(selectionElement.getShell(), this);
|
101
|
if(dialog.open() == IStatus.OK){
|
102
|
selectionElement.updateFromWizard();
|
103
|
}
|
104
|
}
|
105
|
|
106
|
/** {@inheritDoc} */
|
107
|
public void widgetDefaultSelected(SelectionEvent e) {}
|
108
|
}
|