Merge branch 'develop' into remoting-4.0
authorCherian Mathew <c.mathew@bgbm.org>
Tue, 15 Sep 2015 10:11:19 +0000 (12:11 +0200)
committerCherian Mathew <c.mathew@bgbm.org>
Tue, 15 Sep 2015 10:11:19 +0000 (12:11 +0200)
Conflicts:
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewDerivedUnitBaseWizard.java

1  2 
eu.etaxonomy.taxeditor.editor/plugin.xml
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewDerivedUnitBaseWizard.java

@@@ -88,16 -109,63 +109,66 @@@ public class NewDerivedUnitBaseWizard e
          }
      }
  
 -    /** {@inheritDoc} */
 -    @Override
 -    protected void saveEntity() {
 -        CdmStore.getService(IOccurrenceService.class).saveOrUpdate(getEntity());
 -    }
++
 +      /** {@inheritDoc} */
 +      @Override
 +      protected void saveEntity() {
 +              CdmStore.getService(IOccurrenceService.class).merge(getEntity());
 +      }
 +
-       @Override
-       protected String getEntityName() {
-               return "Specimen";
-       }
+     @Override
+     protected String getEntityName() {
+         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(DerivateSearchCompositeController.class, e);
+             } catch (NotDefinedException e) {
+                 MessagingUtils.error(DerivateSearchCompositeController.class, e);
+             } catch (NotEnabledException e) {
+                 MessagingUtils.error(DerivateSearchCompositeController.class, e);
+             } catch (NotHandledException e) {
+                 MessagingUtils.error(DerivateSearchCompositeController.class, e);
+             }
+         }
+         return performFinish;
+     }
  
  
  }