Project

General

Profile

Download (5.31 KB) Statistics
| Branch: | Tag: | Revision:
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.singlesource.ImplementationLoader;
25

    
26
/**
27
 * <p>
28
 * ExportToFileDestinationWizardPage class.
29
 * </p>
30
 * 
31
 * @author n.hoffmann
32
 * @created 15.06.2009
33
 * @version 1.0
34
 */
35
public abstract class ExportToFileDestinationWizardPageFacade extends WizardPage {
36
	private static final Logger logger = Logger.getLogger(ExportToFileDestinationWizardPageFacade.class);
37
	
38
	private final static ExportToFileDestinationWizardPageFacade IMPL;
39
	static {
40
			IMPL = (ExportToFileDestinationWizardPageFacade)ImplementationLoader.newInstance(ExportToFileDestinationWizardPageFacade.class) ;
41
	}
42

    
43
	/** Constant <code>DATE_FORMAT_NOW="yyyyMMddHHmm"</code> */
44
	public static final String DATE_FORMAT_NOW = "yyyyMMddHHmm";
45

    
46
	/** Constant <code>JAXB_EXPORT="JAXB_EXPORT"</code> */
47
	public static final String JAXB_EXPORT = "JAXB_EXPORT";
48

    
49
	/** Constant <code>TCS_EXPORT="TCS_EXPORT"</code> */
50
	public static final String TCS_EXPORT = "TCS_EXPORT";
51

    
52
	/** Constant <code>SDD_EXPORT="SDD_EXPORT"</code> */
53
	public static final String SDD_EXPORT = "SDD_EXPORT";
54

    
55
	public static final String DWCA_EXPORT = "DWCA_EXPORT";
56

    
57
	public static final String XML = "xml";
58

    
59
	public static final String ZIP = "zip";
60

    
61
//	private DirectoryDialog folderDialog;
62
	protected Text text_exportFileName;
63

    
64
	protected Text text_folder;
65

    
66
	protected String type;
67

    
68
	protected String extension;
69

    
70

    
71
	protected ExportToFileDestinationWizardPageFacade() {
72
		super("");
73
	}
74
	
75
	protected ExportToFileDestinationWizardPageFacade(String pageName) {
76
		super(pageName);
77
	}
78

    
79
	/**
80
	 * @param pageName
81
	 * @param selection
82
	 */
83
	private static ExportToFileDestinationWizardPageFacade getInstance (String pageName, String type,
84
			String title, String description, String extension) {
85
		return (ExportToFileDestinationWizardPageFacade)IMPL.getInstanceInternal( pageName, type, title, description, extension);
86
	}
87
	
88
	protected abstract Object getInstanceInternal(String pageName, String type, String title, String description, String extension);
89

    
90
	/**
91
	 * <p>
92
	 * Jaxb
93
	 * </p>
94
	 * 
95
	 * @return a
96
	 *         {@link eu.etaxonomy.taxeditor.singlesource.io.wizard.ExportToFileDestinationWizardPageFacade}
97
	 *         object.
98
	 */
99
	public static ExportToFileDestinationWizardPageFacade Jaxb() {
100
		return getInstance(	
101
				JAXB_EXPORT,
102
				"jaxb",
103
				"JAXB Export",
104
				"Exports the contents of the currently selected database into the cdm jaxb format.",
105
				XML);
106
	}
107

    
108
	/**
109
	 * <p>
110
	 * Tcs
111
	 * </p>
112
	 * 
113
	 * @return a
114
	 *         {@link eu.etaxonomy.taxeditor.singlesource.io.wizard.ExportToFileDestinationWizardPageFacade}
115
	 *         object.
116
	 */
117
	public static ExportToFileDestinationWizardPageFacade Tcs() {
118
		return getInstance(
119
				TCS_EXPORT,
120
				"tcs",
121
				"Tcs Export",
122
				"Export the contents of the currently selected database into TCS format.",
123
				XML);
124
	}
125

    
126
	/**
127
	 * <p>
128
	 * Sdd
129
	 * </p>
130
	 * 
131
	 * @return a
132
	 *         {@link eu.etaxonomy.taxeditor.singlesource.io.wizard.ExportToFileDestinationWizardPageFacade}
133
	 *         object.
134
	 */
135
	public static ExportToFileDestinationWizardPageFacade Sdd() {
136
		return getInstance(
137
				SDD_EXPORT,
138
				"sdd",
139
				"Sdd Export",
140
				"Export the contents of the currently selected database into SDD format.",
141
				XML);
142
	}
143

    
144
	/**
145
	 * @return
146
	 */
147
	public static ExportToFileDestinationWizardPageFacade Dwca() {
148
		return getInstance(
149
				DWCA_EXPORT,
150
				"dwca",
151
				"DwC-Archive Export",
152
				"Export the contents of the currently selected database into Darwin Core Archive format.",
153
				ZIP);
154
	}
155

    
156
	/*
157
	 * (non-Javadoc)
158
	 * 
159
	 * @see
160
	 * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
161
	 * .Composite)
162
	 */
163
	/** {@inheritDoc} */
164
	public void createControl(Composite parent) {
165
		try {
166
			createControlInternal(parent);
167
		} catch (OperationNotSupportedException e) {
168
			logger.warn("ExportToFileDestinationWizardPageFacade.createControl currently not supported !");
169
		}
170
	}
171

    
172
	protected abstract void createControlInternal(Composite parent) throws OperationNotSupportedException;
173
	
174
	protected String generateFilename() {
175
		StringBuffer buffer = new StringBuffer();
176

    
177
		Calendar cal = Calendar.getInstance();
178
		SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
179
		buffer.append(sdf.format(cal.getTime()));
180

    
181
		buffer.append("-");
182

    
183
		buffer.append(type + "_export-");
184
		buffer.append(CdmDataSourceRepository.getCurrentDataSource());
185

    
186
		buffer.append(".");
187
		buffer.append(extension);
188

    
189
		return buffer.toString();
190
	}
191

    
192
	/**
193
	 * <p>
194
	 * getExportFileName
195
	 * </p>
196
	 * 
197
	 * @return the exportFileName
198
	 */
199
	public String getExportFileName() {
200
		return text_exportFileName.getText();
201
	}
202

    
203
	/**
204
	 * <p>
205
	 * getFolderText
206
	 * </p>
207
	 * 
208
	 * @return the folderText
209
	 */
210
	public String getFolderText() {
211
		return text_folder.getText();
212
	}
213

    
214
}
(1-1/2)