2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.preference
.wizard
;
13 import org
.eclipse
.jface
.wizard
.WizardPage
;
14 import org
.eclipse
.swt
.SWT
;
15 import org
.eclipse
.swt
.custom
.CLabel
;
16 import org
.eclipse
.swt
.events
.ModifyEvent
;
17 import org
.eclipse
.swt
.events
.ModifyListener
;
18 import org
.eclipse
.swt
.layout
.GridData
;
19 import org
.eclipse
.swt
.layout
.GridLayout
;
20 import org
.eclipse
.swt
.widgets
.Composite
;
21 import org
.eclipse
.swt
.widgets
.Text
;
23 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
24 import eu
.etaxonomy
.cdm
.model
.common
.DefinedTermBase
;
25 import eu
.etaxonomy
.cdm
.model
.common
.Representation
;
28 * <p>VocabularyTermWizardPage class.</p>
34 public class VocabularyTermWizardPage
<T
extends DefinedTermBase
> extends WizardPage
implements ModifyListener
{
36 private Text text_label
;
37 private Text text_labelAbbreviation
;
38 private Text text_description
;
41 * <p>Constructor for VocabularyTermWizardPage.</p>
43 public VocabularyTermWizardPage() {
44 super("VOCABULARY_TERM_WIZARD_PAGE");
48 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
51 public void createControl(Composite parent
) {
53 String termLabel
= getWizard().getTermClass().getSimpleName();
55 String title
= getWizard().isEditMode() ?
"Edit " + termLabel
: "Create new " + termLabel
;
58 Composite composite
= new Composite(parent
, SWT
.NULL
);
59 GridLayout gridLayout
= new GridLayout();
60 gridLayout
.numColumns
= 2;
61 gridLayout
.horizontalSpacing
= SWT
.FILL
;
62 gridLayout
.verticalSpacing
= SWT
.FILL
;
63 composite
.setLayout(gridLayout
);
66 CLabel label_label
= new CLabel(composite
, SWT
.NULL
);
67 label_label
.setText("Label");
69 text_label
= new Text(composite
, SWT
.BORDER
);
70 text_label
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, false));
71 text_label
.addModifyListener(this);
74 CLabel label_labelAbbreviation
= new CLabel(composite
, SWT
.NULL
);
75 label_labelAbbreviation
.setText("Label Abbreviation");
77 text_labelAbbreviation
= new Text(composite
, SWT
.BORDER
);
78 text_labelAbbreviation
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, false));
79 text_labelAbbreviation
.addModifyListener(this);
82 CLabel label_description
= new CLabel(composite
, SWT
.NULL
);
83 label_description
.setText("Description");
84 label_description
.setLayoutData(new GridData(SWT
.TOP
));
86 text_description
= new Text(composite
, SWT
.BORDER
| SWT
.MULTI
);
87 text_description
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true));
88 text_description
.addModifyListener(this);
90 setControl(composite
);
92 if(getWizard().getRepresentation() != null){
93 Representation representation
= getWizard().getRepresentation();
94 text_label
.setText(CdmUtils
.Nz(representation
.getLabel()));
95 text_labelAbbreviation
.setText(CdmUtils
.Nz(representation
.getAbbreviatedLabel()));
96 text_description
.setText(CdmUtils
.Nz(representation
.getDescription()));
99 setPageComplete(false);
104 * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
107 public void modifyText(ModifyEvent e
) {
108 Object eventSource
= e
.getSource();
109 if(eventSource
== text_label
){
110 getWizard().getRepresentation().setLabel(text_label
.getText());
112 else if(eventSource
== text_labelAbbreviation
){
113 getWizard().getRepresentation().setAbbreviatedLabel(text_labelAbbreviation
.getText());
115 else if(eventSource
== text_description
){
116 getWizard().getRepresentation().setText(text_description
.getText());
120 if(text_label
.getText().length() > 0){
121 setPageComplete(true);
124 setPageComplete(false);
129 * @see org.eclipse.jface.wizard.WizardPage#getWizard()
133 public VocabularyTermWizard
getWizard() {
134 return (VocabularyTermWizard
) super.getWizard();