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.singlesource.io.wizard;
|
12
|
|
13
|
import java.text.SimpleDateFormat;
|
14
|
import java.util.Calendar;
|
15
|
|
16
|
import javax.naming.OperationNotSupportedException;
|
17
|
|
18
|
import org.apache.log4j.Logger;
|
19
|
import org.eclipse.jface.wizard.WizardPage;
|
20
|
import org.eclipse.swt.widgets.Composite;
|
21
|
import org.eclipse.swt.widgets.Text;
|
22
|
|
23
|
import eu.etaxonomy.taxeditor.datasource.CdmDataSourceRepository;
|
24
|
import eu.etaxonomy.taxeditor.io.wizard.SpecimenCdmExcelImportWizard;
|
25
|
import eu.etaxonomy.taxeditor.singlesource.ImplementationLoader;
|
26
|
|
27
|
/**
|
28
|
* <p>
|
29
|
* ExportToFileDestinationWizardPage class.
|
30
|
* </p>
|
31
|
*
|
32
|
* @author n.hoffmann
|
33
|
* @created 15.06.2009
|
34
|
* @version 1.0
|
35
|
*/
|
36
|
public abstract class ExportToFileDestinationWizardPageFacade extends WizardPage {
|
37
|
private static final Logger logger = Logger.getLogger(ExportToFileDestinationWizardPageFacade.class);
|
38
|
|
39
|
private final static ExportToFileDestinationWizardPageFacade IMPL;
|
40
|
static {
|
41
|
IMPL = (ExportToFileDestinationWizardPageFacade)ImplementationLoader.newInstance(ExportToFileDestinationWizardPageFacade.class) ;
|
42
|
}
|
43
|
|
44
|
/** Constant <code>DATE_FORMAT_NOW="yyyyMMddHHmm"</code> */
|
45
|
public static final String DATE_FORMAT_NOW = "yyyyMMddHHmm";
|
46
|
|
47
|
/** Constant <code>JAXB_EXPORT="JAXB_EXPORT"</code> */
|
48
|
public static final String JAXB_EXPORT = "JAXB_EXPORT";
|
49
|
|
50
|
/** Constant <code>TCS_EXPORT="TCS_EXPORT"</code> */
|
51
|
public static final String TCS_EXPORT = "TCS_EXPORT";
|
52
|
|
53
|
/** Constant <code>SDD_EXPORT="SDD_EXPORT"</code> */
|
54
|
public static final String SDD_EXPORT = "SDD_EXPORT";
|
55
|
|
56
|
public static final String DWCA_EXPORT = "DWCA_EXPORT";
|
57
|
|
58
|
public static final String XML = "xml";
|
59
|
|
60
|
public static final String ZIP = "zip";
|
61
|
|
62
|
// private DirectoryDialog folderDialog;
|
63
|
protected Text text_exportFileName;
|
64
|
|
65
|
protected Text text_folder;
|
66
|
|
67
|
protected String type;
|
68
|
|
69
|
protected String extension;
|
70
|
|
71
|
|
72
|
protected ExportToFileDestinationWizardPageFacade() {
|
73
|
super("");
|
74
|
}
|
75
|
|
76
|
protected ExportToFileDestinationWizardPageFacade(String pageName) {
|
77
|
super(pageName);
|
78
|
}
|
79
|
|
80
|
/**
|
81
|
* @param pageName
|
82
|
* @param selection
|
83
|
*/
|
84
|
private static ExportToFileDestinationWizardPageFacade getInstance (String pageName, String type,
|
85
|
String title, String description, String extension) {
|
86
|
return (ExportToFileDestinationWizardPageFacade)IMPL.getInstanceInternal( pageName, type, title, description, extension);
|
87
|
}
|
88
|
|
89
|
protected abstract Object getInstanceInternal(String pageName, String type, String title, String description, String extension);
|
90
|
|
91
|
/**
|
92
|
* <p>
|
93
|
* Jaxb
|
94
|
* </p>
|
95
|
*
|
96
|
* @return a
|
97
|
* {@link eu.etaxonomy.taxeditor.singlesource.io.wizard.ExportToFileDestinationWizardPageFacade}
|
98
|
* object.
|
99
|
*/
|
100
|
public static ExportToFileDestinationWizardPageFacade Jaxb() {
|
101
|
return getInstance(
|
102
|
JAXB_EXPORT,
|
103
|
"jaxb",
|
104
|
"JAXB Export",
|
105
|
"Exports the contents of the currently selected database into the cdm jaxb format.",
|
106
|
XML);
|
107
|
}
|
108
|
|
109
|
/**
|
110
|
* <p>
|
111
|
* Tcs
|
112
|
* </p>
|
113
|
*
|
114
|
* @return a
|
115
|
* {@link eu.etaxonomy.taxeditor.singlesource.io.wizard.ExportToFileDestinationWizardPageFacade}
|
116
|
* object.
|
117
|
*/
|
118
|
public static ExportToFileDestinationWizardPageFacade Tcs() {
|
119
|
return getInstance(
|
120
|
TCS_EXPORT,
|
121
|
"tcs",
|
122
|
"Tcs Export",
|
123
|
"Export the contents of the currently selected database into TCS format.",
|
124
|
XML);
|
125
|
}
|
126
|
|
127
|
/**
|
128
|
* <p>
|
129
|
* Sdd
|
130
|
* </p>
|
131
|
*
|
132
|
* @return a
|
133
|
* {@link eu.etaxonomy.taxeditor.singlesource.io.wizard.ExportToFileDestinationWizardPageFacade}
|
134
|
* object.
|
135
|
*/
|
136
|
public static ExportToFileDestinationWizardPageFacade Sdd() {
|
137
|
return getInstance(
|
138
|
SDD_EXPORT,
|
139
|
"sdd",
|
140
|
"Sdd Export",
|
141
|
"Export the contents of the currently selected database into SDD format.",
|
142
|
XML);
|
143
|
}
|
144
|
|
145
|
/**
|
146
|
* @return
|
147
|
*/
|
148
|
public static ExportToFileDestinationWizardPageFacade Dwca() {
|
149
|
return getInstance(
|
150
|
DWCA_EXPORT,
|
151
|
"dwca",
|
152
|
"DwC-Archive Export",
|
153
|
"Export the contents of the currently selected database into Darwin Core Archive format.",
|
154
|
ZIP);
|
155
|
}
|
156
|
|
157
|
/*
|
158
|
* (non-Javadoc)
|
159
|
*
|
160
|
* @see
|
161
|
* org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
|
162
|
* .Composite)
|
163
|
*/
|
164
|
/** {@inheritDoc} */
|
165
|
public void createControl(Composite parent) {
|
166
|
try {
|
167
|
IMPL.createControlInternal(parent);
|
168
|
} catch (OperationNotSupportedException e) {
|
169
|
logger.warn("ExportToFileDestinationWizardPageFacade.createControl currently not supported !");
|
170
|
}
|
171
|
}
|
172
|
|
173
|
protected abstract void createControlInternal(Composite parent) throws OperationNotSupportedException;
|
174
|
|
175
|
protected String generateFilename() {
|
176
|
StringBuffer buffer = new StringBuffer();
|
177
|
|
178
|
Calendar cal = Calendar.getInstance();
|
179
|
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
|
180
|
buffer.append(sdf.format(cal.getTime()));
|
181
|
|
182
|
buffer.append("-");
|
183
|
|
184
|
buffer.append(type + "_export-");
|
185
|
buffer.append(CdmDataSourceRepository.getCurrentDataSource());
|
186
|
|
187
|
buffer.append(".");
|
188
|
buffer.append(extension);
|
189
|
|
190
|
return buffer.toString();
|
191
|
}
|
192
|
|
193
|
/**
|
194
|
* <p>
|
195
|
* getExportFileName
|
196
|
* </p>
|
197
|
*
|
198
|
* @return the exportFileName
|
199
|
*/
|
200
|
public String getExportFileName() {
|
201
|
return text_exportFileName.getText();
|
202
|
}
|
203
|
|
204
|
/**
|
205
|
* <p>
|
206
|
* getFolderText
|
207
|
* </p>
|
208
|
*
|
209
|
* @return the folderText
|
210
|
*/
|
211
|
public String getFolderText() {
|
212
|
return text_folder.getText();
|
213
|
}
|
214
|
|
215
|
}
|