Home > Software engineering >  Detecting installed plugin in Eclipse
Detecting installed plugin in Eclipse

Time:10-26

I'd like to detect the presence of a plugin from within the Eclipse plugin I'm maintaining. From a few other questions asked on this subject it looks like this is difficult.

The plugin I'm looking to detect provides a view. As such the following works, but I'm hoping that a prettier option exists:

public static boolean internalPluginInstalled() {
    IExtensionRegistry reg = Platform.getExtensionRegistry();       
    IExtensionPoint point = reg.getExtensionPoint("org.eclipse.ui.views");
    IExtension[] extensions = point.getExtensions();
    for(IExtension extension : extensions) {
        IConfigurationElement[] configs = extension.getConfigurationElements();
        for (IConfigurationElement config : configs) {
            if (config.getName().equals("view") && config.getAttribute("id").equals("view.id.goes.here")) {
                return true;
            }
        }
    }
    return false;
}

CodePudding user response:

Use Platform.getBundle (org.eclipse.core.runtime.Platform):

Bundle bundle = Platform.getBundle("plugin id");

bundle will be non-null if the plug-in is installed.

bundle.getState() returns you the exact state of the plug-in - Bundle.ACTIVE if the plug-in has been started.

  • Related