Search in sources :

Example 1 with ConfigurableWrapper

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

the class TraverseUIStarter method startup.

public static void startup(String outputPath) throws IOException {
    Map<SearchableConfigurable, Set<OptionDescription>> options = new LinkedHashMap<>();
    try {
        SearchUtil.processProjectConfigurables(ProjectManager.getInstance().getDefaultProject(), options);
        Element root = new Element(OPTIONS);
        for (SearchableConfigurable option : options.keySet()) {
            SearchableConfigurable configurable = option;
            Element configurableElement = new Element(CONFIGURABLE);
            String id = configurable.getId();
            configurableElement.setAttribute(ID, id);
            configurableElement.setAttribute(CONFIGURABLE_NAME, configurable.getDisplayName());
            Set<OptionDescription> sortedOptions = options.get(configurable);
            writeOptions(configurableElement, sortedOptions);
            if (configurable instanceof ConfigurableWrapper) {
                UnnamedConfigurable wrapped = ((ConfigurableWrapper) configurable).getConfigurable();
                if (wrapped instanceof SearchableConfigurable) {
                    configurable = (SearchableConfigurable) wrapped;
                }
            }
            if (configurable instanceof KeymapPanel) {
                processKeymap(configurableElement);
            } else if (configurable instanceof OptionsContainingConfigurable) {
                processOptionsContainingConfigurable((OptionsContainingConfigurable) configurable, configurableElement);
            } else if (configurable instanceof PluginManagerConfigurable) {
                for (OptionDescription description : wordsToOptionDescriptors(Collections.singleton(AvailablePluginsManagerMain.MANAGE_REPOSITORIES))) {
                    append(null, AvailablePluginsManagerMain.MANAGE_REPOSITORIES, description.getOption(), configurableElement);
                }
            } else if (configurable instanceof AllFileTemplatesConfigurable) {
                processFileTemplates(configurableElement);
            }
            root.addContent(configurableElement);
        }
        FileUtil.ensureCanCreateFile(new File(outputPath));
        JDOMUtil.writeDocument(new Document(root), outputPath, "\n");
        System.out.println("Searchable options index builder completed");
    } finally {
        for (SearchableConfigurable configurable : options.keySet()) {
            configurable.disposeUIResources();
        }
    }
}
Also used : OptionsContainingConfigurable(com.intellij.application.options.OptionsContainingConfigurable) ConfigurableWrapper(com.intellij.openapi.options.ex.ConfigurableWrapper) KeymapPanel(com.intellij.openapi.keymap.impl.ui.KeymapPanel) Element(org.jdom.Element) UnnamedConfigurable(com.intellij.openapi.options.UnnamedConfigurable) Document(org.jdom.Document) PluginManagerConfigurable(com.intellij.ide.plugins.PluginManagerConfigurable) SearchableConfigurable(com.intellij.openapi.options.SearchableConfigurable) AllFileTemplatesConfigurable(com.intellij.ide.fileTemplates.impl.AllFileTemplatesConfigurable) File(java.io.File)

Example 2 with ConfigurableWrapper

use of com.intellij.openapi.options.ex.ConfigurableWrapper 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 3 with ConfigurableWrapper

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

the class SettingsTreeView method fireSelected.

private void fireSelected(Configurable configurable, ActionCallback callback) {
    ConfigurableWrapper wrapper = myConfigurableToWrapperMap.get(configurable);
    myFilter.myContext.fireSelected(wrapper != null ? wrapper : configurable, this).doWhenProcessed(callback.createSetDoneRunnable());
}
Also used : ConfigurableWrapper(com.intellij.openapi.options.ex.ConfigurableWrapper)

Example 4 with ConfigurableWrapper

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

the class SettingsTreeView method findConfigurable.

@Nullable
<T extends UnnamedConfigurable> T findConfigurable(@NotNull Class<T> type) {
    for (UnnamedConfigurable configurable : myConfigurableToNodeMap.keySet()) {
        if (configurable instanceof ConfigurableWrapper) {
            ConfigurableWrapper wrapper = (ConfigurableWrapper) configurable;
            configurable = wrapper.getConfigurable();
            myConfigurableToWrapperMap.put(configurable, wrapper);
        }
        if (type.isInstance(configurable)) {
            return type.cast(configurable);
        }
    }
    return null;
}
Also used : ConfigurableWrapper(com.intellij.openapi.options.ex.ConfigurableWrapper) Nullable(org.jetbrains.annotations.Nullable)

Example 5 with ConfigurableWrapper

use of com.intellij.openapi.options.ex.ConfigurableWrapper 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)5 Nullable (org.jetbrains.annotations.Nullable)3 SortedConfigurableGroup (com.intellij.openapi.options.ex.SortedConfigurableGroup)2 Project (com.intellij.openapi.project.Project)2 OptionsContainingConfigurable (com.intellij.application.options.OptionsContainingConfigurable)1 AllFileTemplatesConfigurable (com.intellij.ide.fileTemplates.impl.AllFileTemplatesConfigurable)1 PluginManagerConfigurable (com.intellij.ide.plugins.PluginManagerConfigurable)1 KeymapPanel (com.intellij.openapi.keymap.impl.ui.KeymapPanel)1 SearchableConfigurable (com.intellij.openapi.options.SearchableConfigurable)1 UnnamedConfigurable (com.intellij.openapi.options.UnnamedConfigurable)1 File (java.io.File)1 Document (org.jdom.Document)1 Element (org.jdom.Element)1