p2izing the editor
[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 @Deprecated
57 public void run() {
58
59 // Use same title "Export FORMAT" for all message dialogs
60 String title = "Export " + getText();
61
62 // Get file from user
63 dialog = new FileDialog(GlobalController.getShell(), SWT.SAVE);
64 dialog.setFileName("export.xml");
65 String filePath = dialog.open();
66 file = new File(filePath);
67
68 // Get current data source
69 ICdmDataSource source = CdmDataSourceRepository.getDefault().getCurrentDataSource();
70
71 // Format file path
72 String destination = null;
73 // destination = file.toURI().toURL().toString();
74 destination = file.toString();
75
76 // TODO i/o has changed drastically in cdmlib.
77 // JaxbExportConfigurator configurator = JaxbExportConfigurator.NewInstance(source, destination);
78 // CdmDefaultExport<JaxbExportConfigurator> jaxbExport =
79 // new CdmDefaultExport<JaxbExportConfigurator>();
80
81 // Start export
82 // boolean isSuccessfulExport = jaxbExport.invoke(configurator);
83 //
84 // // Tell user whether import was a success or a dismal failure
85 // if (isSuccessfulExport) {
86 // MessageDialog.openInformation(GlobalController.getShell(), title, "Export successful");
87 // } else {
88 // MessageDialog.openError(GlobalController.getShell(), title, "Export was unsuccessful.");
89 // }
90 }
91 }