p2izing the editor
[taxeditor.git] / eclipseprojects / eu.etaxonomy.taxeditor / src / eu / etaxonomy / taxeditor / propertysheet / type / wizard / TypeDesignationWizard.java
1 /**
2 * Copyright (C) 2009 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
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.
8 */
9
10 package eu.etaxonomy.taxeditor.propertysheet.type.wizard;
11
12 import org.apache.log4j.Logger;
13 import org.eclipse.core.databinding.observable.list.WritableList;
14 import org.eclipse.jface.wizard.Wizard;
15 import org.eclipse.jface.wizard.WizardPage;
16
17 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
18 import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
19 import eu.etaxonomy.taxeditor.model.CdmUtil;
20
21 /**
22 * @author p.ciardelli
23 * @created 13.02.2009
24 * @version 1.0
25 */
26 public class TypeDesignationWizard extends Wizard {
27
28 private static Logger logger = Logger
29 .getLogger(TypeDesignationWizard.class);
30
31 private TypeDesignationBase typeDesignation;
32 private TaxonNameBase name;
33 private WritableList typeDesignationsList;
34
35 private WizardPage chooseTypePage;
36
37 /**
38 * @param typeDesignation
39 * @param typeDesignationsList
40 */
41 public TypeDesignationWizard(TypeDesignationBase typeDesignation, TaxonNameBase name, WritableList typeDesignationsList) {
42
43 this.name = name;
44 // if (typeDesignation == null) {
45 // createEmptyTypeDesignation();
46 // } else {
47 this.typeDesignation = typeDesignation;
48 // }
49 this.typeDesignationsList = typeDesignationsList;
50 }
51
52 /**
53 *
54 */
55 // private void createEmptyTypeDesignation() {
56 // if (CdmUtil.isNameSupraSpecific(name)) {
57 // typeDesignation = new TemporaryNameTypeDesignation();
58 // } else {
59 // typeDesignation = new TemporarySpecimenTypeDesignation();
60 // }
61 // }
62
63 /* (non-Javadoc)
64 * @see org.eclipse.jface.wizard.Wizard#addPages()
65 */
66 public void addPages() {
67
68 // if (typeDesignation instanceof SpecimenTypeDesignation) {
69 // chooseTypePage = new ChooseSpecimenTypeWizardPage((SpecimenTypeDesignation) typeDesignation, name);
70 // }
71 //
72 // if (typeDesignation instanceof NameTypeDesignation) {
73 // chooseTypePage = new ChooseNameTypeWizardPage((NameTypeDesignation) typeDesignation, name);
74 // }
75
76 // if (name.getRank().isHigher(Rank.SPECIES())) {
77 if (CdmUtil.isNameSupraSpecific(name)) {
78 chooseTypePage = new ChooseNameTypeWizardPage(typeDesignation, name, typeDesignationsList);
79 } else {
80 chooseTypePage = new ChooseSpecimenTypeWizardPage(typeDesignation, name, typeDesignationsList);
81 }
82
83 addPage(chooseTypePage);
84 }
85
86 /* (non-Javadoc)
87 * @see org.eclipse.jface.wizard.Wizard#performFinish()
88 */
89 @Override
90 public boolean performFinish() {
91
92 chooseTypePage.setPageComplete(true);
93
94 // Remove then re-add in case any name editing has taken place
95
96 // typeDesignationsList.remove(typeDesignation);
97 // typeDesignationsList.add(typeDesignation);
98
99 return true;
100 }
101 }