3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.io
.wizard
;
16 import org
.eclipse
.jface
.wizard
.WizardPage
;
17 import org
.eclipse
.swt
.SWT
;
18 import org
.eclipse
.swt
.events
.SelectionAdapter
;
19 import org
.eclipse
.swt
.events
.SelectionEvent
;
20 import org
.eclipse
.swt
.layout
.GridData
;
21 import org
.eclipse
.swt
.layout
.GridLayout
;
22 import org
.eclipse
.swt
.widgets
.Button
;
23 import org
.eclipse
.swt
.widgets
.Composite
;
24 import org
.eclipse
.swt
.widgets
.Event
;
25 import org
.eclipse
.swt
.widgets
.FileDialog
;
26 import org
.eclipse
.swt
.widgets
.Label
;
27 import org
.eclipse
.swt
.widgets
.Listener
;
28 import org
.eclipse
.swt
.widgets
.Text
;
29 import org
.eclipse
.wb
.swt
.ResourceManager
;
31 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
32 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
33 import eu
.etaxonomy
.taxeditor
.ui
.dialog
.selection
.SelectionDialogFactory
;
36 * <p>ImportFromFileDataSourceWizardPage class.</p>
42 public class ClassificationChooserWizardPage
extends WizardPage
implements Listener
{
44 public static final String PAGE_NAME
= "ClassificationChooserWizardPage";
47 private Text textClassification
;
48 private Classification classification
;
49 private Button btnBrowseClassification
;
51 private Button btnClear
;
54 private FileDialog fileDialogReport
;
55 private Text textFileReport
;
58 * <p>Constructor for ImportFromFileDataSourceWizardPage.</p>
60 * @param title a {@link java.lang.String} object.
61 * @param description a {@link java.lang.String} object.
62 * @param extensions an array of {@link java.lang.String} objects.
64 protected ClassificationChooserWizardPage(String title
, String description
) {
69 setDescription(description
);
76 * @return a {@link eu.etaxonomy.taxeditor.io.wizard.ClassificationChooserWizardPage} object.
78 protected static ClassificationChooserWizardPage
createPage(){
79 return new ClassificationChooserWizardPage("Configure import destinations", "Note: Selecting no classification will create a default one.");
85 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
89 public void createControl(Composite parent
) {
90 final Composite composite
= new Composite(parent
, SWT
.NULL
);
92 GridLayout gridLayout
= new GridLayout();
93 gridLayout
.numColumns
= 4;
94 composite
.setLayout(gridLayout
);
97 Label label
= new Label(composite
, SWT
.NONE
);
98 label
.setText("Classification");
99 textClassification
= new Text(composite
, SWT
.NONE
);
100 textClassification
.setEnabled(false);
101 textClassification
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
102 btnBrowseClassification
= new Button(composite
, SWT
.NONE
);
103 btnBrowseClassification
.setImage(ResourceManager
.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/open.gif"));
104 btnBrowseClassification
.addListener(SWT
.Selection
, this);
105 btnClear
= new Button(composite
, SWT
.NONE
);
106 btnClear
.setImage(ResourceManager
.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/trash.gif"));
107 btnClear
.addListener(SWT
.Selection
, this);
109 if(!CdmStore
.getCurrentSessionManager().isRemoting()) {
111 Label labelReportFile
= new Label(composite
, SWT
.NONE
);
112 labelReportFile
.setText("Report File");
114 fileDialogReport
= new FileDialog(parent
.getShell());
116 fileDialogReport
.setFilterExtensions(new String
[]{"*.*"});
118 textFileReport
= new Text(composite
, SWT
.BORDER
);
119 textFileReport
.setEditable(false);
120 textFileReport
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false, 2, 1));
123 Button buttonReport
= new Button(composite
, SWT
.PUSH
);
124 buttonReport
.setText("Browse...");
126 buttonReport
.addSelectionListener(new SelectionAdapter(){
129 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
132 public void widgetSelected(SelectionEvent e
) {
133 String path
= fileDialogReport
.open();
135 textFileReport
.setText(path
);
136 setPageComplete(true);
142 setControl(composite
);
146 * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
149 public void handleEvent(Event event
) {
150 if(event
.widget
==btnBrowseClassification
){
151 classification
= SelectionDialogFactory
.getSelectionFromDialog(Classification
.class, getShell(), null, null);
152 if(classification
!=null){
153 textClassification
.setText(classification
.getTitleCache());
156 else if(event
.widget
==btnClear
){
157 classification
= null;
158 textClassification
.setText("");
163 * @return the classification
165 public Classification
getClassification() {
166 return classification
;
169 public URI
getReportUri(){
170 if(textFileReport
== null) {
173 String text
= textFileReport
.getText();
174 if(text
==null || text
.isEmpty()){
177 return new File(text
).toURI();