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.io.wizard;
|
12
|
|
13
|
import org.eclipse.jface.wizard.WizardPage;
|
14
|
import org.eclipse.swt.SWT;
|
15
|
import org.eclipse.swt.layout.GridData;
|
16
|
import org.eclipse.swt.layout.GridLayout;
|
17
|
import org.eclipse.swt.widgets.Button;
|
18
|
import org.eclipse.swt.widgets.Composite;
|
19
|
import org.eclipse.swt.widgets.Event;
|
20
|
import org.eclipse.swt.widgets.Label;
|
21
|
import org.eclipse.swt.widgets.Listener;
|
22
|
import org.eclipse.swt.widgets.Text;
|
23
|
import org.eclipse.wb.swt.ResourceManager;
|
24
|
|
25
|
import eu.etaxonomy.cdm.model.taxon.Classification;
|
26
|
import eu.etaxonomy.taxeditor.ui.dialog.selection.SelectionDialogFactory;
|
27
|
|
28
|
/**
|
29
|
* <p>ImportFromFileDataSourceWizardPage class.</p>
|
30
|
*
|
31
|
* @author n.hoffmann
|
32
|
* @created 04.08.2009
|
33
|
* @version 1.0
|
34
|
*/
|
35
|
public class ClassificationChooserWizardPage extends WizardPage implements Listener{
|
36
|
|
37
|
public static final String PAGE_NAME = "ClassificationChooserWizardPage";
|
38
|
|
39
|
//classification
|
40
|
private Text textClassification;
|
41
|
private Classification classification;
|
42
|
private Button btnBrowseClassification;
|
43
|
|
44
|
private Button btnClear;
|
45
|
|
46
|
protected ClassificationChooserWizardPage(String title, String description) {
|
47
|
super(PAGE_NAME);
|
48
|
|
49
|
setTitle(title);
|
50
|
|
51
|
setDescription(description);
|
52
|
|
53
|
}
|
54
|
|
55
|
protected static ClassificationChooserWizardPage createPage(){
|
56
|
return new ClassificationChooserWizardPage("Configure import destinations", "Note: Selecting no classification will create a default one.");
|
57
|
}
|
58
|
|
59
|
|
60
|
|
61
|
/** {@inheritDoc} */
|
62
|
@Override
|
63
|
public void createControl(Composite parent) {
|
64
|
final Composite composite = new Composite(parent, SWT.NULL);
|
65
|
|
66
|
GridLayout gridLayout = new GridLayout();
|
67
|
gridLayout.numColumns = 4;
|
68
|
composite.setLayout(gridLayout);
|
69
|
|
70
|
//classification
|
71
|
Label label = new Label(composite, SWT.NONE);
|
72
|
label.setText("Classification");
|
73
|
textClassification = new Text(composite, SWT.NONE);
|
74
|
textClassification.setEnabled(false);
|
75
|
textClassification.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
|
76
|
btnBrowseClassification = new Button(composite, SWT.NONE);
|
77
|
btnBrowseClassification.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/open.gif"));
|
78
|
btnBrowseClassification.addListener(SWT.Selection, this);
|
79
|
btnClear = new Button(composite, SWT.NONE);
|
80
|
btnClear.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/trash.gif"));
|
81
|
btnClear.addListener(SWT.Selection, this);
|
82
|
|
83
|
setControl(composite);
|
84
|
}
|
85
|
|
86
|
@Override
|
87
|
public void handleEvent(Event event) {
|
88
|
if(event.widget==btnBrowseClassification){
|
89
|
classification = SelectionDialogFactory.getSelectionFromDialog(Classification.class, getShell(), null, null);
|
90
|
if(classification!=null){
|
91
|
textClassification.setText(classification.getTitleCache());
|
92
|
}
|
93
|
}
|
94
|
else if(event.widget==btnClear){
|
95
|
classification = null;
|
96
|
textClassification.setText("");
|
97
|
}
|
98
|
}
|
99
|
|
100
|
/**
|
101
|
* @return the classification
|
102
|
*/
|
103
|
public Classification getClassification() {
|
104
|
return classification;
|
105
|
}
|
106
|
|
107
|
}
|