Project

General

Profile

Download (4.16 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
4
* http://www.e-taxonomy.eu
5
* 
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.
8
*/
9

    
10
package eu.etaxonomy.taxeditor.preference.wizard;
11

    
12

    
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;
22

    
23
import eu.etaxonomy.cdm.common.CdmUtils;
24
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
25
import eu.etaxonomy.cdm.model.common.Representation;
26

    
27
/**
28
 * <p>VocabularyTermWizardPage class.</p>
29
 *
30
 * @author n.hoffmann
31
 * @created 12.06.2009
32
 * @version 1.0
33
 */
34
public class VocabularyTermWizardPage<T extends DefinedTermBase> extends WizardPage implements ModifyListener {
35

    
36
	private Text text_label;
37
	private Text text_labelAbbreviation;
38
	private Text text_description;
39
	
40
	/**
41
	 * <p>Constructor for VocabularyTermWizardPage.</p>
42
	 */
43
	public VocabularyTermWizardPage() {
44
		super("VOCABULARY_TERM_WIZARD_PAGE");		
45
	}
46

    
47
	/* (non-Javadoc)
48
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
49
	 */
50
	/** {@inheritDoc} */
51
	public void createControl(Composite parent) {
52
		
53
		String termLabel = getWizard().getTermClass().getSimpleName();
54
		
55
		String title = getWizard().isEditMode() ? "Edit " + termLabel : "Create new " + termLabel;
56
		this.setTitle(title);
57
		
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);
64
		
65
		// label
66
		CLabel label_label = new CLabel(composite, SWT.NULL);
67
		label_label.setText("Label");
68
		
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);
72
		
73
		// label abbreviation 
74
		CLabel label_labelAbbreviation = new CLabel(composite, SWT.NULL);
75
		label_labelAbbreviation.setText("Label Abbreviation");
76
		
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);
80
		
81
		// descriptive text
82
		CLabel label_description = new CLabel(composite, SWT.NULL);
83
		label_description.setText("Description");
84
		label_description.setLayoutData(new GridData(SWT.TOP));
85
		
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);
89
		
90
		setControl(composite);
91
		
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()));
97
		}
98
		
99
		setPageComplete(false);
100
	}
101

    
102

    
103
	/* (non-Javadoc)
104
	 * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
105
	 */
106
	/** {@inheritDoc} */
107
	public void modifyText(ModifyEvent e) {
108
		Object eventSource = e.getSource();
109
		if(eventSource == text_label){
110
			getWizard().getRepresentation().setLabel(text_label.getText());
111
		}
112
		else if(eventSource == text_labelAbbreviation){
113
			getWizard().getRepresentation().setAbbreviatedLabel(text_labelAbbreviation.getText());
114
		}
115
		else if(eventSource == text_description){
116
			getWizard().getRepresentation().setText(text_description.getText());
117
		}  
118
		
119
		
120
		if(text_label.getText().length() > 0){
121
			setPageComplete(true);
122
		}
123
		else {
124
			setPageComplete(false);
125
		}
126
	}
127
	
128
	/* (non-Javadoc)
129
	 * @see org.eclipse.jface.wizard.WizardPage#getWizard()
130
	 */
131
	/** {@inheritDoc} */
132
	@Override
133
	public VocabularyTermWizard getWizard() {
134
		return (VocabularyTermWizard) super.getWizard();
135
	}
136
	
137
	
138
}
(14-14/14)