performed javacscript:fix and worked on documentation
[taxeditor.git] / taxeditor-printpublisher / src / main / java / eu / etaxonomy / taxeditor / printpublisher / wizard / SelectFolderWizardPage.java
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 SelectFolderWizardPage extends AbstractPublishWizardPage {
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 SelectFolderWizardPage(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 text_folder.setText(path);
80 getConfigurator().setExportFolder(new File(path));
81
82 setPageComplete(true);
83 }
84 }
85 });
86
87 setControl(composite);
88 }
89
90 /** {@inheritDoc} */
91 @Override
92 public boolean canFlipToNextPage() {
93 if(isPageComplete()){
94 OverviewWizardPage overviewPage = (OverviewWizardPage) getNextPage();
95 overviewPage.refresh();
96 return true;
97 }
98 return false;
99 }
100
101 /** {@inheritDoc} */
102 @Override
103 public boolean isPageComplete() {
104 return getConfigurator().getExportFolder() != null;
105 }
106 }