Hi,
I need to add code to confirm the delete action, before executing the delete command.
I implemented a class that extends ActionBarContributor, and contributed with retarget actions as follows:
protected void buildActions() {
addRetargetAction(new DeleteRetargetAction());
addRetargetAction(new UndoRetargetAction());
addRetargetAction(new RedoRetargetAction());
}
I tryed to extend DeleteRetargetAction and override the run method, but it does not work, becouse retarget actions delegate to registered delete actions. And now I'm absolutly lost. I just cannot guess who tells what action is executed, or when.
So, what is the correct way to contribute with:
1.A Customized delete action
and
2.My own actions (a WhateverAction will need a retarget action?).
Solved: just overrided the createActions of my Editor
When the editor extends GraphicalEditorWithFlyoutPalette, the action creation is done by this method.
What I did was something like that:
ActionRegistry registry = getActionRegistry();
IAction action;
action = new CancelableDeleteAction((IWorkbenchPart) this); //My extension to DeleteAction
registry.registerAction(action);
getSelectionActions().add(action.getId());
The actionBarContributor is a dead end to make this kind of change.
I tried to create an action to enter the properties of the selected object within a wizard for comfort reasons and there was no way to add my custom action to the actionbarcontributor.
So i added the preferences action to the actionbarcontributor and overwrote it with my implementation like you described it and its working very well.