2f38892db51f07f74ee752d0521722313b4012a9
[taxeditor.git] / taxeditor-store / src / main / java / eu / etaxonomy / taxeditor / preference / wizards / FeatureWizard.java
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.preference.wizards;
12
13 import org.apache.log4j.Logger;
14 import org.eclipse.jface.wizard.Wizard;
15
16 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
17 import eu.etaxonomy.cdm.model.description.Feature;
18 import eu.etaxonomy.taxeditor.store.CdmStore;
19
20 /**
21 * @author n.hoffmann
22 * @created 12.06.2009
23 * @version 1.0
24 */
25 public class FeatureWizard extends Wizard {
26 private static final Logger logger = Logger.getLogger(FeatureWizard.class);
27
28 private Feature feature = null;
29
30 private boolean editMode = false;
31
32 /**
33 *
34 */
35 public FeatureWizard(){}
36
37 /**
38 *
39 * @param selectedFeature
40 */
41 public FeatureWizard(Feature selectedFeature){
42 this.feature = selectedFeature;
43 editMode = true;
44 }
45
46 /* (non-Javadoc)
47 * @see org.eclipse.jface.wizard.Wizard#addPages()
48 */
49 @Override
50 public void addPages() {
51 super.addPages();
52
53 addPage(new FeatureWizardPage());
54 }
55
56 /* (non-Javadoc)
57 * @see org.eclipse.jface.wizard.Wizard#performFinish()
58 */
59 @Override
60 public boolean performFinish() {
61
62 ConversationHolder conversation = CdmStore.NewTransactionalConversation();
63
64 if(editMode){
65 CdmStore.updateFeature(feature);
66 }else{
67 CdmStore.saveFeature(feature);
68 }
69
70 conversation.commit(true);
71
72 return true;
73 }
74
75
76 /**
77 * @param text
78 * @param text2
79 * @param text3
80 */
81 public void setFeature(String term, String label, String labelAbbreviation) {
82 feature = Feature.NewInstance(term, label, labelAbbreviation);
83 }
84
85 /**
86 * @return the feature
87 */
88 public Feature getFeature() {
89 return feature;
90 }
91
92 /**
93 * @return the editMode
94 */
95 public boolean isEditMode() {
96 return editMode;
97 }
98 }