Skip to main content



      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] Fri, 16 May 2014 20:05 Go to next message
Eclipse UserFriend
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 05:36 Go to previous messageGo to next message
Eclipse UserFriend
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 06:48 Go to previous message
Eclipse UserFriend
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: Mon Jul 14 06:51:01 EDT 2025

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

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

Back to the top