1 |
13862f35
|
n.hoffmann
|
/**
|
2 |
1531d4fd
|
n.hoffmann
|
* Copyright (C) 2007 EDIT
|
3 |
4b75d033
|
Alexander Oppermann
|
* European Distributed Institute of Taxonomy
|
4 |
1531d4fd
|
n.hoffmann
|
* http://www.e-taxonomy.eu
|
5 |
4b75d033
|
Alexander Oppermann
|
*
|
6 |
dc25caf0
|
Katja Luther
|
* The content of this file are subject to the Mozilla Public License Version 1.1
|
7 |
1531d4fd
|
n.hoffmann
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8 |
|
|
*/
|
9 |
13862f35
|
n.hoffmann
|
|
10 |
|
|
package eu.etaxonomy.taxeditor.io.wizard;
|
11 |
|
|
|
12 |
|
|
import java.text.SimpleDateFormat;
|
13 |
|
|
import java.util.Calendar;
|
14 |
cb53bcb3
|
Katja Luther
|
import java.util.Collections;
|
15 |
|
|
import java.util.Comparator;
|
16 |
4b75d033
|
Alexander Oppermann
|
import java.util.List;
|
17 |
cb53bcb3
|
Katja Luther
|
import java.util.UUID;
|
18 |
13862f35
|
n.hoffmann
|
|
19 |
|
|
import org.eclipse.jface.wizard.WizardPage;
|
20 |
|
|
import org.eclipse.swt.SWT;
|
21 |
bdc0ab8b
|
n.hoffmann
|
import org.eclipse.swt.events.SelectionAdapter;
|
22 |
|
|
import org.eclipse.swt.events.SelectionEvent;
|
23 |
cb53bcb3
|
Katja Luther
|
import org.eclipse.swt.events.SelectionListener;
|
24 |
13862f35
|
n.hoffmann
|
import org.eclipse.swt.layout.GridData;
|
25 |
|
|
import org.eclipse.swt.layout.GridLayout;
|
26 |
|
|
import org.eclipse.swt.widgets.Button;
|
27 |
4b75d033
|
Alexander Oppermann
|
import org.eclipse.swt.widgets.Combo;
|
28 |
13862f35
|
n.hoffmann
|
import org.eclipse.swt.widgets.Composite;
|
29 |
|
|
import org.eclipse.swt.widgets.DirectoryDialog;
|
30 |
10b4eb6d
|
Katja Luther
|
import org.eclipse.swt.widgets.Event;
|
31 |
13862f35
|
n.hoffmann
|
import org.eclipse.swt.widgets.Label;
|
32 |
c56148f4
|
Katja Luther
|
import org.eclipse.swt.widgets.Listener;
|
33 |
13862f35
|
n.hoffmann
|
import org.eclipse.swt.widgets.Text;
|
34 |
|
|
|
35 |
9e34cfb2
|
Katja Luther
|
import eu.etaxonomy.cdm.api.application.CdmApplicationState;
|
36 |
cb53bcb3
|
Katja Luther
|
import eu.etaxonomy.cdm.api.service.IClassificationService;
|
37 |
0b4f079d
|
Katja Luther
|
import eu.etaxonomy.cdm.io.cdmLight.CdmLightExportConfigurator;
|
38 |
|
|
import eu.etaxonomy.cdm.io.common.ExportConfiguratorBase;
|
39 |
|
|
import eu.etaxonomy.cdm.io.csv.caryophyllales.out.CsvNameExportConfigurator;
|
40 |
|
|
import eu.etaxonomy.cdm.io.csv.redlist.demo.CsvDemoExportConfigurator;
|
41 |
|
|
import eu.etaxonomy.cdm.io.dwca.out.DwcaTaxExportConfigurator;
|
42 |
|
|
import eu.etaxonomy.cdm.io.jaxb.JaxbExportConfigurator;
|
43 |
|
|
import eu.etaxonomy.cdm.io.sdd.out.SDDExportConfigurator;
|
44 |
|
|
import eu.etaxonomy.cdm.io.tcsxml.out.TcsXmlExportConfigurator;
|
45 |
4b75d033
|
Alexander Oppermann
|
import eu.etaxonomy.cdm.model.taxon.Classification;
|
46 |
9e34cfb2
|
Katja Luther
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
47 |
13862f35
|
n.hoffmann
|
import eu.etaxonomy.taxeditor.datasource.CdmDataSourceRepository;
|
48 |
0b4f079d
|
Katja Luther
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
49 |
c53a25ad
|
Cherian Mathew
|
import eu.etaxonomy.taxeditor.remoting.source.CdmRemoteSourceException;
|
50 |
4b75d033
|
Alexander Oppermann
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
51 |
13862f35
|
n.hoffmann
|
|
52 |
|
|
/**
|
53 |
1531d4fd
|
n.hoffmann
|
* <p>
|
54 |
|
|
* ExportToFileDestinationWizardPage class.
|
55 |
|
|
* </p>
|
56 |
4b75d033
|
Alexander Oppermann
|
*
|
57 |
13862f35
|
n.hoffmann
|
* @author n.hoffmann
|
58 |
|
|
* @created 15.06.2009
|
59 |
|
|
* @version 1.0
|
60 |
|
|
*/
|
61 |
cb53bcb3
|
Katja Luther
|
public class ExportToFileDestinationWizardPage extends WizardPage implements SelectionListener {
|
62 |
13862f35
|
n.hoffmann
|
|
63 |
3be6ef3e
|
n.hoffmann
|
/** Constant <code>DATE_FORMAT_NOW="yyyyMMddHHmm"</code> */
|
64 |
13862f35
|
n.hoffmann
|
public static final String DATE_FORMAT_NOW = "yyyyMMddHHmm";
|
65 |
1531d4fd
|
n.hoffmann
|
|
66 |
3be6ef3e
|
n.hoffmann
|
/** Constant <code>JAXB_EXPORT="JAXB_EXPORT"</code> */
|
67 |
13862f35
|
n.hoffmann
|
public static final String JAXB_EXPORT = "JAXB_EXPORT";
|
68 |
1531d4fd
|
n.hoffmann
|
|
69 |
3be6ef3e
|
n.hoffmann
|
/** Constant <code>TCS_EXPORT="TCS_EXPORT"</code> */
|
70 |
13862f35
|
n.hoffmann
|
public static final String TCS_EXPORT = "TCS_EXPORT";
|
71 |
1531d4fd
|
n.hoffmann
|
|
72 |
3be6ef3e
|
n.hoffmann
|
/** Constant <code>SDD_EXPORT="SDD_EXPORT"</code> */
|
73 |
1531d4fd
|
n.hoffmann
|
public static final String SDD_EXPORT = "SDD_EXPORT";
|
74 |
|
|
|
75 |
|
|
public static final String DWCA_EXPORT = "DWCA_EXPORT";
|
76 |
e75532a6
|
Katja Luther
|
public static final String OUTPUT_MODEL_EXPORT = "CDM_LIGHT(CSV)";
|
77 |
4b75d033
|
Alexander Oppermann
|
public static final String CSV_EXPORT = "CSV_EXPORT";
|
78 |
43c825ae
|
Katja Luther
|
public static final String CSV_NAME_EXPORT = "CSV_NAME_EXPORT";
|
79 |
e75532a6
|
Katja Luther
|
private static final String CSV_PRINT_EXPORT ="CSV_PRINT_EXPORT";
|
80 |
0b4f079d
|
Katja Luther
|
private static final String EXPORT_FOLDER ="EXPORT_FOLDER";
|
81 |
1531d4fd
|
n.hoffmann
|
public static final String XML = "xml";
|
82 |
|
|
|
83 |
4b75d033
|
Alexander Oppermann
|
public static final String CSV = "csv";
|
84 |
df366db5
|
Katja Luther
|
|
85 |
1531d4fd
|
n.hoffmann
|
public static final String ZIP = "zip";
|
86 |
|
|
|
87 |
e75532a6
|
Katja Luther
|
private boolean csvExport = false;
|
88 |
df366db5
|
Katja Luther
|
|
89 |
e75532a6
|
Katja Luther
|
private boolean csvNameExport = false;
|
90 |
4b75d033
|
Alexander Oppermann
|
|
91 |
e75532a6
|
Katja Luther
|
private boolean csvPrintExport = false;
|
92 |
4b75d033
|
Alexander Oppermann
|
|
93 |
e75532a6
|
Katja Luther
|
private boolean outputModelExport = false;
|
94 |
a05f423c
|
Katja Luther
|
private boolean dwcaExport = false;
|
95 |
f3e1e1fa
|
Katja Luther
|
|
96 |
13862f35
|
n.hoffmann
|
private DirectoryDialog folderDialog;
|
97 |
|
|
private Text text_exportFileName;
|
98 |
|
|
|
99 |
|
|
private Text text_folder;
|
100 |
|
|
|
101 |
1531d4fd
|
n.hoffmann
|
private final String type;
|
102 |
|
|
|
103 |
|
|
private final String extension;
|
104 |
|
|
|
105 |
cb53bcb3
|
Katja Luther
|
private Combo classificationSelectionCombo;
|
106 |
df366db5
|
Katja Luther
|
|
107 |
cb53bcb3
|
Katja Luther
|
private List<Classification> classifications;
|
108 |
df366db5
|
Katja Luther
|
|
109 |
cb53bcb3
|
Katja Luther
|
private Classification selectedClassification;
|
110 |
10b4eb6d
|
Katja Luther
|
private Label classificationLabel;
|
111 |
d018d823
|
Patrick Plitzner
|
|
112 |
0b4f079d
|
Katja Luther
|
private ExportConfiguratorBase configurator;
|
113 |
10b4eb6d
|
Katja Luther
|
private Button checkUseSelectedtaxonNode;
|
114 |
4b75d033
|
Alexander Oppermann
|
|
115 |
da38b436
|
Katja Luther
|
private Button checkUseSelectedClassification;
|
116 |
|
|
|
117 |
4b75d033
|
Alexander Oppermann
|
protected ExportToFileDestinationWizardPage(String pageName, String type,
|
118 |
0b4f079d
|
Katja Luther
|
String title, String description, String extension, ExportConfiguratorBase configurator) {
|
119 |
13862f35
|
n.hoffmann
|
super(pageName);
|
120 |
0b4f079d
|
Katja Luther
|
this.configurator = configurator;
|
121 |
13862f35
|
n.hoffmann
|
this.type = type;
|
122 |
e75532a6
|
Katja Luther
|
switch(type) {
|
123 |
|
|
case CSV_EXPORT :
|
124 |
|
|
csvExport = true;
|
125 |
|
|
break;
|
126 |
|
|
case CSV_NAME_EXPORT:
|
127 |
|
|
csvNameExport = true;
|
128 |
|
|
break;
|
129 |
|
|
case OUTPUT_MODEL_EXPORT:
|
130 |
|
|
outputModelExport = true;
|
131 |
|
|
break;
|
132 |
|
|
case CSV_PRINT_EXPORT:
|
133 |
|
|
csvPrintExport = true;
|
134 |
|
|
break;
|
135 |
a05f423c
|
Katja Luther
|
case DWCA_EXPORT:
|
136 |
|
|
dwcaExport = true;
|
137 |
|
|
break;
|
138 |
d018d823
|
Patrick Plitzner
|
|
139 |
e75532a6
|
Katja Luther
|
}
|
140 |
1531d4fd
|
n.hoffmann
|
this.extension = extension;
|
141 |
13862f35
|
n.hoffmann
|
this.setTitle(title);
|
142 |
1531d4fd
|
n.hoffmann
|
this.setDescription(description);
|
143 |
13862f35
|
n.hoffmann
|
}
|
144 |
1531d4fd
|
n.hoffmann
|
|
145 |
0b4f079d
|
Katja Luther
|
public static ExportToFileDestinationWizardPage Jaxb(JaxbExportConfigurator configurator) {
|
146 |
1531d4fd
|
n.hoffmann
|
return new ExportToFileDestinationWizardPage(
|
147 |
|
|
JAXB_EXPORT,
|
148 |
|
|
"jaxb",
|
149 |
|
|
"JAXB Export",
|
150 |
dc25caf0
|
Katja Luther
|
"Exports the content of the currently selected database into the cdm jaxb format.",
|
151 |
0b4f079d
|
Katja Luther
|
XML, configurator);
|
152 |
13862f35
|
n.hoffmann
|
}
|
153 |
1531d4fd
|
n.hoffmann
|
|
154 |
0b4f079d
|
Katja Luther
|
public static ExportToFileDestinationWizardPage Tcs(TcsXmlExportConfigurator config) {
|
155 |
1531d4fd
|
n.hoffmann
|
return new ExportToFileDestinationWizardPage(
|
156 |
|
|
TCS_EXPORT,
|
157 |
|
|
"tcs",
|
158 |
|
|
"Tcs Export",
|
159 |
dc25caf0
|
Katja Luther
|
"Export the content of the currently selected database into TCS format.",
|
160 |
0b4f079d
|
Katja Luther
|
XML, config);
|
161 |
13862f35
|
n.hoffmann
|
}
|
162 |
1531d4fd
|
n.hoffmann
|
|
163 |
0b4f079d
|
Katja Luther
|
public static ExportToFileDestinationWizardPage Sdd(SDDExportConfigurator config) {
|
164 |
1531d4fd
|
n.hoffmann
|
return new ExportToFileDestinationWizardPage(
|
165 |
|
|
SDD_EXPORT,
|
166 |
|
|
"sdd",
|
167 |
|
|
"Sdd Export",
|
168 |
dc25caf0
|
Katja Luther
|
"Export the content of the currently selected database into SDD format.",
|
169 |
0b4f079d
|
Katja Luther
|
XML, config);
|
170 |
2d9a13f7
|
n.hoffmann
|
}
|
171 |
13862f35
|
n.hoffmann
|
|
172 |
0b4f079d
|
Katja Luther
|
public static ExportToFileDestinationWizardPage Dwca(DwcaTaxExportConfigurator config) {
|
173 |
1531d4fd
|
n.hoffmann
|
return new ExportToFileDestinationWizardPage(
|
174 |
|
|
DWCA_EXPORT,
|
175 |
e75532a6
|
Katja Luther
|
DWCA_EXPORT,
|
176 |
1531d4fd
|
n.hoffmann
|
"DwC-Archive Export",
|
177 |
dc25caf0
|
Katja Luther
|
"Export the content of the currently selected database into Darwin Core Archive format.",
|
178 |
0b4f079d
|
Katja Luther
|
ZIP, config);
|
179 |
1531d4fd
|
n.hoffmann
|
}
|
180 |
13862f35
|
n.hoffmann
|
|
181 |
0b4f079d
|
Katja Luther
|
public static ExportToFileDestinationWizardPage OutputModel(CdmLightExportConfigurator config) {
|
182 |
d018d823
|
Patrick Plitzner
|
|
183 |
f3e1e1fa
|
Katja Luther
|
return new ExportToFileDestinationWizardPage(
|
184 |
|
|
OUTPUT_MODEL_EXPORT,
|
185 |
e75532a6
|
Katja Luther
|
OUTPUT_MODEL_EXPORT,
|
186 |
72e56518
|
Andreas Müller
|
"CDM Light Export (csv)",
|
187 |
|
|
"Export the content of the currently selected database into the CDM light (csv) format.",
|
188 |
0b4f079d
|
Katja Luther
|
CSV,config);
|
189 |
f3e1e1fa
|
Katja Luther
|
}
|
190 |
4b75d033
|
Alexander Oppermann
|
|
191 |
0b4f079d
|
Katja Luther
|
public static ExportToFileDestinationWizardPage Csv(CsvDemoExportConfigurator config) {
|
192 |
d018d823
|
Patrick Plitzner
|
|
193 |
4b75d033
|
Alexander Oppermann
|
return new ExportToFileDestinationWizardPage(
|
194 |
|
|
CSV_EXPORT,
|
195 |
e75532a6
|
Katja Luther
|
CSV_EXPORT,
|
196 |
4b75d033
|
Alexander Oppermann
|
"CSV Export",
|
197 |
dc25caf0
|
Katja Luther
|
"Export the content of the currently selected database into Comma Separated Value format.",
|
198 |
0b4f079d
|
Katja Luther
|
CSV, config);
|
199 |
4b75d033
|
Alexander Oppermann
|
}
|
200 |
df366db5
|
Katja Luther
|
|
201 |
0b4f079d
|
Katja Luther
|
public static ExportToFileDestinationWizardPage CsvNames(CsvNameExportConfigurator config) {
|
202 |
d018d823
|
Patrick Plitzner
|
|
203 |
43c825ae
|
Katja Luther
|
return new ExportToFileDestinationWizardPage(
|
204 |
|
|
CSV_NAME_EXPORT,
|
205 |
e75532a6
|
Katja Luther
|
CSV_NAME_EXPORT,
|
206 |
43c825ae
|
Katja Luther
|
"CSV Name Export",
|
207 |
|
|
"Export the names of the currently selected database into Semicolon Separated Value format.",
|
208 |
0b4f079d
|
Katja Luther
|
CSV, config);
|
209 |
43c825ae
|
Katja Luther
|
}
|
210 |
df366db5
|
Katja Luther
|
|
211 |
0b4f079d
|
Katja Luther
|
public static ExportToFileDestinationWizardPage CsvPrint(CsvNameExportConfigurator config) {
|
212 |
d018d823
|
Patrick Plitzner
|
|
213 |
f2c1e4b7
|
Katja Luther
|
return new ExportToFileDestinationWizardPage(
|
214 |
|
|
CSV_PRINT_EXPORT,
|
215 |
e75532a6
|
Katja Luther
|
CSV_NAME_EXPORT,
|
216 |
f2c1e4b7
|
Katja Luther
|
"CSV Print Export",
|
217 |
|
|
"Export the content of the currently selected database into Semicolon Separated Value format.",
|
218 |
0b4f079d
|
Katja Luther
|
CSV, config);
|
219 |
f2c1e4b7
|
Katja Luther
|
}
|
220 |
4b75d033
|
Alexander Oppermann
|
|
221 |
3be6ef3e
|
n.hoffmann
|
/** {@inheritDoc} */
|
222 |
4b75d033
|
Alexander Oppermann
|
@Override
|
223 |
|
|
public void createControl(Composite parent) {
|
224 |
1531d4fd
|
n.hoffmann
|
|
225 |
13862f35
|
n.hoffmann
|
setPageComplete(false);
|
226 |
1531d4fd
|
n.hoffmann
|
|
227 |
13862f35
|
n.hoffmann
|
Composite composite = new Composite(parent, SWT.NONE);
|
228 |
|
|
GridLayout gridLayout = new GridLayout();
|
229 |
d018d823
|
Patrick Plitzner
|
|
230 |
e75532a6
|
Katja Luther
|
gridLayout.numColumns = 2;
|
231 |
ae455253
|
Katja Luther
|
TaxonNode node = null;
|
232 |
d018d823
|
Patrick Plitzner
|
|
233 |
13862f35
|
n.hoffmann
|
composite.setLayout(gridLayout);
|
234 |
cb53bcb3
|
Katja Luther
|
if(classifications == null){
|
235 |
|
|
classifications = CdmStore.getService(IClassificationService.class).list(null, null, null, null, null);
|
236 |
|
|
Collections.sort(classifications, new Comparator<Classification>() {
|
237 |
|
|
|
238 |
|
|
@Override
|
239 |
|
|
public int compare(Classification o1, Classification o2) {
|
240 |
df366db5
|
Katja Luther
|
if (o1.equals(o2)){
|
241 |
|
|
return 0;
|
242 |
|
|
}
|
243 |
|
|
int result = o1.getTitleCache().compareTo(o2.getTitleCache());
|
244 |
|
|
if (result == 0){
|
245 |
|
|
return o1.getUuid().compareTo(o2.getUuid());
|
246 |
|
|
}
|
247 |
|
|
return result;
|
248 |
cb53bcb3
|
Katja Luther
|
}
|
249 |
|
|
});
|
250 |
dc25caf0
|
Katja Luther
|
if (!configurator.getTaxonNodeFilter().getClassificationFilter().isEmpty()){
|
251 |
|
|
selectedClassification = CdmStore.getService(IClassificationService.class).load(configurator.getTaxonNodeFilter().getClassificationFilter().get(0).getUuid());
|
252 |
|
|
}else{
|
253 |
d018d823
|
Patrick Plitzner
|
|
254 |
dc25caf0
|
Katja Luther
|
selectedClassification = classifications.iterator().next();
|
255 |
|
|
}
|
256 |
cb53bcb3
|
Katja Luther
|
}
|
257 |
1531d4fd
|
n.hoffmann
|
|
258 |
4b75d033
|
Alexander Oppermann
|
|
259 |
a05f423c
|
Katja Luther
|
if(csvExport || csvPrintExport || outputModelExport|| csvNameExport || dwcaExport){
|
260 |
|
|
if ((outputModelExport || dwcaExport)&& !configurator.getTaxonNodeFilter().getSubtreeFilter().isEmpty()){
|
261 |
da38b436
|
Katja Luther
|
Composite selectNodeOrClassification = new Composite(composite, SWT.NONE);
|
262 |
|
|
GridLayout grid = new GridLayout();
|
263 |
|
|
grid.numColumns = 1;
|
264 |
|
|
selectNodeOrClassification.setLayout(grid);
|
265 |
|
|
checkUseSelectedtaxonNode= new Button(selectNodeOrClassification, SWT.RADIO);
|
266 |
|
|
String taxonStr = "";
|
267 |
ae455253
|
Katja Luther
|
node = CdmApplicationState.getCurrentAppConfig().getTaxonNodeService().load(configurator.getTaxonNodeFilter().getSubtreeFilter().get(0).getUuid());
|
268 |
da38b436
|
Katja Luther
|
if (node.hasTaxon()){
|
269 |
|
|
taxonStr = node.getTaxon().getName().getTitleCache();
|
270 |
|
|
}
|
271 |
|
|
checkUseSelectedtaxonNode.setText("Export selected subtree ("+ taxonStr+")");
|
272 |
|
|
checkUseSelectedtaxonNode.addListener(SWT.Selection, new Listener() {
|
273 |
|
|
@Override
|
274 |
|
|
public void handleEvent(Event e) {
|
275 |
|
|
Button b = (Button) e.widget;
|
276 |
|
|
GridData data = (GridData) classificationSelectionCombo.getLayoutData();
|
277 |
|
|
data.exclude = b.getSelection();
|
278 |
|
|
classificationSelectionCombo.setVisible(!data.exclude);
|
279 |
|
|
classificationLabel.setVisible(!data.exclude);
|
280 |
|
|
}
|
281 |
|
|
});
|
282 |
dc25caf0
|
Katja Luther
|
checkUseSelectedtaxonNode.setSelection(true);
|
283 |
da38b436
|
Katja Luther
|
checkUseSelectedClassification= new Button(selectNodeOrClassification, SWT.RADIO);
|
284 |
7293cf0b
|
Andreas Müller
|
checkUseSelectedClassification.setText("Export complete classification");
|
285 |
da38b436
|
Katja Luther
|
checkUseSelectedClassification.addListener(SWT.Selection, new Listener() {
|
286 |
10b4eb6d
|
Katja Luther
|
@Override
|
287 |
da38b436
|
Katja Luther
|
public void handleEvent(Event e) {
|
288 |
|
|
Button b = (Button) e.widget;
|
289 |
10b4eb6d
|
Katja Luther
|
GridData data = (GridData) classificationSelectionCombo.getLayoutData();
|
290 |
|
|
data.exclude = b.getSelection();
|
291 |
da38b436
|
Katja Luther
|
classificationSelectionCombo.setVisible(data.exclude);
|
292 |
|
|
classificationLabel.setVisible(data.exclude);
|
293 |
|
|
}
|
294 |
|
|
});
|
295 |
10b4eb6d
|
Katja Luther
|
}
|
296 |
ae455253
|
Katja Luther
|
if (node!= null){
|
297 |
|
|
selectedClassification = node.getClassification();
|
298 |
|
|
}
|
299 |
10b4eb6d
|
Katja Luther
|
createClassificationSelectionCombo(composite);
|
300 |
d018d823
|
Patrick Plitzner
|
|
301 |
10b4eb6d
|
Katja Luther
|
classificationSelectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL,
|
302 |
|
|
true, false, 2, 1));
|
303 |
363dd7cb
|
Katja Luther
|
if (checkUseSelectedtaxonNode != null){
|
304 |
d018d823
|
Patrick Plitzner
|
|
305 |
363dd7cb
|
Katja Luther
|
if (checkUseSelectedtaxonNode.getSelection()){
|
306 |
|
|
classificationSelectionCombo.setVisible(false);
|
307 |
|
|
classificationLabel.setVisible(false);
|
308 |
|
|
}
|
309 |
a73cb995
|
Katja Luther
|
}
|
310 |
d018d823
|
Patrick Plitzner
|
|
311 |
4b75d033
|
Alexander Oppermann
|
}
|
312 |
1531d4fd
|
n.hoffmann
|
|
313 |
13862f35
|
n.hoffmann
|
Label folderLabel = new Label(composite, SWT.NONE);
|
314 |
e75532a6
|
Katja Luther
|
folderLabel.setText("Select Folder for exported files");
|
315 |
|
|
folderLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL,
|
316 |
|
|
true, false, 2, 1));
|
317 |
13862f35
|
n.hoffmann
|
folderDialog = new DirectoryDialog(parent.getShell());
|
318 |
2cbfc2bf
|
Katja Luther
|
folderDialog.setFilterPath(PreferencesUtil.getPreferenceStore().getString(EXPORT_FOLDER));
|
319 |
1531d4fd
|
n.hoffmann
|
|
320 |
13862f35
|
n.hoffmann
|
text_folder = new Text(composite, SWT.BORDER);
|
321 |
|
|
text_folder.setEditable(false);
|
322 |
1531d4fd
|
n.hoffmann
|
text_folder.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
|
323 |
|
|
false));
|
324 |
0b4f079d
|
Katja Luther
|
if (PreferencesUtil.getPreferenceStore().getString(EXPORT_FOLDER) != null){
|
325 |
|
|
text_folder.setText(PreferencesUtil.getPreferenceStore().getString(EXPORT_FOLDER));
|
326 |
|
|
setPageComplete(true);
|
327 |
|
|
}
|
328 |
13862f35
|
n.hoffmann
|
|
329 |
|
|
Button button = new Button(composite, SWT.PUSH);
|
330 |
|
|
button.setText("Browse...");
|
331 |
1531d4fd
|
n.hoffmann
|
|
332 |
|
|
button.addSelectionListener(new SelectionAdapter() {
|
333 |
13862f35
|
n.hoffmann
|
@Override
|
334 |
bdc0ab8b
|
n.hoffmann
|
public void widgetSelected(SelectionEvent e) {
|
335 |
|
|
super.widgetSelected(e);
|
336 |
2cbfc2bf
|
Katja Luther
|
|
337 |
13862f35
|
n.hoffmann
|
String path = folderDialog.open();
|
338 |
1531d4fd
|
n.hoffmann
|
if (path != null) { // a folder was selected
|
339 |
bdc0ab8b
|
n.hoffmann
|
text_folder.setText(path);
|
340 |
0b4f079d
|
Katja Luther
|
PreferencesUtil.getPreferenceStore().setValue(EXPORT_FOLDER, path);
|
341 |
bdc0ab8b
|
n.hoffmann
|
setPageComplete(true);
|
342 |
|
|
}
|
343 |
13862f35
|
n.hoffmann
|
}
|
344 |
|
|
});
|
345 |
36d9312d
|
Katja Luther
|
if (!outputModelExport){
|
346 |
d018d823
|
Patrick Plitzner
|
|
347 |
2cbfc2bf
|
Katja Luther
|
Label fileLabel = new Label(composite, SWT.NONE);
|
348 |
|
|
fileLabel.setText("File");
|
349 |
|
|
text_exportFileName = new Text(composite, SWT.BORDER);
|
350 |
|
|
text_exportFileName.setText(generateFilename());
|
351 |
|
|
text_exportFileName.setLayoutData(new GridData(SWT.FILL, SWT.FILL,
|
352 |
|
|
true, false));
|
353 |
|
|
}
|
354 |
13862f35
|
n.hoffmann
|
// make the composite the wizard pages control
|
355 |
|
|
setControl(composite);
|
356 |
|
|
}
|
357 |
1531d4fd
|
n.hoffmann
|
|
358 |
4b75d033
|
Alexander Oppermann
|
protected String generateFilename() {
|
359 |
13862f35
|
n.hoffmann
|
StringBuffer buffer = new StringBuffer();
|
360 |
1531d4fd
|
n.hoffmann
|
|
361 |
13862f35
|
n.hoffmann
|
Calendar cal = Calendar.getInstance();
|
362 |
1531d4fd
|
n.hoffmann
|
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
|
363 |
13862f35
|
n.hoffmann
|
buffer.append(sdf.format(cal.getTime()));
|
364 |
1531d4fd
|
n.hoffmann
|
|
365 |
13862f35
|
n.hoffmann
|
buffer.append("-");
|
366 |
1531d4fd
|
n.hoffmann
|
|
367 |
13862f35
|
n.hoffmann
|
buffer.append(type + "_export-");
|
368 |
3001881c
|
Cherian Mathew
|
try {
|
369 |
|
|
buffer.append(CdmDataSourceRepository.getCurrentCdmSource());
|
370 |
|
|
} catch (CdmRemoteSourceException e) {
|
371 |
|
|
buffer.append("Unknown");
|
372 |
|
|
}
|
373 |
1531d4fd
|
n.hoffmann
|
|
374 |
|
|
buffer.append(".");
|
375 |
|
|
buffer.append(extension);
|
376 |
|
|
|
377 |
13862f35
|
n.hoffmann
|
return buffer.toString();
|
378 |
|
|
}
|
379 |
|
|
|
380 |
|
|
public String getExportFileName() {
|
381 |
|
|
return text_exportFileName.getText();
|
382 |
|
|
}
|
383 |
|
|
|
384 |
|
|
public String getFolderText() {
|
385 |
|
|
return text_folder.getText();
|
386 |
|
|
}
|
387 |
d018d823
|
Patrick Plitzner
|
|
388 |
c56148f4
|
Katja Luther
|
public Text getFolderComposite() {
|
389 |
|
|
return text_folder;
|
390 |
|
|
}
|
391 |
1531d4fd
|
n.hoffmann
|
|
392 |
e75532a6
|
Katja Luther
|
private void createClassificationSelectionCombo(Composite parent){
|
393 |
4b75d033
|
Alexander Oppermann
|
|
394 |
10b4eb6d
|
Katja Luther
|
Composite classificationSelection = new Composite(parent, SWT.NULL);
|
395 |
|
|
classificationSelection.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
|
396 |
4b75d033
|
Alexander Oppermann
|
|
397 |
10b4eb6d
|
Katja Luther
|
GridLayout layout = new GridLayout();
|
398 |
|
|
classificationSelection.setLayout(layout);
|
399 |
4b75d033
|
Alexander Oppermann
|
|
400 |
10b4eb6d
|
Katja Luther
|
classificationLabel = new Label(classificationSelection, SWT.NULL);
|
401 |
cb53bcb3
|
Katja Luther
|
// TODO not working is not really true but leave it here to remind everyone that this is under construction
|
402 |
90e1bc8c
|
Katja Luther
|
classificationLabel.setText("Export complete classification");
|
403 |
d018d823
|
Patrick Plitzner
|
|
404 |
10b4eb6d
|
Katja Luther
|
classificationSelectionCombo = new Combo(classificationSelection, SWT.BORDER | SWT.READ_ONLY);
|
405 |
e75532a6
|
Katja Luther
|
classificationSelectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true, 2,1));
|
406 |
cb53bcb3
|
Katja Luther
|
|
407 |
|
|
for(Classification tree : classifications){
|
408 |
|
|
classificationSelectionCombo.add(tree.getName().getText(), classifications.indexOf(tree));
|
409 |
|
|
|
410 |
|
|
}
|
411 |
4b75d033
|
Alexander Oppermann
|
|
412 |
cb53bcb3
|
Katja Luther
|
classificationSelectionCombo.select(classifications.indexOf(selectedClassification));
|
413 |
|
|
|
414 |
|
|
// TODO remember last selection
|
415 |
|
|
classificationSelectionCombo.addSelectionListener(this);
|
416 |
|
|
|
417 |
|
|
|
418 |
|
|
|
419 |
e75532a6
|
Katja Luther
|
//return classificationSelection;
|
420 |
4b75d033
|
Alexander Oppermann
|
}
|
421 |
|
|
|
422 |
|
|
public Combo getCombo(){
|
423 |
cb53bcb3
|
Katja Luther
|
return classificationSelectionCombo;
|
424 |
|
|
}
|
425 |
|
|
|
426 |
|
|
@Override
|
427 |
|
|
public void widgetSelected(SelectionEvent e) {
|
428 |
|
|
selectedClassification = classifications.get(classificationSelectionCombo.getSelectionIndex());
|
429 |
df366db5
|
Katja Luther
|
|
430 |
cb53bcb3
|
Katja Luther
|
}
|
431 |
|
|
|
432 |
|
|
@Override
|
433 |
|
|
public void widgetDefaultSelected(SelectionEvent e) {
|
434 |
|
|
//not needed here
|
435 |
df366db5
|
Katja Luther
|
|
436 |
cb53bcb3
|
Katja Luther
|
}
|
437 |
|
|
|
438 |
|
|
public UUID getSelectedClassificationUUID() {
|
439 |
df366db5
|
Katja Luther
|
|
440 |
cb53bcb3
|
Katja Luther
|
return selectedClassification.getUuid();
|
441 |
4b75d033
|
Alexander Oppermann
|
}
|
442 |
10b4eb6d
|
Katja Luther
|
|
443 |
|
|
public boolean getCheckUseSelectedTaxonNode() {
|
444 |
6ae3a6b2
|
Katja Luther
|
if (checkUseSelectedtaxonNode== null){
|
445 |
|
|
return false;
|
446 |
|
|
}
|
447 |
10b4eb6d
|
Katja Luther
|
return checkUseSelectedtaxonNode.getSelection();
|
448 |
|
|
}
|
449 |
|
|
|
450 |
fe505329
|
Katja Luther
|
@Override
|
451 |
|
|
public boolean canFlipToNextPage() {
|
452 |
|
|
return getFolderText() != null;
|
453 |
|
|
}
|
454 |
4b75d033
|
Alexander Oppermann
|
|
455 |
13862f35
|
n.hoffmann
|
}
|