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
.dialogs
.MessageDialog
;
17 import org
.eclipse
.jface
.resource
.ImageDescriptor
;
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 ImportAction
extends Action
{
30 private static final Logger logger
= Logger
.getLogger(ImportAction
.class);
32 private static String text
= "Import ...";
33 private ImageDescriptor image
= null;
34 public static final String ID
= "eu.etaxonomy.taxeditor.actions.io.importaction"; //$NON-NLS-1$
36 private FileDialog dialog
;
38 // private ImportWrapper importWrapper;
40 private ImportAction() {
42 setImageDescriptor(image
);
46 // public ImportAction(ImportWrapper importWrapper) {
49 // this.importWrapper = importWrapper;
50 // setText(importWrapper.getLabel());
57 // Use same title "Import FORMAT" for all message dialogs
58 String title
= "Import " + getText();
60 // Make sure user is aware of the implications of an import
61 boolean doProceed
= MessageDialog
.openConfirm(GlobalController
.getShell(), title
,
62 "Import may require a great deal of time and system resources.\n\n" +
63 "Are you sure you would like to proceed?");
69 dialog
= new FileDialog(GlobalController
.getShell());
70 String filePath
= dialog
.open();
71 file
= new File(filePath
);
73 // Get current data source
74 ICdmDataSource destination
= CdmDataSourceRepository
.getDefault().getCurrentDataSource();
76 // Get plugin application controller - from Anahit
77 // CdmApplicationController app = TaxEditorPlugin.getDefault().getCdmApp();
78 // TaxEditorPlugin.getDefault().commitTransaction();
79 // TaxEditorPlugin.getDefault().getCdmApp().close();
84 source
= file
.toURI().toURL().toString();
85 //source = file.toString();
86 } catch (/*MalformedURL*/Exception e
) {
87 MessageDialog
.openError(GlobalController
.getShell(), title
, "File could not be read.");
92 // boolean isSuccessfulImport = importWrapper.invoke(source, destination, null);
94 // // Tell user whether import was a success or a dismal failure
95 // if (isSuccessfulImport) {
96 // MessageDialog.openInformation(GlobalController.getShell(), title, "Import successful");
97 // TreeController.getTreeViewer().refresh();
99 // MessageDialog.openError(GlobalController.getShell(), title, "Import was unsuccessful.");