Project

General

Profile

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

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

    
13

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

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

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

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

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

    
103

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