Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Call to a command defined in another plugin(with Eclipse 4)
Call to a command defined in another plugin [message #894368] Sun, 08 July 2012 19:17 Go to next message
Vince Cadmus is currently offline Vince CadmusFriend
Messages: 14
Registered: July 2012
Junior Member
In an RCP application (not a plugin), I would like to trigger to Preferences Dialog opening. So in the application model, I tried to define a command, and in the corresponding handler to execute the standard "org.eclipse.ui.window.preferences" command :
public class PrefsHandler {
	@Inject
	ECommandService commandService;
	@Inject
	EHandlerService handlerService;

	@Execute
	public void execute() {
		Command cmd = commandService
				.getCommand("org.eclipse.ui.window.preferences");
		ParameterizedCommand parmCommand = new ParameterizedCommand(cmd, null);
		handlerService.executeHandler(parmCommand);
	}

}


Nothing happens, and when I try to debug I see the cmd command is found, but that no handler is found in context by the handlerService.

In the org.eclipse.ui plugin, the "org.eclipse.ui.window.preferences" command is defined with a "org.eclipse.ui.internal.handlers.ShowPreferencePageHandler" default handler, so I guessed it would use this handler to execute the command.

Have I missed something ?
Re: Call to a command defined in another plugin [message #894520 is a reply to message #894368] Mon, 09 July 2012 14:00 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Are you running the 4.2 Workbench in your RCP app? Or is it an Eclipse4 application?

PW


Re: Call to a command defined in another plugin [message #894538 is a reply to message #894368] Mon, 09 July 2012 14:28 Go to previous messageGo to next message
Sopot Cela is currently offline Sopot CelaFriend
Messages: 597
Registered: December 2010
Senior Member

Also when using handlers (4.2 style) inject the needed services in the @Execute method and not through field injection.
Re: Call to a command defined in another plugin [message #894619 is a reply to message #894538] Mon, 09 July 2012 20:18 Go to previous messageGo to next message
Vince Cadmus is currently offline Vince CadmusFriend
Messages: 14
Registered: July 2012
Junior Member
It's an Eclipse4 RCP Application, I defined the menu (and all the UI) in the Application.e4xmi file, but I would like to be able to re-use some functionalities coming from "standard" ui plugins (like the preferences page, eg). I hoped I could reference the "org.eclipse.ui.window.preferences" command directly in my HandledMenuItem in the application file, but I couldn't achieve this, that's why I tried to define my own command and a specific handler triggering the "org.eclipse.ui.window.preferences" command (which is defined in org.eclipse.ui plugin).

I changed the prototype of my @Execute to inject the services as parameters (and not as fields), but same thing Sad
Re: Call to a command defined in another plugin [message #894882 is a reply to message #894619] Tue, 10 July 2012 22:05 Go to previous messageGo to next message
Vince Cadmus is currently offline Vince CadmusFriend
Messages: 14
Registered: July 2012
Junior Member
Well, in fact, trying to do the same in an Eclipse 3.x way, I don't know if I'm doing it well :

In an Eclipse 3.x RCP application, I just tried to add in the plugin.xml a menu contribution with a menu/command targetting the org.eclipse.ui.window.preferences command (just filling the commandId attribute of the menuContribution/menu/command element). And it works !

The trouble is that in an Application.e4xmi file, I couldn't do the same : when trying to fill the Command for my HandledMenuItem (using the "find" button in the model editor), I can only choose commands described in this same file, nothing coming from other plugins ! By the way, I think the plugin.xml editor uses the listed dependencies to look for the commands, but as the Application.e4mi file does not list any dependency, I'm not sure it could be possible to achieve the same.

So the question becomes : in an Application.e4xmi file, how can I use in a menu a command defined in another plugin ? As it is possible using the extensions of the plugin.xml file for a 3.x RCP application, I guess it should also be possible for an Eclipse 4 application, but I can't find how Sad

Thanks !
Re: Call to a command defined in another plugin [message #895123 is a reply to message #894882] Wed, 11 July 2012 18:20 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Eclipse4 doesn't use the plugin.xml for commands and menu contributions at the moment, so it doesn't read o.e.ui.commands.

Don't you either have your commands and menu items defined in the model, or defined in fragments?

PW


Re: Call to a command defined in another plugin [message #896000 is a reply to message #895123] Mon, 16 July 2012 19:53 Go to previous messageGo to next message
Vince Cadmus is currently offline Vince CadmusFriend
Messages: 14
Registered: July 2012
Junior Member
I was trying to use in my model (the Applicatiobn.e4xmi file) a command defined in a standard 3.X module (to open the prefs dialog), and I think I have more or less understood my problem : to use a 3.x plugin with UI contributions, you have to start the Eclipse 4 application in compatibiliy mode (using the IDEApplication for instance). If you develop and start an Eclipse 4 application without using this compatibility mode, you won't be able to use UI contributions (eg commands or menus) from 3.X plugins. Right ?

But so I have another question : isn'it possible to mix 3.x and 4 plugins (with UI contributions) in the same application ? As most the "standard" plugins (let's say, the ones coming with "Eclipse for J2EE") are still 3.x modules, can't I use them in a Eclipse 4 application without the compatibiliy layer ? And if I have to use the compatibility layer, so does it mean I won't be able to run in this Eclipse 4 application some 4.x plugins with UI contributions (or may be the compatibility layer is able to use both 3.x and 4.x plugins, reading both UI extension points from plugin.xml and contributions from fragments ?). If for instance I need to develop some plugins (with UI contributions) that I would like to make available in a standard Eclipse workbench, but also use in a standalone application, can't I develop them using Eclipse 4 UI features ?

I'm afraid I'm a bit lost with this (and not sure this is the right forum to ask about this, if not just tell me Wink )

[Updated on: Mon, 16 July 2012 19:54]

Report message to a moderator

Re: Call to a command defined in another plugin [message #896129 is a reply to message #896000] Tue, 17 July 2012 11:06 Go to previous message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 242
Registered: July 2009
Senior Member
No, at the moment you can't easily mix E4 and E3.x -- the compat layer assumes it's in total control. I'd one of the aras we plan to relax in 4.3.

In terms of where to post: there are more people in the Eclipse 4 forum, but it's ok to post here too.

Brian,
Previous Topic:How to delete a cell in a table??
Next Topic:HandlerUtil.getCurrentSelection failing miserably for handler based on a listviewer....
Goto Forum:
  


Current Time: Fri Nov 28 11:35:43 GMT 2014

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

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