Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Inputs To Commands
Inputs To Commands [message #533424] Thu, 13 May 2010 19:58 Go to next message
Andy is currently offline Andy
Messages: 47
Registered: July 2009
Member
I have an application that displays information in a tree. I would like to add a command that allows me to override the delete key to delete a node from the tree. The command works in the sense that it now overrides the delete key and calls the execute method in the handler for the command. Right now it just throws a message saying that my handler has been called.

My question is how can I get the handler class to know about the ViewPart class that holds the tree to do the delete? I was thinking that I could have the handler class fire an event into the wiew, but I have no idea how to get the handler to know about the view. Is there a way for the ViewPart when it is creating itself to get a hold of the command and pass "this" to the handler so that the handler can add the view as a listener and then fire an event into the view? Is there any standard way of having a view and a handler for a command to communicate with each other?

Thanks,

Andy

Re: Inputs To Commands [message #533527 is a reply to message #533424] Fri, 14 May 2010 12:51 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Check out ISources and HandlerUtil. HandlerUtil can extract the active
part from the ExecutionEvent, which will be your ViewPart.

You can also activate your handler from your view's createPartControl,
at which point you can tell it about your viewer.

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: Inputs To Commands [message #533545 is a reply to message #533424] Fri, 14 May 2010 14:07 Go to previous message
Andy is currently offline Andy
Messages: 47
Registered: July 2009
Member
Thanks!

IWorkbenchPart viewer = HandlerUtil.getActivePart(event);

did the trick.
Previous Topic:Problems with custom config.ini
Next Topic:How to access Velocity templates in a plugin
Goto Forum:
  


Current Time: Wed Oct 22 21:54:39 GMT 2014

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

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