// $Id$
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
-*
+*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizardContainer;
import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.SWT;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorReference;
* @version 1.0
*/
public abstract class AbstractImportWizard<CONFIG extends IIoConfigurator> extends Wizard implements IImportWizard {
-
- protected final String CONFIGURATION_PAGE = "CONFIGURATION_PAGE";
-
+
+ protected final String CONFIGURATION_PAGE = "CONFIGURATION_PAGE";
+
private GenericConfiguratorWizardPage pageConfiguration;
private NomenclaturalCodeWizardPage pageNomenclaturalCode;
private IWorkbench workbench;
private IStructuredSelection selection;
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.wizard.Wizard#addPages()
@Override
public void addPages() {
super.addPages();
-
+
pageConfiguration = GenericConfiguratorWizardPage.Import(CONFIGURATION_PAGE, getConfigurator());
this.addPage(pageConfiguration);
-
+
pageNomenclaturalCode = new NomenclaturalCodeWizardPage((IImportConfigurator)getConfigurator());
this.addPage(pageNomenclaturalCode);
-
-
+
+
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.wizard.Wizard#setContainer(org.eclipse.jface.wizard.IWizardContainer)
*/
@Override
public void setContainer(IWizardContainer wizardContainer) {
- super.setContainer(wizardContainer);
- checkForUnsavedEditors();
+ if(existUnsavedEditors()){
+ MessageDialog.open(MessageDialog.WARNING, getShell(), "Unsaved editors", "Please save all open editors before executing " +
+ "an import operation. The import operation will be cancelled", SWT.NONE);
+ }
+ else{
+ super.setContainer(wizardContainer);
+ }
}
-
+
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
*/
this.setWorkbench(workbench);
this.setSelection(selection);
}
-
- protected void checkForUnsavedEditors(){
+
+ protected boolean existUnsavedEditors(){
IWorkbenchPage activePage = getWorkbench().getActiveWorkbenchWindow().getActivePage();
-
if(activePage != null){
for (IEditorReference reference : activePage.getEditorReferences()) {
IEditorPart editor = reference.getEditor(false);
if(editor.isDirty()){
-
- MessageDialog.open(MessageDialog.WARNING, getShell(), "Unsaved editors", "Please save all open editors before executing " +
- "an import operation. The import operation will be cancelled", SWT.NONE);
-
- performCancel();
- if(getContainer() instanceof WizardDialog){
- ((WizardDialog)getContainer()).close();
- }
-
+ return true;
}
}
}
+ return false;
}
-
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#canFinish()
+ */
+ @Override
+ public boolean canFinish() {
+ return !existUnsavedEditors();
+ }
+
/**
* <p>getConfigurator</p>
*
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.swt.widgets.Display;
-import org.hibernate.collection.internal.AbstractPersistentCollection;
-import org.hibernate.proxy.AbstractLazyInitializer;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.security.access.PermissionEvaluator;
import eu.etaxonomy.cdm.api.service.IService;
import eu.etaxonomy.cdm.config.ICdmSource;
import eu.etaxonomy.cdm.database.DbSchemaValidation;
-import eu.etaxonomy.cdm.database.ICdmDataSource;
import eu.etaxonomy.cdm.ext.geo.IEditGeoService;
import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.model.common.Language;
protected static CdmStore getDefault() {
if (instance != null && instance.isConnected) {
return instance;
- } else if (instance == null || !instance.isConnected) {
+ } else{// if (instance == null || !instance.isConnected) {
MessagingUtils
.warningDialog(
+ "connected to a datasource. You may choose a datasource to connect to or create a new one in the datasource view.");
AbstractUtility.showView(CdmDataSourceViewPart.ID);
-
+ return null;
}
-
- throw new RuntimeException();
}
/**
MessagingUtils.messageDialog("Connection to CDM Source Failed", CdmStore.class, "Could not connect to target CDM Source", e);
}
-
+
}
/**
private CdmStore(ICdmApplicationConfiguration applicationController,
ICdmSource cdmSource) {
- this.applicationConfiguration = applicationController;
+ this.applicationConfiguration = applicationController;
this.cdmSource = cdmSource;
isConnected = true;
}
}
return null;
}
-
+
/**
* <p>
* getDataSource