private SpecimenDeleteConfigurator deleteConfigurator;
@Execute
- public Object execute(@Named(IServiceConstants.ACTIVE_PART) MPart part, @Named(IServiceConstants.ACTIVE_SELECTION) TreeNode treeNode, ParameterizedCommand command) {
+ public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart part, @Named(IServiceConstants.ACTIVE_SELECTION) Object selection, ParameterizedCommand command) {
deleteConfigurator = new SpecimenDeleteConfigurator();
if(command.getId().equals(AppModelId.COMMAND_EU_ETAXONOMY_TAXEDITOR_EDITOR_DERIVATE_DEEPDELETE)){
deleteConfigurator.setDeleteChildren(true);
}
-
DerivateView derivateView = (DerivateView) part.getObject();
+
+ 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;
+ }
+ confirmationQuestion += "?"; //$NON-NLS-1$
+ if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(deleteConfigurator, null, Messages.DeleteDerivateOperation_CONFIRM, confirmationQuestion)){
+ return;
+ }
+
+ if(selection instanceof Object[]){
+ for (Object o : (Object[])selection) {
+ if(o instanceof TreeNode){
+ delete((TreeNode)o, derivateView);
+ }
+ }
+ }
+ if(selection instanceof TreeNode){
+ delete((TreeNode)selection, derivateView);
+ }
+
+ }
+
+ private void delete(TreeNode treeNode, DerivateView derivateView){
Object value = treeNode.getValue();
IStatus allowStatus = allowOperations(derivateView, treeNode);
if(allowStatus.isOK()) {
if (!deleteResult.isOk()) {
MessagingUtils.warningDialog(Messages.DeleteDerivateOperation_DELETE_FAILED, this, deleteResult.toString());
-
- return Status.CANCEL_STATUS;
+ return ;
}
//broadcast delete result
EventUtility.postEvent(WorkbenchEventConstants.DELETE_DERIVATIVE, deleteResult);
derivateView.remove(treeNode);
}
- return Status.OK_STATUS;
}
- return null;
+
}
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){
}
@CanExecute
- public boolean canExecute(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) TreeNode node,
+ public boolean canExecute(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) Object selection,
MHandledMenuItem menuItem){
- boolean canExecute = node !=null;
+ boolean canExecute = false;
+ canExecute = selection!=null;
menuItem.setVisible(canExecute);
return canExecute;
}