fix #6342: fix exception when using ? in selection dialog
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / newWizard / NewDerivedUnitBaseWizard.java
index 1c5ea07fb1c2b24d73808622d96bf23021983c30..1629b49999cddc9ffb07e3bcb1450e98f966f185 100644 (file)
@@ -1,4 +1,3 @@
-// $Id$
 /**
  * Copyright (C) 2007 EDIT
  * European Distributed Institute of Taxonomy
@@ -10,23 +9,6 @@
 
 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;
@@ -36,10 +18,7 @@ import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
 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;
@@ -113,11 +92,8 @@ public class NewDerivedUnitBaseWizard extends AbstractNewEntityWizard<SpecimenOr
        /** {@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()));
+           
        }
 
 
@@ -126,54 +102,4 @@ public class NewDerivedUnitBaseWizard extends AbstractNewEntityWizard<SpecimenOr
         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;
-    }
-
-
 }