|Re: How to create a handler by id? [message #987670 is a reply to message #987638]
||Tue, 27 November 2012 14:16
| Brian de Alwis
Registered: January 2012
Is there a way to create the handler by id only?
Can I somehow resolve the id to bundleURI?
Short answer: no. You'll need to do the search and creation yourself. You might want to check if the MHandler has an object already before creating a new one.
contributing a Handler for a Command and executing it by ID is clearer.
I'm not sure how it's more clear considering it's (mis-?) using a part of the framework for a totally unanticipated and unintended purpose.
First, heavyweight is usually used in the context of execution time or memory consumption, not in having to code a loop. If you're seeing a performance hit iterating over the extension registry, you should be clear and file a bug report with reproducible data -- it's been pretty heavily tuned.
Second, all the model searches come down to iterating over the model elements. I.e., equally "heavyweight". In fact, it's even more "heavyweight" as handlers can be installed at many different points in the model (see the implementors of MHandlerContainer) -- so you're looking at a complete graph traversal, which is "expensive" in terms of stack (e.g., you'll be implementing BFS or DFS of some kind).
Finally, I'm not understanding your desire for pursuing this appraoch. If you know a handler, why are you using the E4 framework at all? The E4 command/handler design was intended to separate the intent (the command) from the implementation (the handler), where the implementation is identified based on the current context. This allows one part to contribute a completely different "org.eclipse.ui.delete" handler from the Package Explorer, for example. This seems to be an example of "when you have a hammer, everything looks like a nail".
Anyways, best of luck.
Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
|Re: How to create a handler by id? [message #987794 is a reply to message #987670]
||Wed, 28 November 2012 08:31
| Alex Kipling
Registered: July 2012
Thnx for the answer, Brian!|
Maybe I should provide some explanation:
You are right - I used "heavyweight" as a large, chunky piece of code, it was not about the erformance.
The Handler I know, because I'm getting a Plugin earlier in my code. This plugin is found dynamically, using the e4 way.
Now this plugin should contribute some own funcitonality. Plugin does this, by providing a handler. How else plugin could contribute some executable piece of code?
For now, to execute the code - plugin has to provide a command either. This is redundant, and so i would like to execute the handler directly.
I am aware about the purposes, which handlers and commands were introduced for.
Powered by FUDForum
. Page generated in 0.08042 seconds