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