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
.printpublisher
.wizard
;
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
;
27 * <p>SelectFolderWizardPage class.</p>
30 * @created Apr 7, 2010
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
;
40 * <p>Constructor for SelectFolderWizardPage.</p>
42 * @param pageName a {@link java.lang.String} object.
44 public SelectDirectoryWizardPage(String pageName
) {
46 setTitle("Select a folder");
50 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
53 public void createControl(Composite parent
) {
54 // configurator = ((IPublishConfigurer) getWizard()).getConfigurator();
56 composite
= new Composite(parent
, SWT
.NULL
);
57 composite
.setLayout(new GridLayout());
59 Label folderLabel
= new Label(composite
, SWT
.NONE
);
60 folderLabel
.setText("Folder");
62 folderDialog
= new DirectoryDialog(parent
.getShell());
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));
68 Button button
= new Button(composite
, SWT
.PUSH
);
69 button
.setText("Browse...");
71 button
.addSelectionListener(new SelectionAdapter(){
73 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
76 public void widgetSelected(SelectionEvent e
) {
77 super.widgetSelected(e
);
78 String path
= folderDialog
.open();
79 if(path
!= null){ // a folder was selected
87 setControl(composite
);
91 public void loadSettings() {
92 String directory
= getDialogSettingValue(DIALOG_SETTING_OUTPUT_DIRECTORY
);
94 if(directory
!= null){
95 setDirectory(directory
);
99 private void setDirectory(String directory
){
100 text_folder
.setText(directory
);
101 getConfigurator().setExportFolder(new File(directory
));
103 putDialogSettingValue(DIALOG_SETTING_OUTPUT_DIRECTORY
, directory
);
105 setPageComplete(true);
110 public boolean isPageComplete() {
111 return getConfigurator().getExportFolder() != null;