1. 创建DeleteRetargetAction类
public class DeleteRetargetAction extends RetargetAction {
public DeleteRetargetAction() {
super(IWorkbenchActionConstants.Delete, "删除(&D)");
this.setActionDefinitionId("net.foreworld.rss2.bindings.command.delete");
this.setImageDescriptor(Activator.getImageDescriptor("icons/QuickReader_140.gif"));
}
}
public DeleteRetargetAction() {
super(IWorkbenchActionConstants.Delete, "删除(&D)");
this.setActionDefinitionId("net.foreworld.rss2.bindings.command.delete");
this.setImageDescriptor(Activator.getImageDescriptor("icons/QuickReader_140.gif"));
}
}
2. ApplicationActionBarAdvisor.makeActions() 中添加
this.deleteRetargetAction = new DeleteRetargetAction();
this.register(this.deleteRetargetAction);
window.getPartService().addPartListener(this.deleteRetargetAction);
this.register(this.deleteRetargetAction);
window.getPartService().addPartListener(this.deleteRetargetAction);
3. 在你的view中添加钩子
actionBars.setGlobalActionHandler(IWorkbenchActionConstants.Delete, this.deleteAction);
第一个参数指RetargetAction的setActionDefinitionId,第二个指当前视图所用删除Action。