views:

43

answers:

2

I'm having Plugin A which extends the 'Export Wizard' via the org.eclipse.ui.exportWizard ExtensionPoint. Plugin B depends on Plugin A, is it possible to add WizardPages defined in Plugin B to Plugin A? I know adding Pages dynamicly is possible withhin the same Plugin with the DynamicWizard and function getNextPage.

A: 

Yes, as long as Plugin B is in the required plugins list for Plugin A (in Plugin A's manifest) then you can access classes from it in any extension point you define in Plugin A. The plugin editor will help you with this, as it will give you a warning if you are referring to a class that it can't access in your wizard extension point.

Francis Upton
I wanted to keep Plugin A independent of Plugin B.I'm having Listener Functionality which notifies Plugin B of a certain event in Plugin A, therefor I scan the ExtensionRegistry. But having Plugin B in the required plugins List of Plugin A makes Plugin A dependend of B (Plugin B already depends on Plugin A)
Martin Dürrmeier
Thanks for the clarification (and sorry for reading your requirement incorrectly). I think the only solution then might be to have a 3rd plugin that both B and A depend on, as you can't really have a circular dependency on plugins in Eclipse as far as I know.
Francis Upton
+1  A: 

One way would be to define an extension point "plugin_a_wizard_page" in Plugin A, with Plugin B extending it. That way, Plugin A can scan for plugins extending the extension point and add all these to the wizard.

You than have to take a look at Buddy-Class-Loading. In short: PluginA has to define a policy of Eclipse-BuddyPolicy: registered and PluginB has to register itself as a buddy to PluginA.

See: Eclipse RCP: ClassNotFoundException or How to make other bundle load my class

Then PluginA can do the following loop:

IExtensionRegistry registry = Platform.getExtensionRegistry();
IConfigurationElement[] wizardContributions = extensionRegistry
            .getConfigurationElementsFor(
                    "my.plugin",
                    "myExtensionPoint");

for (IConfigurationElement wizardContribution  : wizardContributions ) {
    try {
        IMyWizardContributionInterface listenerClass = (IContactsListener) wizardContribution.createExecutableExtension("class");
        // User your class and add it to the wizard
    } catch (final Exception e) {
         e.printStackTrace();
    }
}
Sven Lilienthal