Type module largely complete.
[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.SpecimenTypeDesignation;
18 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
19
20 /**
21 * @author p.ciardelli
22 * @created 13.02.2009
23 * @version 1.0
24 */
25 public class TypeDesignationWizard extends Wizard {
26
27 private static Logger logger = Logger
28 .getLogger(TypeDesignationWizard.class);
29
30 private SpecimenTypeDesignation typeDesignation;
31 private TaxonNameBase name;
32 private WritableList typeDesignationsList;
33
34 public class TemporarySpecimenTypeDesignation extends
35 SpecimenTypeDesignation {
36 TemporarySpecimenTypeDesignation() {
37 super();
38 }
39 }
40
41 private WizardPage chooseNamePage;
42
43 /**
44 * @param typeDesignation
45 * @param typeDesignationsList
46 */
47 public TypeDesignationWizard(SpecimenTypeDesignation typeDesignation, TaxonNameBase name, WritableList typeDesignationsList) {
48
49 this.name = name;
50 if (typeDesignation == null) {
51 createEmptyTypeDesignation();
52 } else {
53 this.typeDesignation = typeDesignation;
54 }
55 this.typeDesignationsList = typeDesignationsList;
56 }
57
58 /**
59 *
60 */
61 private void createEmptyTypeDesignation() {
62 typeDesignation = new TemporarySpecimenTypeDesignation();
63 }
64
65 /* (non-Javadoc)
66 * @see org.eclipse.jface.wizard.Wizard#addPages()
67 */
68 public void addPages() {
69 chooseNamePage = new ChooseTypeDesignationWizardPage(typeDesignation, name);
70 addPage(chooseNamePage);
71 }
72
73 /* (non-Javadoc)
74 * @see org.eclipse.jface.wizard.Wizard#performFinish()
75 */
76 @Override
77 public boolean performFinish() {
78
79 chooseNamePage.setPageComplete(true);
80
81 // Remove then re-add in case any name editing has taken place
82 typeDesignationsList.remove(typeDesignation);
83 typeDesignationsList.add(typeDesignation);
84
85 return true;
86 }
87 }