2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.actions
.io
;
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
;
20 import eu
.etaxonomy
.cdm
.database
.ICdmDataSource
;
21 import eu
.etaxonomy
.taxeditor
.controller
.GlobalController
;
22 import eu
.etaxonomy
.taxeditor
.datasource
.CdmDataSourceRepository
;
29 public class ExportAction
extends Action
{
30 private static final Logger logger
= Logger
.getLogger(ExportAction
.class);
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$
36 public static final String JAXB
= "JAXB";
38 private FileDialog dialog
;
41 private String exportType
;
43 public ExportAction() {
45 setImageDescriptor(image
);
49 public ExportAction(String exportType
) {
52 this.exportType
= exportType
;
59 // Use same title "Export FORMAT" for all message dialogs
60 String title
= "Export " + getText();
63 dialog
= new FileDialog(GlobalController
.getShell(), SWT
.SAVE
);
64 dialog
.setFileName("export.xml");
65 String filePath
= dialog
.open();
66 file
= new File(filePath
);
68 // Get current data source
69 ICdmDataSource source
= CdmDataSourceRepository
.getDefault().getCurrentDataSource();
72 String destination
= null;
73 // destination = file.toURI().toURL().toString();
74 destination
= file
.toString();
76 // TODO i/o has changed drastically in cdmlib.
77 // JaxbExportConfigurator configurator = JaxbExportConfigurator.NewInstance(source, destination);
78 // CdmDefaultExport<JaxbExportConfigurator> jaxbExport =
79 // new CdmDefaultExport<JaxbExportConfigurator>();
82 // boolean isSuccessfulExport = jaxbExport.invoke(configurator);
84 // // Tell user whether import was a success or a dismal failure
85 // if (isSuccessfulExport) {
86 // MessageDialog.openInformation(GlobalController.getShell(), title, "Export successful");
88 // MessageDialog.openError(GlobalController.getShell(), title, "Export was unsuccessful.");