Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » actions and keybindings
actions and keybindings [message #540366] Tue, 15 June 2010 20:15 Go to next message
Lidder is currently offline LidderFriend
Messages: 46
Registered: July 2009
Member
Hello,

I Have two drawers (SWT expandBars) in my custom outline view. I need to provide delete actions in both the drawers and link them to the eclipse delete key binding. The two drawers present different information and so that delete actions have to be separate actions.

Drawer 1: the delete action sits in the actionbar
 ActionRegistry registry = this.editor.getActionRegistry();
    IActionBars bars = pageSite.getActionBars();  
    bars.setGlobalActionHandler(ActionFactory.CUT.getId(), registry.getAction(CustomCutAction.ACTION_ID));
    bars.setGlobalActionHandler(ActionFactory.COPY.getId(), registry.getAction(CustomCopyAction.ACTION_ID));
    bars.setGlobalActionHandler(ActionFactory.PASTE.getId(), registry.getAction(CustomPasteAction.ACTION_ID));
    bars.setGlobalActionHandler(ActionFactory.DELETE.getId(), registry.getAction(CustomDeleteAction.ACTION_ID));



Drawer 2
     IPageSite pageSite = this.getSite();
		IHandlerService handlerService = (IHandlerService) pageSite.getService(IHandlerService.class);
		RemoveItemAction deleteAction = new RemoveItemAction(pageSite.getPage(), tree);
		handlerService.activateHandler(ActionFactory.DELETE.getId(), new ActionHandler(deleteAction));


The problem is that the CustomDeleteAction runs in both drawers when I press the delete key. I guess the reason is that I am not allowed to over write the binding? Does anybody have an idea as to how I can resolve this issue.

Thank you very much !!
Re: actions and keybindings [message #540529 is a reply to message #540366] Wed, 16 June 2010 12:32 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

You only get one DELETE action and/or handler per part (editor or view).

Look at org.eclipse.ui.actions.TextActionHandler and how it is used.
That allows you to provide a delete action for your view, but have
delete on multiple text controls work as well. You will probably need
to write something similar yourself, so you can provide DELETE once and
have it delegate to the expand bar that has focus/activate

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: actions and keybindings [message #540619 is a reply to message #540366] Wed, 16 June 2010 17:44 Go to previous message
Lidder is currently offline LidderFriend
Messages: 46
Registered: July 2009
Member
Thank you Paul. I am now checking if the control in drawer has focus when the delete is pressed. Seems to work.

Upkar.
Previous Topic:Eclipse with wide screen
Next Topic:Programmatic handler enablement
Goto Forum:
  


Current Time: Mon Nov 24 03:58:59 GMT 2014

Powered by FUDForum. Page generated in 0.01799 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software