}
}
- /** {@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;
+ }
}