Example usage for com.intellij.openapi.options Configurable PROJECT_CONFIGURABLE

List of usage examples for com.intellij.openapi.options Configurable PROJECT_CONFIGURABLE

Introduction

In this page you can find the example usage for com.intellij.openapi.options Configurable PROJECT_CONFIGURABLE.

Prototype

ExtensionPointName PROJECT_CONFIGURABLE

To view the source code for com.intellij.openapi.options Configurable PROJECT_CONFIGURABLE.

Click Source Link

Usage

From source file:pl.tajchert.wearhighlight.ProjectConfigRegistrator.java

License:Apache License

public void checkAndRegister(boolean isNeedRegister) {
    try {//  w  ww .  j  ava 2 s .  com
        Object[] extensions = project.getExtensions(Configurable.PROJECT_CONFIGURABLE);
        ConfigurableEP ourExtension = null;
        for (Object extension : extensions) {
            if (extension instanceof ConfigurableEP) {
                String implementationClass = ((ConfigurableEP) extension).instanceClass;
                if (StringUtils.equals(implementationClass, ProjectConfigConfigurable.class.getName())) {
                    ourExtension = (ConfigurableEP) extension;
                    break;
                }
            }
        }
        ExtensionPoint<Object> projectConfigurableEP = Extensions.getArea(project)
                .getExtensionPoint("com.intellij.projectConfigurable");
        if (ourExtension != null && !isNeedRegister) {
            // alredy registered
            projectConfigurableEP.unregisterExtension(ourExtension);
        } else if (ourExtension == null && isNeedRegister) {
            if (configurableEP == null) {
                configurableEP = new ConfigurableEP(project);
                configurableEP.setPluginDescriptor(
                        PluginManager.getPlugin(PluginId.getId("ru.crazycoder.plugins.tabdir")));
                configurableEP.instanceClass = ProjectConfigConfigurable.class.getName();
            }
            projectConfigurableEP.registerExtension(configurableEP);
        }
    } catch (Exception ignored) {
        Logger.getInstance(this.getClass().getName()).error("", ignored);
    }
}