Project

General

Profile

Download (3.8 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.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
    private Text textClassification;
40
    private Classification classification;
41
    private Button btnBrowseClassification;
42

    
43
    private Button btnClear;
44

    
45
	/**
46
	 * <p>Constructor for ImportFromFileDataSourceWizardPage.</p>
47
	 *
48
	 * @param title a {@link java.lang.String} object.
49
	 * @param description a {@link java.lang.String} object.
50
	 * @param extensions an array of {@link java.lang.String} objects.
51
	 */
52
	protected ClassificationChooserWizardPage(String title, String description) {
53
		super(PAGE_NAME);
54

    
55
		setTitle(title);
56

    
57
		setDescription(description);
58

    
59
	}
60

    
61
	/**
62
	 * <p>XML</p>
63
	 *
64
	 * @return a {@link eu.etaxonomy.taxeditor.io.wizard.ClassificationChooserWizardPage} object.
65
	 */
66
	protected static ClassificationChooserWizardPage createPage(){
67
		return new ClassificationChooserWizardPage("Choose Classification", "Selecting no classification will create a default one.");
68
	}
69

    
70

    
71

    
72
	/* (non-Javadoc)
73
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
74
	 */
75
	/** {@inheritDoc} */
76
	@Override
77
    public void createControl(Composite parent) {
78
		final Composite composite = new Composite(parent, SWT.NULL);
79

    
80
		setPageComplete(false);
81

    
82
		GridLayout gridLayout = new GridLayout();
83
		gridLayout.numColumns = 4;
84
		composite.setLayout(gridLayout);
85

    
86
		Label label = new Label(composite, SWT.NONE);
87
		label.setText("Classification");
88
		textClassification = new Text(composite, SWT.NONE);
89
		textClassification.setEnabled(false);
90
		textClassification.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
91
		btnBrowseClassification = new Button(composite, SWT.NONE);
92
		btnBrowseClassification.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/open.gif"));
93
		btnBrowseClassification.addListener(SWT.Selection, this);
94
		btnClear = new Button(composite, SWT.NONE);
95
		btnClear.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/trash.gif"));
96
		btnClear.addListener(SWT.Selection, this);
97

    
98
		setControl(composite);
99
	}
100

    
101
	/* (non-Javadoc)
102
	 * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
103
	 */
104
	@Override
105
	public void handleEvent(Event event) {
106
	    if(event.widget==btnBrowseClassification){
107
	        classification = SelectionDialogFactory.getSelectionFromDialog(Classification.class, getShell(), null, null);
108
	        if(classification!=null){
109
	            textClassification.setText(classification.getTitleCache());
110
	        }
111
	    }
112
	    else if(event.widget==btnClear){
113
	        classification = null;
114
	        textClassification.setText("");
115
	    }
116
	}
117

    
118

    
119
    /**
120
     * @return the classification
121
     */
122
    public Classification getClassification() {
123
        return classification;
124
    }
125
}
(6-6/22)