-// $Id$
/**
* Copyright (C) 2007 EDIT
* European Distributed Institute of Taxonomy
package eu.etaxonomy.taxeditor.newWizard;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import org.eclipse.core.commands.Command;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.NotEnabledException;
-import org.eclipse.core.commands.NotHandledException;
-import org.eclipse.core.commands.ParameterizedCommand;
-import org.eclipse.core.commands.common.NotDefinedException;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialogWithToggle;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.commands.ICommandService;
-import org.eclipse.ui.handlers.IHandlerService;
-
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException;
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
import eu.etaxonomy.cdm.model.occurrence.MediaSpecimen;
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
-import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.IDerivedUnitFacadePart;
-import eu.etaxonomy.taxeditor.model.MessagingUtils;
-import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
import eu.etaxonomy.taxeditor.store.CdmStore;
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseWizardPage;
/** {@inheritDoc} */
@Override
protected void saveEntity() {
- if(CdmStore.getCurrentSessionManager().isRemoting()) {
- CdmStore.getService(IOccurrenceService.class).merge(getEntity(), true);
- } else {
- CdmStore.getService(IOccurrenceService.class).save(getEntity());
- }
+ setEntity(CdmStore.getService(IOccurrenceService.class).merge(getEntity()));
+
}
return "Specimen";
}
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean performFinish() {
- boolean performFinish = super.performFinish();
- int returnCode = IDialogConstants.NO_ID;
- if (!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.PROMPT_FOR_OPEN_SPECIMEN_IN_EDITOR)){
- MessageDialogWithToggle messageDialog = MessageDialogWithToggle.openYesNoQuestion(getShell(),
- "Choose opening option", "Do you want to open the specimen in the specimen editor?",
- "Remember my decision?", false, PreferencesUtil.getPreferenceStore(),
- IPreferenceKeys.ALWAYS_OPEN_SPECIMEN_IN_EDITOR);
- returnCode = messageDialog.getReturnCode();
- PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.PROMPT_FOR_OPEN_SPECIMEN_IN_EDITOR, messageDialog.getToggleState());
- if (returnCode != IDialogConstants.YES_ID) {
- return performFinish;
- }
- }
- if (returnCode==IDialogConstants.YES_ID ||
- PreferencesUtil.getPreferenceStore().getString(IPreferenceKeys.ALWAYS_OPEN_SPECIMEN_IN_EDITOR)
- .equals(MessageDialogWithToggle.ALWAYS)) {
- IHandlerService handlerService = (IHandlerService) AbstractUtility.getService(IHandlerService.class);
-
- // get the command from plugin.xml
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- ICommandService cmdService = (ICommandService) window.getService(ICommandService.class);
- Command command = cmdService.getCommand("eu.etaxonomy.taxeditor.editor.openSpecimenEditor");
- Map<String, UUID> parameters = new HashMap<String, UUID>();
- parameters.put("eu.etaxonomy.taxeditor.specimenUuidParameter", getEntity().getUuid());
- ParameterizedCommand parameterizedCommand = ParameterizedCommand.generateCommand(command, parameters);
-
-
- // execute the command
- try {
- handlerService.executeCommand(parameterizedCommand, null);
- } catch (ExecutionException e) {
- MessagingUtils.error(NewDerivedUnitBaseWizard.class, e);
- } catch (NotDefinedException e) {
- MessagingUtils.error(NewDerivedUnitBaseWizard.class, e);
- } catch (NotEnabledException e) {
- MessagingUtils.error(NewDerivedUnitBaseWizard.class, e);
- } catch (NotHandledException e) {
- MessagingUtils.error(NewDerivedUnitBaseWizard.class, e);
- }
- }
-
- return performFinish;
- }
-
-
}