Search code examples
eclipse-plugineclipse-rcpdeprecated

Equivalent to the deprecated Platform.getPlugin(), need access to org.eclipse.ui plugin


In a custom plug-in that I need to migrate from Eclipse 4.5.2 to Eclipse 4.6.3, I'm using the following code to access the org.eclipse.ui plugin

public class myClass extends Wizard {

...

   AbstractUIPlugin plugin = (AbstractUIPlugin) Platform.getPlugin("org.eclipse.ui");
   IDialogSettings settings = plugin.getDialogSettings();
   IDialogSettings section = workbenchSettings.getSection("myWizard");
   if (section == null) {
      section = workbenchSettings.addNewSection("myWizard");
   }
   setDialogSettings(section);

...

}

But since 4.6.0 the org.eclipse.core.runtime.compatibility plug-in has been removed. So I can't use the Platform.getPlugin() method.

I've found here someone having an equivalent problem but with no answer. And I've found there that I can access the plugin only if the creator expose the singleton.

So I have two questions:

  1. Is the singleton of the org.eclipse.ui plug-in exposed ?
  2. If yes, what is the equivalent of Platform.getPlugin() to access the org.eclipse.ui plug-in?

Solution

  • There is no equivalent API to Platform.getPlugin. You can get limited information about other plugins using Platform.getBundle and FileLocator.find but that doesn't help here.

    The org.eclipse.ui plugin does have a UIPlugin.getDefault() method but this is in an internal package so you would be breaking the Eclipse API Rules of Engagement if you used it.

    For dialog settings it is standard practice to call the getDialogSettings on your own plugin not some other plugin which you don't control.