Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Dynamic Menus, Handlers and passing variables application context
Dynamic Menus, Handlers and passing variables application context [message #493173] Fri, 23 October 2009 13:25 Go to next message
Kyle Girard is currently offline Kyle GirardFriend
Messages: 1
Registered: October 2009
Junior Member
I've done a bunch of searches looking for an example of what I am doing and
have come up empty so I'm pretty sure I'm doing something wrong or missing
some fundamental step.

Background Info:

I have a View, containing a TreeViewer with multiple columns. I'm populating
the pop-up menu depending on which column gets clicked on. Currently, I have
defined a dynamic menu in the plugin.xml which uses my view and
current mouse location and getCell() to get the objects contained in the
cell to populate the menu. However I need to pass that object to the handler
After many searches I discovered the proper way to pass complex objects
to the handler is via the application context. However in my case I am
not sure how to do this.

Questions:

Is using a dynamic menu defined in plugin.xml the proper approach to my problem? Should I be solving my problem some other way?

When using dynamic menu contributions how can you execute commands
programatically (so I can add variables)?

Should I be doing this all in code in the view instead?

And more generally, when do you define commands and handlers in plugin.xml
and when should you do things in code.

Any guidance is appreciated

Kyle
Re: Dynamic Menus, Handlers and passing variables application context [message #494283 is a reply to message #493173] Thu, 29 October 2009 22:34 Go to previous messageGo to next message
Del Myers is currently offline Del MyersFriend
Messages: 82
Registered: July 2009
Member
It sounds like you can do what you are looking for if you just tell the command to execute on the current selection. This can be done by using HandlerUtil.getCurrentSelection(ExecutionEvent). You have to have your viewer registered as a selection provider in the current view site, though.

There is a greater problem of trying to pass general objects to commands. I'm searching desperately for an answer to that right now. I can't find it, though.

Del
Re: Dynamic Menus, Handlers and passing variables application context [message #494814 is a reply to message #494283] Mon, 02 November 2009 18:00 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

General objects that need to be provided to handlers should be set in the IEvaluationContext.

Either an AbstractSourceProvider makes it available to the global state through using org.eclipse.ui.services, or by generating an ExecutionEvent and extracting the IEvaluationContext from getApplicationContext().

PW


Previous Topic:Making an RCP of existing projects.
Next Topic:Drag&Drop with unknown source
Goto Forum:
  


Current Time: Fri Apr 26 03:55:37 GMT 2024

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

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

Back to the top