开发者

Extend ExportWizard defined in Plugin A in a depending Plugin

I'm having Plugin A which extends the 'Export Wizard' via the org.eclipse.ui.exportWizard Extens开发者_如何学编程ionPoint. 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.


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();
    }
}


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜