+
+ public IStatus allowOperations(DerivateView derivateView, TreeNode treeNode) {
+ String confirmationQuestion = Messages.DeleteDerivateOperation_REALLY_DELETE;
+ if(deleteConfigurator.isDeleteChildren()){
+ confirmationQuestion += Messages.DeleteDerivateOperation_AND_CHILDREN;
+ }
+
+ if(derivateView.isDirty()){
+ MessagingUtils.warningDialog(DerivateView.VIEW_HAS_UNSAVED_CHANGES, this, DerivateView.YOU_NEED_TO_SAVE_BEFORE_PERFORMING_THIS_ACTION);
+ return Status.CANCEL_STATUS;
+ }
+ confirmationQuestion += "?"; //$NON-NLS-1$
+ if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(deleteConfigurator, null, Messages.DeleteDerivateOperation_CONFIRM, confirmationQuestion)){
+ return Status.CANCEL_STATUS;
+ }
+ DeleteResult deleteResult;
+ Object value = treeNode.getValue();
+ if(value instanceof SpecimenOrObservationBase<?> || value instanceof Sequence || value instanceof SingleRead){
+ if (value instanceof Sequence || value instanceof SingleRead){
+ deleteResult = CdmStore.getService(ISequenceService.class).isDeletable(((CdmBase)value).getUuid(), deleteConfigurator);
+ } else{
+ deleteResult = CdmStore.getService(IOccurrenceService.class).isDeletable(((CdmBase)value).getUuid(), deleteConfigurator);
+ }
+ if (deleteResult.isOk() || deleteResult.getExceptions().isEmpty()){ return Status.OK_STATUS;}
+ else{
+ if (!deleteResult.isOk()){
+ DeleteResultMessagingUtils.messageDialogWithDetails(deleteResult, Messages.DeleteDerivateOperation_DELETE_FAILED, TaxeditorEditorPlugin.PLUGIN_ID);
+ } else {
+ if (!deleteResult.getExceptions().isEmpty()){
+ DeleteResultMessagingUtils.messageDialogWithDetails(deleteResult, Messages.DeleteDerivateHandler_SUCCESSFULL_BUT_EXCEPTIONS, TaxeditorEditorPlugin.PLUGIN_ID);
+ }
+ }
+
+ return Status.CANCEL_STATUS;
+ }
+ }
+ return Status.CANCEL_STATUS;
+ }
+
+ @CanExecute
+ public boolean canExecute(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) TreeNode node,
+ MHandledMenuItem menuItem){
+ boolean canExecute = node !=null;
+ menuItem.setVisible(canExecute);
+ return canExecute;
+ }
+