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
.core
.runtime
.CoreException
;
15 import org
.eclipse
.core
.runtime
.IPath
;
16 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
17 import org
.eclipse
.core
.runtime
.IStatus
;
18 import org
.eclipse
.core
.runtime
.Status
;
19 import org
.eclipse
.core
.runtime
.jobs
.Job
;
20 import org
.eclipse
.debug
.core
.DebugPlugin
;
21 import org
.eclipse
.debug
.core
.ILaunchConfiguration
;
22 import org
.eclipse
.debug
.core
.ILaunchConfigurationType
;
23 import org
.eclipse
.debug
.core
.ILaunchConfigurationWorkingCopy
;
24 import org
.eclipse
.debug
.core
.ILaunchManager
;
25 import org
.eclipse
.jdt
.core
.IClasspathEntry
;
26 import org
.eclipse
.jdt
.launching
.IJavaLaunchConfigurationConstants
;
27 import org
.eclipse
.jdt
.launching
.IVMInstall
;
28 import org
.eclipse
.jdt
.launching
.IVMInstallType
;
29 import org
.eclipse
.jdt
.launching
.JavaRuntime
;
30 import org
.eclipse
.jface
.wizard
.Wizard
;
31 import org
.eclipse
.ui
.IImportWizard
;
33 import eu
.etaxonomy
.cdm
.io
.common
.CdmDefaultImport
;
34 import eu
.etaxonomy
.cdm
.io
.common
.IImportConfigurator
;
35 import eu
.etaxonomy
.cdm
.io
.common
.IIoConfigurator
;
36 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
43 public abstract class AbstractImportWizard
<CONFIG
extends IIoConfigurator
> extends Wizard
implements IImportWizard
, IJavaLaunchConfigurationConstants
{
44 private static final Logger logger
= Logger
45 .getLogger(AbstractImportWizard
.class);
47 protected final String CONFIGURATION_PAGE
= "CONFIGURATION_PAGE";
49 private GenericConfiguratorWizardPage pageConfiguration
;
51 private CdmDefaultImport
<IImportConfigurator
> importer
;
54 * Performs an import into a new database. The application context has to be changed
58 public boolean doImportExternal(IImportConfigurator configurator
){
62 // ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
63 // ILaunchConfigurationType type = manager.getLaunchConfigurationType(ID_JAVA_APPLICATION);
64 // ILaunchConfiguration[] configurations = manager.getLaunchConfigurations(type);
66 // // delete possible prior launch configurations
67 // for (ILaunchConfiguration configuration : configurations) {
68 // if (configuration.getName().equals("NewInstance")) {
69 // configuration.delete();
74 // ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(null, "NewInstance");
76 // workingCopy.setAttribute(ATTR_MAIN_TYPE_NAME, "eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin");
79 // workingCopy.setAttribute(ATTR_VM_INSTALL_NAME, JavaRuntime.getDefaultVMInstall().getName());
80 // workingCopy.setAttribute(ATTR_VM_INSTALL_TYPE, JavaRuntime.getDefaultVMInstall().getVMInstallType().getId());
83 // workingCopy.launch(ILaunchManager.RUN_MODE, null);
86 // IVMInstall vm = JavaRuntime.getDefaultVMInstall();//VMInstall(proj);
87 // if (vm == null) vm = JavaRuntime.getDefaultVMInstall();
88 // IVMRunner vmr = vm.getVMRunner(ILaunchManager.RUN_MODE);
89 // String[] cp = JavaRuntime.computeDefaultRuntimeClassPath(proj);
90 // VMRunnerConfiguration config = new VMRunnerConfiguration(main, cp);
91 // ILaunch launch = new Launch(null,
92 // ILaunchManager.RUN_MODE, null);
93 // vmr.run(config, launch, null);
95 // IVMInstallType[] types = JavaRuntime.getVMInstallTypes();
97 // IVMInstall install = null;
98 // for(IVMInstallType type : types){
99 // install = type.createVMInstall(type.getId());
104 // IPath path = JavaRuntime.newJREContainerPath(install);
105 // String jrePath = path.toPortableString();
109 // ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
110 // ILaunchConfigurationType type = manager.getLaunchConfigurationType(ID_JAVA_APPLICATION);
111 // ILaunchConfigurationWorkingCopy wc = type.newInstance(null, "NewInstance");
112 // wc.setAttribute(ATTR_JRE_CONTAINER_PATH, jrePath);
113 // wc.setAttribute(ATTR_MAIN_TYPE_NAME, "eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin");
114 // ILaunchConfiguration config = wc.doSave();
115 // config.launch(ILaunchManager.RUN_MODE, null);
118 // Process p = Runtime.getRuntime().exec(cmdarray);
121 // } catch (CoreException e) {
122 // logger.error("Error launching import", e);
125 StoreUtil
.notImplementedMessage();
131 * Use when importing data into the current application context
133 * @param configurator
136 public boolean doImportInternal(final IImportConfigurator configurator
){
137 importer
= new CdmDefaultImport();
139 Job importJob
= new Job("Import"){
141 protected IStatus
run(IProgressMonitor monitor
) {
142 return importer
.invoke(configurator
) ? Status
.OK_STATUS
: Status
.CANCEL_STATUS
;
146 importJob
.schedule();
152 * @see org.eclipse.jface.wizard.Wizard#addPages()
155 public void addPages() {
158 pageConfiguration
= new GenericConfiguratorWizardPage(CONFIGURATION_PAGE
, getConfigurator());
159 this.addPage(pageConfiguration
);
162 public abstract CONFIG
getConfigurator();