Revision 707b6237
Added by Niels Hoffmann over 12 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ExportToFileDestinationWizardPage.java | ||
---|---|---|
1 | 1 |
// $Id$ |
2 | 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 |
*/ |
|
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 | 10 |
|
11 | 11 |
package eu.etaxonomy.taxeditor.io.wizard; |
12 | 12 |
|
... | ... | |
28 | 28 |
import eu.etaxonomy.taxeditor.datasource.CdmDataSourceRepository; |
29 | 29 |
|
30 | 30 |
/** |
31 |
* <p>ExportToFileDestinationWizardPage class.</p> |
|
32 |
* |
|
31 |
* <p> |
|
32 |
* ExportToFileDestinationWizardPage class. |
|
33 |
* </p> |
|
34 |
* |
|
33 | 35 |
* @author n.hoffmann |
34 | 36 |
* @created 15.06.2009 |
35 | 37 |
* @version 1.0 |
36 | 38 |
*/ |
37 |
public class ExportToFileDestinationWizardPage extends WizardPage{ |
|
39 |
public class ExportToFileDestinationWizardPage extends WizardPage {
|
|
38 | 40 |
|
39 | 41 |
/** Constant <code>DATE_FORMAT_NOW="yyyyMMddHHmm"</code> */ |
40 | 42 |
public static final String DATE_FORMAT_NOW = "yyyyMMddHHmm"; |
41 |
|
|
43 |
|
|
42 | 44 |
/** Constant <code>JAXB_EXPORT="JAXB_EXPORT"</code> */ |
43 | 45 |
public static final String JAXB_EXPORT = "JAXB_EXPORT"; |
44 |
|
|
46 |
|
|
45 | 47 |
/** Constant <code>TCS_EXPORT="TCS_EXPORT"</code> */ |
46 | 48 |
public static final String TCS_EXPORT = "TCS_EXPORT"; |
47 |
|
|
49 |
|
|
48 | 50 |
/** Constant <code>SDD_EXPORT="SDD_EXPORT"</code> */ |
49 |
public static final String SDD_EXPORT = "SDD_EXPORT"; |
|
50 |
|
|
51 |
public static final String SDD_EXPORT = "SDD_EXPORT"; |
|
52 |
|
|
53 |
public static final String DWCA_EXPORT = "DWCA_EXPORT"; |
|
54 |
|
|
55 |
public static final String XML = "xml"; |
|
56 |
|
|
57 |
public static final String ZIP = "zip"; |
|
58 |
|
|
51 | 59 |
private DirectoryDialog folderDialog; |
52 | 60 |
private Text text_exportFileName; |
53 | 61 |
|
54 | 62 |
private Text text_folder; |
55 | 63 |
|
56 |
private String type; |
|
57 |
|
|
58 |
|
|
64 |
private final String type; |
|
65 |
|
|
66 |
private final String extension; |
|
67 |
|
|
59 | 68 |
/** |
60 | 69 |
* @param pageName |
61 | 70 |
* @param selection |
62 | 71 |
*/ |
63 |
private ExportToFileDestinationWizardPage(String pageName, String type, String title, String description) { |
|
72 |
private ExportToFileDestinationWizardPage(String pageName, String type, |
|
73 |
String title, String description, String extension) { |
|
64 | 74 |
super(pageName); |
65 |
|
|
75 |
|
|
66 | 76 |
this.type = type; |
67 |
|
|
77 |
this.extension = extension; |
|
68 | 78 |
this.setTitle(title); |
69 |
this.setDescription("Exports the contents of the currently selected database into the cdm jaxb format.");
|
|
79 |
this.setDescription(description);
|
|
70 | 80 |
} |
71 |
|
|
81 |
|
|
72 | 82 |
/** |
73 |
* <p>Jaxb</p> |
|
74 |
* |
|
75 |
* @return a {@link eu.etaxonomy.taxeditor.io.wizard.ExportToFileDestinationWizardPage} object. |
|
83 |
* <p> |
|
84 |
* Jaxb |
|
85 |
* </p> |
|
86 |
* |
|
87 |
* @return a |
|
88 |
* {@link eu.etaxonomy.taxeditor.io.wizard.ExportToFileDestinationWizardPage} |
|
89 |
* object. |
|
76 | 90 |
*/ |
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."); |
|
91 |
public static ExportToFileDestinationWizardPage Jaxb() { |
|
92 |
return new ExportToFileDestinationWizardPage( |
|
93 |
JAXB_EXPORT, |
|
94 |
"jaxb", |
|
95 |
"JAXB Export", |
|
96 |
"Exports the contents of the currently selected database into the cdm jaxb format.", |
|
97 |
XML); |
|
79 | 98 |
} |
80 |
|
|
99 |
|
|
81 | 100 |
/** |
82 |
* <p>Tcs</p> |
|
83 |
* |
|
84 |
* @return a {@link eu.etaxonomy.taxeditor.io.wizard.ExportToFileDestinationWizardPage} object. |
|
101 |
* <p> |
|
102 |
* Tcs |
|
103 |
* </p> |
|
104 |
* |
|
105 |
* @return a |
|
106 |
* {@link eu.etaxonomy.taxeditor.io.wizard.ExportToFileDestinationWizardPage} |
|
107 |
* object. |
|
85 | 108 |
*/ |
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."); |
|
109 |
public static ExportToFileDestinationWizardPage Tcs() { |
|
110 |
return new ExportToFileDestinationWizardPage( |
|
111 |
TCS_EXPORT, |
|
112 |
"tcs", |
|
113 |
"Tcs Export", |
|
114 |
"Export the contents of the currently selected database into TCS format.", |
|
115 |
XML); |
|
88 | 116 |
} |
89 |
|
|
117 |
|
|
90 | 118 |
/** |
91 |
* <p>Sdd</p> |
|
92 |
* |
|
93 |
* @return a {@link eu.etaxonomy.taxeditor.io.wizard.ExportToFileDestinationWizardPage} object. |
|
119 |
* <p> |
|
120 |
* Sdd |
|
121 |
* </p> |
|
122 |
* |
|
123 |
* @return a |
|
124 |
* {@link eu.etaxonomy.taxeditor.io.wizard.ExportToFileDestinationWizardPage} |
|
125 |
* object. |
|
94 | 126 |
*/ |
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."); |
|
127 |
public static ExportToFileDestinationWizardPage Sdd() { |
|
128 |
return new ExportToFileDestinationWizardPage( |
|
129 |
SDD_EXPORT, |
|
130 |
"sdd", |
|
131 |
"Sdd Export", |
|
132 |
"Export the contents of the currently selected database into SDD format.", |
|
133 |
XML); |
|
97 | 134 |
} |
98 | 135 |
|
136 |
/** |
|
137 |
* @return |
|
138 |
*/ |
|
139 |
public static ExportToFileDestinationWizardPage Dwca() { |
|
140 |
return new ExportToFileDestinationWizardPage( |
|
141 |
DWCA_EXPORT, |
|
142 |
"dwca", |
|
143 |
"DwC-Archive Export", |
|
144 |
"Export the contents of the currently selected database into Darwin Core Archive format.", |
|
145 |
ZIP); |
|
146 |
} |
|
99 | 147 |
|
100 |
/* (non-Javadoc) |
|
101 |
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) |
|
148 |
/* |
|
149 |
* (non-Javadoc) |
|
150 |
* |
|
151 |
* @see |
|
152 |
* org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets |
|
153 |
* .Composite) |
|
102 | 154 |
*/ |
103 | 155 |
/** {@inheritDoc} */ |
104 | 156 |
public void createControl(Composite parent) { |
105 |
|
|
157 |
|
|
106 | 158 |
setPageComplete(false); |
107 |
|
|
159 |
|
|
108 | 160 |
Composite composite = new Composite(parent, SWT.NONE); |
109 | 161 |
GridLayout gridLayout = new GridLayout(); |
110 | 162 |
gridLayout.numColumns = 3; |
111 | 163 |
composite.setLayout(gridLayout); |
112 |
|
|
164 |
|
|
113 | 165 |
Label fileLabel = new Label(composite, SWT.NONE); |
114 | 166 |
fileLabel.setText("File"); |
115 |
|
|
167 |
|
|
116 | 168 |
text_exportFileName = new Text(composite, SWT.BORDER); |
117 | 169 |
text_exportFileName.setText(generateFilename()); |
118 |
text_exportFileName.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
|
|
119 |
|
|
120 |
|
|
170 |
text_exportFileName.setLayoutData(new GridData(SWT.FILL, SWT.FILL, |
|
171 |
true, false, 2, 1)); |
|
172 |
|
|
121 | 173 |
Label folderLabel = new Label(composite, SWT.NONE); |
122 | 174 |
folderLabel.setText("Folder"); |
123 |
|
|
175 |
|
|
124 | 176 |
folderDialog = new DirectoryDialog(parent.getShell()); |
125 |
|
|
177 |
|
|
126 | 178 |
text_folder = new Text(composite, SWT.BORDER); |
127 | 179 |
text_folder.setEditable(false); |
128 |
text_folder.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); |
|
180 |
text_folder.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, |
|
181 |
false)); |
|
129 | 182 |
|
130 |
|
|
131 | 183 |
Button button = new Button(composite, SWT.PUSH); |
132 | 184 |
button.setText("Browse..."); |
133 |
|
|
134 |
button.addSelectionListener(new SelectionAdapter(){ |
|
135 |
/* (non-Javadoc) |
|
136 |
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) |
|
185 |
|
|
186 |
button.addSelectionListener(new SelectionAdapter() { |
|
187 |
/* |
|
188 |
* (non-Javadoc) |
|
189 |
* |
|
190 |
* @see |
|
191 |
* org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse |
|
192 |
* .swt.events.SelectionEvent) |
|
137 | 193 |
*/ |
138 | 194 |
@Override |
139 | 195 |
public void widgetSelected(SelectionEvent e) { |
140 | 196 |
super.widgetSelected(e); |
141 | 197 |
String path = folderDialog.open(); |
142 |
if(path != null){ // a folder was selected
|
|
198 |
if (path != null) { // a folder was selected
|
|
143 | 199 |
text_folder.setText(path); |
144 | 200 |
setPageComplete(true); |
145 | 201 |
} |
146 | 202 |
} |
147 | 203 |
}); |
148 |
|
|
204 |
|
|
149 | 205 |
// make the composite the wizard pages control |
150 | 206 |
setControl(composite); |
151 | 207 |
} |
152 |
|
|
153 |
private String generateFilename(){ |
|
208 |
|
|
209 |
private String generateFilename() {
|
|
154 | 210 |
StringBuffer buffer = new StringBuffer(); |
155 |
|
|
211 |
|
|
156 | 212 |
Calendar cal = Calendar.getInstance(); |
157 |
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
|
|
213 |
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
|
|
158 | 214 |
buffer.append(sdf.format(cal.getTime())); |
159 |
|
|
215 |
|
|
160 | 216 |
buffer.append("-"); |
161 |
|
|
217 |
|
|
162 | 218 |
buffer.append(type + "_export-"); |
163 | 219 |
buffer.append(CdmDataSourceRepository.getCurrentDataSource()); |
164 |
|
|
165 |
buffer.append(".xml"); |
|
166 |
|
|
220 |
|
|
221 |
buffer.append("."); |
|
222 |
buffer.append(extension); |
|
223 |
|
|
167 | 224 |
return buffer.toString(); |
168 | 225 |
} |
169 | 226 |
|
170 |
|
|
171 | 227 |
/** |
172 |
* <p>getExportFileName</p> |
|
173 |
* |
|
228 |
* <p> |
|
229 |
* getExportFileName |
|
230 |
* </p> |
|
231 |
* |
|
174 | 232 |
* @return the exportFileName |
175 | 233 |
*/ |
176 | 234 |
public String getExportFileName() { |
177 | 235 |
return text_exportFileName.getText(); |
178 | 236 |
} |
179 | 237 |
|
180 |
|
|
181 | 238 |
/** |
182 |
* <p>getFolderText</p> |
|
183 |
* |
|
239 |
* <p> |
|
240 |
* getFolderText |
|
241 |
* </p> |
|
242 |
* |
|
184 | 243 |
* @return the folderText |
185 | 244 |
*/ |
186 | 245 |
public String getFolderText() { |
187 | 246 |
return text_folder.getText(); |
188 | 247 |
} |
248 |
|
|
189 | 249 |
} |
Also available in: Unified diff
Merged with trunk