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
.io
.e4
.in
;
12 import org
.eclipse
.e4
.core
.contexts
.ContextInjectionFactory
;
13 import org
.eclipse
.e4
.core
.contexts
.IEclipseContext
;
14 import org
.eclipse
.e4
.ui
.workbench
.modeling
.EPartService
;
15 import org
.eclipse
.jface
.dialogs
.MessageDialog
;
16 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
17 import org
.eclipse
.jface
.wizard
.IWizardContainer
;
18 import org
.eclipse
.jface
.wizard
.Wizard
;
19 import org
.eclipse
.swt
.SWT
;
21 import eu
.etaxonomy
.cdm
.io
.common
.IImportConfigurator
;
22 import eu
.etaxonomy
.cdm
.io
.common
.IIoConfigurator
;
23 import eu
.etaxonomy
.taxeditor
.l10n
.Messages
;
32 public abstract class AbstractImportWizardE4
<CONFIG
extends IIoConfigurator
> extends Wizard
{
34 protected GenericConfiguratorWizardPageE4 pageConfiguration
;
35 private NomenclaturalCodeWizardPageE4 pageNomenclaturalCode
;
37 protected IStructuredSelection selection
;
39 protected IEclipseContext context
;
41 private EPartService partService
;
43 public AbstractImportWizardE4(IEclipseContext context
, EPartService partService
) {
44 this(context
, partService
, null);
47 public AbstractImportWizardE4(IEclipseContext context
, EPartService partService
, IStructuredSelection selection
) {
48 this.context
= context
;
49 this.partService
= partService
;
50 this.selection
= selection
;
55 public void addPages() {
58 addConfiguratorPage();
60 pageNomenclaturalCode
= ContextInjectionFactory
.make(NomenclaturalCodeWizardPageE4
.class, context
);
61 pageNomenclaturalCode
.setConfigurator((IImportConfigurator
)getConfigurator());
62 this.addPage(pageNomenclaturalCode
);
65 protected void addConfiguratorPage(){
66 pageConfiguration
= ContextInjectionFactory
.make(GenericConfiguratorWizardPageE4
.class, context
);
67 pageConfiguration
.initImport(getConfigurator(), null, Messages
.AbstractImportWizard_ConfigurationLabel
);
68 this.addPage(pageConfiguration
);
72 public void setContainer(IWizardContainer wizardContainer
) {
73 if(existUnsavedEditors() && wizardContainer
!=null){
74 MessageDialog
.open(MessageDialog
.WARNING
, getShell(), "Unsaved editors", "Please save all open editors before executing " +
75 "an import operation. The import operation will be cancelled", SWT
.NONE
);
78 super.setContainer(wizardContainer
);
82 public abstract void init();
84 protected boolean existUnsavedEditors(){
85 return !partService
.getDirtyParts().isEmpty();
89 public boolean canFinish() {
90 return !existUnsavedEditors() && super.canFinish();
93 public abstract CONFIG
getConfigurator();
95 public void setSelection(IStructuredSelection selection
) {
96 this.selection
= selection
;
99 public IStructuredSelection
getSelection() {