Re: Eclipse RCP Plugins Technical questions
Nuno schrieb:
On 1 Set, 02:31, Christian <fakem...@xyz.de> wrote:
Nuno schrieb:
- Mostrar texto citado -
Ok i understand that... "the other plugins as what they are.. a part
of your program.. there is nothing special about the plugins" but how
i call the functionality (interface) of that specific loaded instance
(plugin)... can you give a small example with source code? How i list
the available instance of plugins or how i know if all plugins were
loaded by the main app and are there to be accessed?
in the main app you could use something like this:
private void loadTokenDescriptors() {
IExtensionRegistry reg = Platform.getExtensionRegistry();
IConfigurationElement[] configElements = reg
.getConfigurationElementsFor(ITokenDescriptor.ExtensionPointID);
for (IConfigurationElement element : configElements) {
try {
tokenDescriptors.put(element.getAttribute("id") ,
(ITokenDescriptor)element.createExecutableExtension("class")
);
} catch (CoreException ce) {
logger.warn("exception on initializing: "
+ element.getAttribute("name")
+ " ("+element.getAttribute("id")
+")", ce);
}
}
}
I load with this all classes that contribute to the extension point that
is specified by the String ITokenDescriptor.ExtensionPointID.
into a HashMap (tokenDescriptors).
element.getAttribute() is used to retrieve string attributes of the plugin
while createExecutableExtension() will instantiate a class with the
no-args constructor
hope this gives you a start..
Another question, the other plugins are loaded automaticly by the main
pluggin or i have to write code to load each plugin? What i need is to
load all the E1, E2, E... plugins automaticly because these may grow
thrue time, implementing another specific functionality specified in
the BP3. That is why i need to know how many pluggins are loaded and
access the interface (declared in BP3) for each one. Again if you have
some code that explains this will be great, because i'm in the dark
and i can't get any tutorial explaining this.
i think the code above covered some of this.. and as tokens are
specified by interfaces.. provide these interfaces to other plugins that
need to use the plugin.
Thanks for the attencion,
Nuno