7cf0ae7e8b14aafe36d850e55716705fd5cb554d
[taxeditor.git] / eclipseprojects / eu.etaxonomy.taxeditor / src / eu / etaxonomy / taxeditor / actions / io / ExportAction.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9
10 package eu.etaxonomy.taxeditor.actions.io;
11
12 import java.io.File;
13
14 import org.apache.log4j.Logger;
15 import org.eclipse.jface.action.Action;
16 import org.eclipse.jface.resource.ImageDescriptor;
17 import org.eclipse.swt.SWT;
18 import org.eclipse.swt.widgets.FileDialog;
19
20 import eu.etaxonomy.cdm.database.ICdmDataSource;
21 import eu.etaxonomy.taxeditor.controller.GlobalController;
22 import eu.etaxonomy.taxeditor.datasource.CdmDataSourceRepository;
23
24 /**
25 * @author p.ciardelli
26 * @created 05.11.2008
27 * @version 1.0
28 */
29 public class ExportAction extends Action {
30 private static final Logger logger = Logger.getLogger(ExportAction.class);
31
32 private static String text = "Export as ...";
33 private ImageDescriptor image = null;
34 public static final String ID = "eu.etaxonomy.taxeditor.actions.io.exportaction"; //$NON-NLS-1$
35
36 public static final String JAXB = "JAXB";
37
38 private FileDialog dialog;
39 private File file;
40
41 private String exportType;
42
43 public ExportAction() {
44 super(text);
45 setImageDescriptor(image);
46 setId(ID);
47 }
48
49 public ExportAction(String exportType) {
50 this();
51
52 this.exportType = exportType;
53 setText(exportType);
54 }
55
56 public void run() {
57
58 // Use same title "Export FORMAT" for all message dialogs
59 String title = "Export " + getText();
60
61 // Get file from user
62 dialog = new FileDialog(GlobalController.getShell(), SWT.SAVE);
63 dialog.setFileName("export.xml");
64 String filePath = dialog.open();
65 file = new File(filePath);
66
67 // Get current data source
68 ICdmDataSource source = CdmDataSourceRepository.getDefault().getCurrentDataSource();
69
70 // Format file path
71 String destination = null;
72 // destination = file.toURI().toURL().toString();
73 destination = file.toString();
74
75 // TODO i/o has changed drastically in cdmlib.
76 // JaxbExportConfigurator configurator = JaxbExportConfigurator.NewInstance(source, destination);
77 // CdmDefaultExport<JaxbExportConfigurator> jaxbExport =
78 // new CdmDefaultExport<JaxbExportConfigurator>();
79
80 // Start export
81 // boolean isSuccessfulExport = jaxbExport.invoke(configurator);
82 //
83 // // Tell user whether import was a success or a dismal failure
84 // if (isSuccessfulExport) {
85 // MessageDialog.openInformation(GlobalController.getShell(), title, "Export successful");
86 // } else {
87 // MessageDialog.openError(GlobalController.getShell(), title, "Export was unsuccessful.");
88 // }
89 }
90 }