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
.common
.CdmUtils
;
25 import eu
.etaxonomy
.cdm
.model
.common
.DefinedTermBase
;
26 import eu
.etaxonomy
.cdm
.model
.common
.Representation
;
29 * <p>VocabularyTermWizardPage class.</p>
35 public class VocabularyTermWizardPage
<T
extends DefinedTermBase
> extends WizardPage
implements ModifyListener
{
37 private Text text_label
;
38 private Text text_labelAbbreviation
;
39 private Text text_description
;
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().getRepresentation() != null){
94 Representation representation
= getWizard().getRepresentation();
95 text_label
.setText(CdmUtils
.Nz(representation
.getLabel()));
96 text_labelAbbreviation
.setText(CdmUtils
.Nz(representation
.getAbbreviatedLabel()));
97 text_description
.setText(CdmUtils
.Nz(representation
.getDescription()));
100 setPageComplete(false);
105 * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
108 public void modifyText(ModifyEvent e
) {
109 Object eventSource
= e
.getSource();
110 if(eventSource
== text_label
){
111 getWizard().getRepresentation().setLabel(text_label
.getText());
113 else if(eventSource
== text_labelAbbreviation
){
114 getWizard().getRepresentation().setAbbreviatedLabel(text_labelAbbreviation
.getText());
116 else if(eventSource
== text_description
){
117 getWizard().getRepresentation().setText(text_description
.getText());
121 if(text_label
.getText().length() > 0){
122 setPageComplete(true);
125 setPageComplete(false);
130 * @see org.eclipse.jface.wizard.WizardPage#getWizard()
134 public VocabularyTermWizard
getWizard() {
135 return (VocabularyTermWizard
) super.getWizard();