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
.wizard
;
14 import org
.eclipse
.jface
.wizard
.WizardPage
;
15 import org
.eclipse
.swt
.SWT
;
16 import org
.eclipse
.swt
.custom
.CLabel
;
17 import org
.eclipse
.swt
.events
.ModifyEvent
;
18 import org
.eclipse
.swt
.events
.ModifyListener
;
19 import org
.eclipse
.swt
.layout
.GridData
;
20 import org
.eclipse
.swt
.layout
.GridLayout
;
21 import org
.eclipse
.swt
.widgets
.Composite
;
22 import org
.eclipse
.swt
.widgets
.Text
;
24 import eu
.etaxonomy
.cdm
.model
.common
.DefinedTermBase
;
27 * <p>VocabularyTermWizardPage class.</p>
33 public class VocabularyTermWizardPage
<T
extends DefinedTermBase
> extends WizardPage
implements ModifyListener
{
35 private Text text_label
;
36 private Text text_labelAbbreviation
;
37 private Text text_description
;
39 private T term
= null;
42 * <p>Constructor for VocabularyTermWizardPage.</p>
44 public VocabularyTermWizardPage() {
45 super("VOCABULARY_TERM_WIZARD_PAGE");
49 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
52 public void createControl(Composite parent
) {
54 String termLabel
= getWizard().getTermClass().getSimpleName();
56 String title
= getWizard().isEditMode() ?
"Edit " + termLabel
: "Create new " + termLabel
;
59 Composite composite
= new Composite(parent
, SWT
.NULL
);
60 GridLayout gridLayout
= new GridLayout();
61 gridLayout
.numColumns
= 2;
62 gridLayout
.horizontalSpacing
= SWT
.FILL
;
63 gridLayout
.verticalSpacing
= SWT
.FILL
;
64 composite
.setLayout(gridLayout
);
67 CLabel label_label
= new CLabel(composite
, SWT
.NULL
);
68 label_label
.setText("Label");
70 text_label
= new Text(composite
, SWT
.BORDER
);
71 text_label
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, false));
72 text_label
.addModifyListener(this);
75 CLabel label_labelAbbreviation
= new CLabel(composite
, SWT
.NULL
);
76 label_labelAbbreviation
.setText("Label Abbreviation");
78 text_labelAbbreviation
= new Text(composite
, SWT
.BORDER
);
79 text_labelAbbreviation
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, false));
80 text_labelAbbreviation
.addModifyListener(this);
83 CLabel label_description
= new CLabel(composite
, SWT
.NULL
);
84 label_description
.setText("Description");
85 label_description
.setLayoutData(new GridData(SWT
.TOP
));
87 text_description
= new Text(composite
, SWT
.BORDER
| SWT
.MULTI
);
88 text_description
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true));
89 text_description
.addModifyListener(this);
91 setControl(composite
);
93 if(getWizard().getTerm() != null){
94 DefinedTermBase
<T
> term
= getWizard().getTerm();
95 text_label
.setText(term
.getLabel());
96 // why can't we access labelAbbreviation
97 // text_labelAbbreviation.setText(feature.get)
98 // why can't we access the term string?
99 // text_description.setText(feature.getT)
102 setPageComplete(false);
107 * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
110 public void modifyText(ModifyEvent e
) {
111 if(text_label
.getText().length() > 0){
112 setPageComplete(true);
114 getWizard().setTerm(text_description
.getText(), text_label
.getText(), text_labelAbbreviation
.getText());
116 setPageComplete(false);
121 * @see org.eclipse.jface.wizard.WizardPage#getWizard()
125 public VocabularyTermWizard
getWizard() {
126 return (VocabularyTermWizard
) super.getWizard();