Project

General

Profile

Download (3.22 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.io.wizard;
11

    
12
import org.eclipse.jface.wizard.WizardPage;
13
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.layout.GridData;
15
import org.eclipse.swt.layout.GridLayout;
16
import org.eclipse.swt.widgets.Button;
17
import org.eclipse.swt.widgets.Composite;
18
import org.eclipse.swt.widgets.Event;
19
import org.eclipse.swt.widgets.Label;
20
import org.eclipse.swt.widgets.Listener;
21
import org.eclipse.swt.widgets.Text;
22
import org.eclipse.wb.swt.ResourceManager;
23

    
24
import eu.etaxonomy.cdm.model.taxon.Classification;
25
import eu.etaxonomy.taxeditor.ui.dialog.selection.SelectionDialogFactory;
26

    
27
/**
28
 * <p>ImportFromFileDataSourceWizardPage class.</p>
29
 *
30
 * @author n.hoffmann
31
 * @created 04.08.2009
32
 * @version 1.0
33
 */
34
public class ClassificationChooserWizardPage extends WizardPage implements Listener{
35

    
36
	public static final String PAGE_NAME = "ClassificationChooserWizardPage";
37

    
38
	//classification
39
    private Text textClassification;
40
    private Classification classification;
41
    private Button btnBrowseClassification;
42

    
43
    private Button btnClear;
44

    
45
	protected ClassificationChooserWizardPage(String title, String description) {
46
		super(PAGE_NAME);
47

    
48
		setTitle(title);
49

    
50
		setDescription(description);
51

    
52
	}
53

    
54
	public static ClassificationChooserWizardPage createPage(){
55
		return new ClassificationChooserWizardPage("Configure import destinations", "Note: Selecting no classification will create a default one.");
56
	}
57

    
58

    
59

    
60
	/** {@inheritDoc} */
61
	@Override
62
    public void createControl(Composite parent) {
63
		final Composite composite = new Composite(parent, SWT.NULL);
64

    
65
		GridLayout gridLayout = new GridLayout();
66
		gridLayout.numColumns = 4;
67
		composite.setLayout(gridLayout);
68

    
69
		//classification
70
		Label label = new Label(composite, SWT.NONE);
71
		label.setText("Classification");
72
		textClassification = new Text(composite, SWT.NONE);
73
		textClassification.setEnabled(false);
74
		textClassification.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
75
		btnBrowseClassification = new Button(composite, SWT.NONE);
76
		btnBrowseClassification.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/open.gif"));
77
		btnBrowseClassification.addListener(SWT.Selection, this);
78
		btnClear = new Button(composite, SWT.NONE);
79
		btnClear.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/trash.gif"));
80
		btnClear.addListener(SWT.Selection, this);
81

    
82
		setControl(composite);
83
	}
84

    
85
	@Override
86
	public void handleEvent(Event event) {
87
	    if(event.widget==btnBrowseClassification){
88
	        classification = SelectionDialogFactory.getSelectionFromDialog(Classification.class, getShell(), null, null);
89
	        if(classification!=null){
90
	            textClassification.setText(classification.getTitleCache());
91
	        }
92
	    }
93
	    else if(event.widget==btnClear){
94
	        classification = null;
95
	        textClassification.setText("");
96
	    }
97
	}
98

    
99
    /**
100
     * @return the classification
101
     */
102
    public Classification getClassification() {
103
        return classification;
104
    }
105

    
106
}
(8-8/26)