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
;
13 import java
.text
.SimpleDateFormat
;
14 import java
.util
.Calendar
;
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
.DirectoryDialog
;
25 import org
.eclipse
.swt
.widgets
.Label
;
26 import org
.eclipse
.swt
.widgets
.Text
;
28 import eu
.etaxonomy
.taxeditor
.datasource
.CdmDataSourceRepository
;
31 * <p>ExportToFileDestinationWizardPage class.</p>
37 public class ExportToFileDestinationWizardPage
extends WizardPage
{
39 /** Constant <code>DATE_FORMAT_NOW="yyyyMMddHHmm"</code> */
40 public static final String DATE_FORMAT_NOW
= "yyyyMMddHHmm";
42 /** Constant <code>JAXB_EXPORT="JAXB_EXPORT"</code> */
43 public static final String JAXB_EXPORT
= "JAXB_EXPORT";
45 /** Constant <code>TCS_EXPORT="TCS_EXPORT"</code> */
46 public static final String TCS_EXPORT
= "TCS_EXPORT";
48 /** Constant <code>SDD_EXPORT="SDD_EXPORT"</code> */
49 public static final String SDD_EXPORT
= "SDD_EXPORT";
51 private DirectoryDialog folderDialog
;
52 private Text text_exportFileName
;
54 private Text text_folder
;
63 private ExportToFileDestinationWizardPage(String pageName
, String type
, String title
, String description
) {
69 this.setDescription("Exports the contents of the currently selected database into the cdm jaxb format.");
75 * @return a {@link eu.etaxonomy.taxeditor.io.wizard.ExportToFileDestinationWizardPage} object.
77 public static ExportToFileDestinationWizardPage
Jaxb(){
78 return new ExportToFileDestinationWizardPage(JAXB_EXPORT
, "jaxb", "JAXB Export", "Exports the contents of the currently selected database into the cdm jaxb format.");
84 * @return a {@link eu.etaxonomy.taxeditor.io.wizard.ExportToFileDestinationWizardPage} object.
86 public static ExportToFileDestinationWizardPage
Tcs(){
87 return new ExportToFileDestinationWizardPage(TCS_EXPORT
, "tcs", "Tcs Export", "Export the contents of the currently selected database into TCS format.");
93 * @return a {@link eu.etaxonomy.taxeditor.io.wizard.ExportToFileDestinationWizardPage} object.
95 public static ExportToFileDestinationWizardPage
Sdd(){
96 return new ExportToFileDestinationWizardPage(SDD_EXPORT
, "sdd", "Sdd Export", "Export the contents of the currently selected database into SDD format.");
101 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
104 public void createControl(Composite parent
) {
106 setPageComplete(false);
108 Composite composite
= new Composite(parent
, SWT
.NONE
);
109 GridLayout gridLayout
= new GridLayout();
110 gridLayout
.numColumns
= 3;
111 composite
.setLayout(gridLayout
);
113 Label fileLabel
= new Label(composite
, SWT
.NONE
);
114 fileLabel
.setText("File");
116 text_exportFileName
= new Text(composite
, SWT
.BORDER
);
117 text_exportFileName
.setText(generateFilename());
118 text_exportFileName
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, false, 2, 1));
121 Label folderLabel
= new Label(composite
, SWT
.NONE
);
122 folderLabel
.setText("Folder");
124 folderDialog
= new DirectoryDialog(parent
.getShell());
126 text_folder
= new Text(composite
, SWT
.BORDER
);
127 text_folder
.setEditable(false);
128 text_folder
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
131 Button button
= new Button(composite
, SWT
.PUSH
);
132 button
.setText("Browse...");
134 button
.addSelectionListener(new SelectionAdapter(){
136 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
139 public void widgetSelected(SelectionEvent e
) {
140 super.widgetSelected(e
);
141 String path
= folderDialog
.open();
142 if(path
!= null){ // a folder was selected
143 text_folder
.setText(path
);
144 setPageComplete(true);
149 // make the composite the wizard pages control
150 setControl(composite
);
153 private String
generateFilename(){
154 StringBuffer buffer
= new StringBuffer();
156 Calendar cal
= Calendar
.getInstance();
157 SimpleDateFormat sdf
= new SimpleDateFormat(DATE_FORMAT_NOW
);
158 buffer
.append(sdf
.format(cal
.getTime()));
162 buffer
.append(type
+ "_export-");
163 buffer
.append(CdmDataSourceRepository
.getCurrentDataSource());
165 buffer
.append(".xml");
167 return buffer
.toString();
172 * <p>getExportFileName</p>
174 * @return the exportFileName
176 public String
getExportFileName() {
177 return text_exportFileName
.getText();
182 * <p>getFolderText</p>
184 * @return the folderText
186 public String
getFolderText() {
187 return text_folder
.getText();