Is there any event handler or any method that will be executed when clicking on the delete button(bin icon) of a particular bpmn element, there are suggestions about shape.remove but I want to know before the element deleted or while clicking on the delete button itself.
The DeleteShapeHandler is responsible for deleting shapes. You can intercept the delete action in a number of ways e.g. changing the context pad’s implementation, disallowing deleting elements using rules or intercepting the actual command. What are you trying to achieve in general?
There is no simple event being fired in that case (except for all the events related to the command execution). Try modifying ContextPadProvider to achieve your custom behavior.
Can I stimulate the deletion command by code? I basically want to do the deletion command on an element but programmatically, without the user actually clicking the button.