Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » How to write a plugin register mechanism, that can register own icons, commands, handlers etc.
How to write a plugin register mechanism, that can register own icons, commands, handlers etc. [message #1360785] Sat, 17 May 2014 00:05 Go to next message
Simon Schäfer is currently offline Simon SchäferFriend
Messages: 14
Registered: June 2011
Junior Member
I have created an extension point that allows extensions to set things like a class to execute or the addition of an optional icon.

The problem now is that I don't know how to register extensions in the Eclipse runtime. I know that I can access all the available extensions with

org.eclipse.core.runtime.Platform.getExtensionRegistry().getConfigurationElementsFor(id)

I get all the information I need from the extensions but I'm unable to find a way to register, say, a command + a handler + a corresponding icon that would allow me to call the class (which is provided by the extension) by executing this command.

The org.eclipse.ui.newWizards extension for example does something similar. How can I implement something similar?
Re: How to write a plugin register mechanism, that can register own icons, commands, handlers etc. [message #1364035 is a reply to message #1360785] Sun, 18 May 2014 09:36 Go to previous messageGo to next message
tony hedoux is currently offline tony hedouxFriend
Messages: 19
Registered: May 2012
Junior Member
You have to instantiate dynamically the class from the information you gather.

First you have to found all the contributors to your extension point :

 
// Get registry
        IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();

// Get one of the contribution for your extension point
        IExtension currentExtension : vExtensionRegistry.getExtensionPoint(EXTENSION_POINT_ID).getExtensions()[0]


Then read the configuration elements

IConfigurationElement commandConfElement = currentExtension.getConfigurationElements()[0];



Then instantiate it

Command myCommand = (Command) vElement.createExecutableExtension(name of the attribute détails);

Re: How to write a plugin register mechanism, that can register own icons, commands, handlers etc. [message #1364149 is a reply to message #1364035] Sun, 18 May 2014 10:48 Go to previous message
Simon Schäfer is currently offline Simon SchäferFriend
Messages: 14
Registered: June 2011
Junior Member
Thanks for your reply, but createExecutableExtension creates an instance of a class, it doesn't register a command in the platform (or even associate an icon with a command). Therefore it can only be cast to the type of the class and not to org.eclipse.core.commands.Command.
Previous Topic:Eclipse 4 editor tab position
Next Topic:Looking for an Eclipse build for Linux AArch64
Goto Forum:
  


Current Time: Thu Sep 19 02:08:25 GMT 2024

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

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

Back to the top