3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.preference
.wizards
;
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
;
25 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
32 public class FeatureWizardPage
extends WizardPage
implements ModifyListener
{
34 private Text text_label
;
35 private Text text_labelAbbreviation
;
36 private Text text_description
;
43 public FeatureWizardPage() {
44 super("FEATURE_WIZARD_PAGE");
47 private static final Logger logger
= Logger
48 .getLogger(FeatureWizardPage
.class);
51 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
53 public void createControl(Composite parent
) {
54 String title
= getWizard().isEditMode() ?
"Edit Feature" : "Create new Feature";
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
);
65 CLabel label_label
= new CLabel(composite
, SWT
.NULL
);
66 label_label
.setText("Label");
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);
73 CLabel label_labelAbbreviation
= new CLabel(composite
, SWT
.NULL
);
74 label_labelAbbreviation
.setText("Label Abbreviation");
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);
81 CLabel label_description
= new CLabel(composite
, SWT
.NULL
);
82 label_description
.setText("Description");
83 label_description
.setLayoutData(new GridData(SWT
.TOP
));
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);
89 setControl(composite
);
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)
103 * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
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());
116 * @see org.eclipse.jface.wizard.WizardPage#getWizard()
119 public FeatureWizard
getWizard() {
120 return (FeatureWizard
) super.getWizard();