finalizing preferred refactoring
[taxeditor.git] / taxeditor-store / src / main / java / eu / etaxonomy / taxeditor / preference / wizards / FeatureWizardPage.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.IWizard;
15 import org.eclipse.jface.wizard.WizardPage;
16 import org.eclipse.swt.SWT;
17 import org.eclipse.swt.custom.CLabel;
18 import org.eclipse.swt.events.ModifyEvent;
19 import org.eclipse.swt.events.ModifyListener;
20 import org.eclipse.swt.layout.GridData;
21 import org.eclipse.swt.layout.GridLayout;
22 import org.eclipse.swt.widgets.Composite;
23 import org.eclipse.swt.widgets.Text;
24
25 import eu.etaxonomy.cdm.model.description.Feature;
26
27 /**
28 * @author n.hoffmann
29 * @created 12.06.2009
30 * @version 1.0
31 */
32 public class FeatureWizardPage extends WizardPage implements ModifyListener {
33
34 private Text text_label;
35 private Text text_labelAbbreviation;
36 private Text text_description;
37
38
39
40 /**
41 *
42 */
43 public FeatureWizardPage() {
44 super("FEATURE_WIZARD_PAGE");
45 }
46
47 private static final Logger logger = Logger
48 .getLogger(FeatureWizardPage.class);
49
50 /* (non-Javadoc)
51 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
52 */
53 public void createControl(Composite parent) {
54 String title = getWizard().isEditMode() ? "Edit Feature" : "Create new Feature";
55 this.setTitle(title);
56
57 Composite composite = new Composite(parent, SWT.NULL);
58 GridLayout gridLayout = new GridLayout();
59 gridLayout.numColumns = 2;
60 gridLayout.horizontalSpacing = SWT.FILL;
61 gridLayout.verticalSpacing = SWT.FILL;
62 composite.setLayout(gridLayout);
63
64 // label
65 CLabel label_label = new CLabel(composite, SWT.NULL);
66 label_label.setText("Label");
67
68 text_label = new Text(composite, SWT.BORDER);
69 text_label.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
70 text_label.addModifyListener(this);
71
72 // label abbreviation
73 CLabel label_labelAbbreviation = new CLabel(composite, SWT.NULL);
74 label_labelAbbreviation.setText("Label Abbreviation");
75
76 text_labelAbbreviation = new Text(composite, SWT.BORDER);
77 text_labelAbbreviation.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
78 text_labelAbbreviation.addModifyListener(this);
79
80 // descriptive text
81 CLabel label_description = new CLabel(composite, SWT.NULL);
82 label_description.setText("Description");
83 label_description.setLayoutData(new GridData(SWT.TOP));
84
85 text_description = new Text(composite, SWT.BORDER | SWT.MULTI);
86 text_description.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
87 text_description.addModifyListener(this);
88
89 setControl(composite);
90
91 if(getWizard().getFeature() != null){
92 Feature feature = getWizard().getFeature();
93 text_label.setText(feature.getLabel());
94 // why can't we access labelAbbreviation
95 // text_labelAbbreviation.setText(feature.get)
96 // why can't we access the term string?
97 // text_description.setText(feature.getT)
98 }
99 }
100
101
102 /* (non-Javadoc)
103 * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
104 */
105 public void modifyText(ModifyEvent e) {
106 if(text_description.getText().length() > 0 &&
107 text_labelAbbreviation.getText().length() > 0 &&
108 text_label.getText().length() > 0 ){
109 setPageComplete(true);
110 ((FeatureWizard) getWizard()).setFeature(text_description.getText(), text_label.getText(), text_labelAbbreviation.getText());
111 }
112 }
113
114
115 /* (non-Javadoc)
116 * @see org.eclipse.jface.wizard.WizardPage#getWizard()
117 */
118 @Override
119 public FeatureWizard getWizard() {
120 return (FeatureWizard) super.getWizard();
121 }
122
123
124 }