3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.io
;
13 import org
.apache
.log4j
.Logger
;
14 import org
.eclipse
.jface
.wizard
.Wizard
;
15 import org
.eclipse
.ui
.IImportWizard
;
17 import eu
.etaxonomy
.cdm
.io
.common
.CdmDefaultImport
;
18 import eu
.etaxonomy
.cdm
.io
.common
.IImportConfigurator
;
19 import eu
.etaxonomy
.cdm
.io
.common
.IIoConfigurator
;
20 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
27 public abstract class AbstractImportWizard
<CONFIG
extends IIoConfigurator
> extends Wizard
implements IImportWizard
{
28 private static final Logger logger
= Logger
29 .getLogger(AbstractImportWizard
.class);
31 protected final String CONFIGURATION_PAGE
= "CONFIGURATION_PAGE";
33 private GenericConfiguratorWizardPage pageConfiguration
;
35 private CdmDefaultImport
<IImportConfigurator
> importer
;
38 * Performs an import into a new database. The application context has to be changed
42 public boolean doImportExternal(IImportConfigurator configurator
){
46 // ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
47 // ILaunchConfigurationType type = manager.getLaunchConfigurationType(ID_JAVA_APPLICATION);
48 // ILaunchConfiguration[] configurations = manager.getLaunchConfigurations(type);
50 // // delete possible prior launch configurations
51 // for (ILaunchConfiguration configuration : configurations) {
52 // if (configuration.getName().equals("NewInstance")) {
53 // configuration.delete();
58 // ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(null, "NewInstance");
60 // workingCopy.setAttribute(ATTR_MAIN_TYPE_NAME, "eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin");
63 // workingCopy.setAttribute(ATTR_VM_INSTALL_NAME, JavaRuntime.getDefaultVMInstall().getName());
64 // workingCopy.setAttribute(ATTR_VM_INSTALL_TYPE, JavaRuntime.getDefaultVMInstall().getVMInstallType().getId());
67 // workingCopy.launch(ILaunchManager.RUN_MODE, null);
70 // IVMInstall vm = JavaRuntime.getDefaultVMInstall();//VMInstall(proj);
71 // if (vm == null) vm = JavaRuntime.getDefaultVMInstall();
72 // IVMRunner vmr = vm.getVMRunner(ILaunchManager.RUN_MODE);
73 // String[] cp = JavaRuntime.computeDefaultRuntimeClassPath(proj);
74 // VMRunnerConfiguration config = new VMRunnerConfiguration(main, cp);
75 // ILaunch launch = new Launch(null,
76 // ILaunchManager.RUN_MODE, null);
77 // vmr.run(config, launch, null);
79 // IVMInstallType[] types = JavaRuntime.getVMInstallTypes();
81 // IVMInstall install = null;
82 // for(IVMInstallType type : types){
83 // install = type.createVMInstall(type.getId());
88 // IPath path = JavaRuntime.newJREContainerPath(install);
89 // String jrePath = path.toPortableString();
93 // ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
94 // ILaunchConfigurationType type = manager.getLaunchConfigurationType(ID_JAVA_APPLICATION);
95 // ILaunchConfigurationWorkingCopy wc = type.newInstance(null, "NewInstance");
96 // wc.setAttribute(ATTR_JRE_CONTAINER_PATH, jrePath);
97 // wc.setAttribute(ATTR_MAIN_TYPE_NAME, "eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin");
98 // ILaunchConfiguration config = wc.doSave();
99 // config.launch(ILaunchManager.RUN_MODE, null);
102 // Process p = Runtime.getRuntime().exec(cmdarray);
105 // } catch (CoreException e) {
106 // logger.error("Error launching import", e);
109 StoreUtil
.notImplementedMessage();
115 * Use when importing data into the current application context
117 * @param configurator
120 public boolean doImportInternal(final IImportConfigurator configurator
){
122 if(configurator
== null){
123 throw new IllegalArgumentException("Configuration may not be null");
126 importer
= new CdmDefaultImport();
128 // Job importJob = new Job("Import"){
130 // protected IStatus run(IProgressMonitor monitor) {
131 // return importer.invoke(configurator) ? Status.OK_STATUS : Status.CANCEL_STATUS;
135 // importJob.schedule();
137 importer
.setCdmAppController(configurator
.getCdmAppController());
139 return importer
.invoke(configurator
);
143 * @see org.eclipse.jface.wizard.Wizard#addPages()
146 public void addPages() {
149 pageConfiguration
= new GenericConfiguratorWizardPage(CONFIGURATION_PAGE
, getConfigurator());
150 this.addPage(pageConfiguration
);
153 public abstract CONFIG
getConfigurator();