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.printpublisher.wizard;
|
11
|
|
12
|
import java.io.File;
|
13
|
|
14
|
import org.eclipse.swt.SWT;
|
15
|
import org.eclipse.swt.events.SelectionAdapter;
|
16
|
import org.eclipse.swt.events.SelectionEvent;
|
17
|
import org.eclipse.swt.layout.GridData;
|
18
|
import org.eclipse.swt.layout.GridLayout;
|
19
|
import org.eclipse.swt.widgets.Button;
|
20
|
import org.eclipse.swt.widgets.Composite;
|
21
|
import org.eclipse.swt.widgets.DirectoryDialog;
|
22
|
import org.eclipse.swt.widgets.Label;
|
23
|
import org.eclipse.swt.widgets.Text;
|
24
|
|
25
|
/**
|
26
|
* <p>SelectFolderWizardPage class.</p>
|
27
|
*
|
28
|
* @author n.hoffmann
|
29
|
* @created Apr 7, 2010
|
30
|
* @version 1.0
|
31
|
*/
|
32
|
public class SelectDirectoryWizardPage extends AbstractPublishWizardPage implements IHasPersistableSettings {
|
33
|
private static final String DIALOG_SETTING_OUTPUT_DIRECTORY = "dialogSettingOutputDirectory";
|
34
|
private Composite composite;
|
35
|
private DirectoryDialog folderDialog;
|
36
|
private Text text_folder;
|
37
|
|
38
|
/**
|
39
|
* <p>Constructor for SelectFolderWizardPage.</p>
|
40
|
*
|
41
|
* @param pageName a {@link java.lang.String} object.
|
42
|
*/
|
43
|
public SelectDirectoryWizardPage(String pageName) {
|
44
|
super(pageName);
|
45
|
setTitle("Select a folder");
|
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
|
// configurator = ((IPublishConfigurer) getWizard()).getConfigurator();
|
54
|
|
55
|
composite = new Composite(parent, SWT.NULL);
|
56
|
composite.setLayout(new GridLayout());
|
57
|
|
58
|
Label folderLabel = new Label(composite, SWT.NONE);
|
59
|
folderLabel.setText("Folder");
|
60
|
|
61
|
folderDialog = new DirectoryDialog(parent.getShell());
|
62
|
|
63
|
text_folder = new Text(composite, SWT.BORDER);
|
64
|
text_folder.setEditable(false);
|
65
|
text_folder.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
|
66
|
|
67
|
Button button = new Button(composite, SWT.PUSH);
|
68
|
button.setText("Browse...");
|
69
|
|
70
|
button.addSelectionListener(new SelectionAdapter(){
|
71
|
/* (non-Javadoc)
|
72
|
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
|
73
|
*/
|
74
|
@Override
|
75
|
public void widgetSelected(SelectionEvent e) {
|
76
|
super.widgetSelected(e);
|
77
|
String path = folderDialog.open();
|
78
|
if(path != null){ // a folder was selected
|
79
|
setDirectory(path);
|
80
|
}
|
81
|
}
|
82
|
});
|
83
|
|
84
|
loadSettings();
|
85
|
|
86
|
setControl(composite);
|
87
|
}
|
88
|
|
89
|
@Override
|
90
|
public void loadSettings() {
|
91
|
String directory = getDialogSettingValue(DIALOG_SETTING_OUTPUT_DIRECTORY);
|
92
|
|
93
|
if(directory != null){
|
94
|
setDirectory(directory);
|
95
|
}
|
96
|
}
|
97
|
|
98
|
private void setDirectory(String directory){
|
99
|
text_folder.setText(directory);
|
100
|
getConfigurator().setExportFolder(new File(directory));
|
101
|
|
102
|
putDialogSettingValue(DIALOG_SETTING_OUTPUT_DIRECTORY, directory);
|
103
|
|
104
|
setPageComplete(true);
|
105
|
}
|
106
|
|
107
|
/** {@inheritDoc} */
|
108
|
@Override
|
109
|
public boolean isPageComplete() {
|
110
|
return getConfigurator().getExportFolder() != null;
|
111
|
}
|
112
|
}
|