Search in sources :

Example 1 with SortedConfigurableGroup

use of com.intellij.openapi.options.ex.SortedConfigurableGroup in project intellij-community by JetBrains.

the class SettingsTreeView method findConfigurableProject.

@Nullable
private static Project findConfigurableProject(@NotNull MyNode node, boolean checkProjectLevel) {
    Configurable configurable = node.myConfigurable;
    Project project = node.getProject();
    if (checkProjectLevel) {
        Configurable.VariableProjectAppLevel wrapped = ConfigurableWrapper.cast(Configurable.VariableProjectAppLevel.class, configurable);
        if (wrapped != null)
            return wrapped.isProjectLevel() ? project : null;
    }
    if (configurable instanceof ConfigurableWrapper)
        return project;
    if (configurable instanceof SortedConfigurableGroup)
        return project;
    SimpleNode parent = node.getParent();
    return parent instanceof MyNode ? findConfigurableProject((MyNode) parent, checkProjectLevel) : null;
}
Also used : Project(com.intellij.openapi.project.Project) ConfigurableWrapper(com.intellij.openapi.options.ex.ConfigurableWrapper) SortedConfigurableGroup(com.intellij.openapi.options.ex.SortedConfigurableGroup) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with SortedConfigurableGroup

use of com.intellij.openapi.options.ex.SortedConfigurableGroup in project intellij-community by JetBrains.

the class SettingsTreeView method prepareProject.

@Nullable
private static Project prepareProject(CachingSimpleNode parent, Configurable configurable) {
    if (configurable instanceof ConfigurableWrapper) {
        ConfigurableWrapper wrapper = (ConfigurableWrapper) configurable;
        return wrapper.getExtensionPoint().getProject();
    }
    if (configurable instanceof SortedConfigurableGroup) {
        SortedConfigurableGroup group = (SortedConfigurableGroup) configurable;
        Configurable[] configurables = group.getConfigurables();
        if (configurables != null && configurables.length != 0) {
            Project project = prepareProject(parent, configurables[0]);
            if (project != null) {
                for (int i = 1; i < configurables.length; i++) {
                    if (project != prepareProject(parent, configurables[i])) {
                        return null;
                    }
                }
            }
            return project;
        }
    }
    return parent == null ? null : parent.getProject();
}
Also used : Project(com.intellij.openapi.project.Project) ConfigurableWrapper(com.intellij.openapi.options.ex.ConfigurableWrapper) SortedConfigurableGroup(com.intellij.openapi.options.ex.SortedConfigurableGroup) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

ConfigurableWrapper (com.intellij.openapi.options.ex.ConfigurableWrapper)2 SortedConfigurableGroup (com.intellij.openapi.options.ex.SortedConfigurableGroup)2 Project (com.intellij.openapi.project.Project)2 Nullable (org.jetbrains.annotations.Nullable)2