Search in sources :

Example 1 with SearchableConfigurable

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

the class SeverityEditorDialog method editColorsAndFonts.

private void editColorsAndFonts() {
    final String toConfigure = getSelectedType().getSeverity(null).myName;
    if (myCloseDialogWhenSettingsShown) {
        doOKAction();
    }
    myOptionsList.clearSelection();
    final DataContext dataContext = DataManager.getInstance().getDataContext(myPanel);
    Settings settings = Settings.KEY.getData(dataContext);
    if (settings != null) {
        ColorAndFontOptions colorAndFontOptions = settings.find(ColorAndFontOptions.class);
        assert colorAndFontOptions != null;
        final SearchableConfigurable javaPage = colorAndFontOptions.findSubConfigurable(InspectionColorSettingsPage.class);
        LOG.assertTrue(javaPage != null);
        settings.select(javaPage).doWhenDone(() -> {
            final Runnable runnable = javaPage.enableSearch(toConfigure);
            if (runnable != null) {
                SwingUtilities.invokeLater(runnable);
            }
        });
    } else {
        ColorAndFontOptions colorAndFontOptions = new ColorAndFontOptions();
        final Configurable[] configurables = colorAndFontOptions.buildConfigurables();
        try {
            final SearchableConfigurable javaPage = colorAndFontOptions.findSubConfigurable(InspectionColorSettingsPage.class);
            LOG.assertTrue(javaPage != null);
            ShowSettingsUtil.getInstance().editConfigurable(CommonDataKeys.PROJECT.getData(dataContext), javaPage);
        } finally {
            for (Configurable configurable : configurables) {
                configurable.disposeUIResources();
            }
            colorAndFontOptions.disposeUIResources();
        }
    }
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) ColorAndFontOptions(com.intellij.application.options.colors.ColorAndFontOptions) SearchableConfigurable(com.intellij.openapi.options.SearchableConfigurable) Configurable(com.intellij.openapi.options.Configurable) SearchableConfigurable(com.intellij.openapi.options.SearchableConfigurable) Settings(com.intellij.openapi.options.ex.Settings)

Example 2 with SearchableConfigurable

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

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

the class JumpToColorsAndFontsAction method openSettingsAndSelectKey.

private static boolean openSettingsAndSelectKey(@NotNull Project project, @NotNull ColorSettingsPage page, @NotNull AttributesDescriptor descriptor) {
    SettingsDialog dialog = (SettingsDialog) ShowSettingsUtilImpl.getDialog(project, ShowSettingsUtilImpl.getConfigurableGroups(project, true), null);
    Settings settings = Settings.KEY.getData(dialog);
    ColorAndFontOptions configurable0 = settings == null ? null : settings.find(ColorAndFontOptions.class);
    SearchableConfigurable configurable = configurable0 == null ? null : configurable0.findSubConfigurable(page.getDisplayName());
    if (configurable == null)
        return false;
    Runnable runnable = configurable.enableSearch(descriptor.getDisplayName());
    ActionCallback callback = settings.select(configurable);
    if (runnable != null)
        callback.doWhenDone(runnable);
    dialog.show();
    return true;
}
Also used : ActionCallback(com.intellij.openapi.util.ActionCallback) SearchableConfigurable(com.intellij.openapi.options.SearchableConfigurable) SettingsDialog(com.intellij.openapi.options.newEditor.SettingsDialog) Settings(com.intellij.openapi.options.ex.Settings)

Example 4 with SearchableConfigurable

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

the class SearchableOptionsRegistrarImpl method getConfigurables.

@Override
@NotNull
public ConfigurableHit getConfigurables(ConfigurableGroup[] groups, final DocumentEvent.EventType type, Set<Configurable> configurables, String option, Project project) {
    final ConfigurableHit hits = new ConfigurableHit();
    final Set<Configurable> contentHits = hits.getContentHits();
    Set<String> options = getProcessedWordsWithoutStemming(option);
    if (configurables == null) {
        for (ConfigurableGroup group : groups) {
            contentHits.addAll(SearchUtil.expandGroup(group));
        }
    } else {
        contentHits.addAll(configurables);
    }
    String optionToCheck = option.trim().toLowerCase();
    for (Configurable each : contentHits) {
        if (each.getDisplayName() == null)
            continue;
        final String displayName = each.getDisplayName().toLowerCase();
        final List<String> allWords = StringUtil.getWordsIn(displayName);
        if (displayName.contains(optionToCheck)) {
            hits.getNameFullHits().add(each);
            hits.getNameHits().add(each);
        }
        for (String eachWord : allWords) {
            if (eachWord.startsWith(optionToCheck)) {
                hits.getNameHits().add(each);
                break;
            }
        }
        if (options.isEmpty()) {
            hits.getNameHits().add(each);
            hits.getNameFullHits().add(each);
        }
    }
    final Set<Configurable> currentConfigurables = new HashSet<>(contentHits);
    if (options.isEmpty()) {
        //operate with substring
        String[] components = REG_EXP.split(optionToCheck);
        if (components.length > 0) {
            Collections.addAll(options, components);
        } else {
            options.add(option);
        }
    }
    Set<String> helpIds = null;
    for (String opt : options) {
        final Set<OptionDescription> optionIds = getAcceptableDescriptions(opt);
        if (optionIds == null) {
            contentHits.clear();
            return hits;
        }
        final Set<String> ids = new HashSet<>();
        for (OptionDescription id : optionIds) {
            ids.add(id.getConfigurableId());
        }
        if (helpIds == null) {
            helpIds = ids;
        }
        helpIds.retainAll(ids);
    }
    if (helpIds != null) {
        for (Iterator<Configurable> it = contentHits.iterator(); it.hasNext(); ) {
            Configurable configurable = it.next();
            if (CodeStyleFacade.getInstance(project).isUnsuitableCodeStyleConfigurable(configurable)) {
                it.remove();
                continue;
            }
            if (!(configurable instanceof SearchableConfigurable && helpIds.contains(((SearchableConfigurable) configurable).getId()))) {
                it.remove();
            }
        }
    }
    if (currentConfigurables.equals(contentHits) && !(configurables == null && type == DocumentEvent.EventType.CHANGE)) {
        return getConfigurables(groups, DocumentEvent.EventType.CHANGE, null, option, project);
    }
    return hits;
}
Also used : ConfigurableGroup(com.intellij.openapi.options.ConfigurableGroup) PluginManagerConfigurable(com.intellij.ide.plugins.PluginManagerConfigurable) Configurable(com.intellij.openapi.options.Configurable) SearchableConfigurable(com.intellij.openapi.options.SearchableConfigurable) SearchableConfigurable(com.intellij.openapi.options.SearchableConfigurable) THashSet(gnu.trove.THashSet) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with SearchableConfigurable

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

the class SearchEverywhereAction method fillConfigurablesIds.

private void fillConfigurablesIds(String pathToParent, Configurable[] configurables) {
    for (Configurable configurable : configurables) {
        if (configurable instanceof SearchableConfigurable) {
            final String id = ((SearchableConfigurable) configurable).getId();
            String name = configurable.getDisplayName();
            if (pathToParent != null) {
                name = pathToParent + " -> " + name;
            }
            myConfigurables.put(id, name);
            if (configurable instanceof SearchableConfigurable.Parent) {
                fillConfigurablesIds(name, ((SearchableConfigurable.Parent) configurable).getConfigurables());
            }
        }
    }
}
Also used : SearchableConfigurable(com.intellij.openapi.options.SearchableConfigurable) Configurable(com.intellij.openapi.options.Configurable) SearchableConfigurable(com.intellij.openapi.options.SearchableConfigurable)

Aggregations

SearchableConfigurable (com.intellij.openapi.options.SearchableConfigurable)7 Configurable (com.intellij.openapi.options.Configurable)5 PluginManagerConfigurable (com.intellij.ide.plugins.PluginManagerConfigurable)2 Settings (com.intellij.openapi.options.ex.Settings)2 OptionsContainingConfigurable (com.intellij.application.options.OptionsContainingConfigurable)1 ColorAndFontOptions (com.intellij.application.options.colors.ColorAndFontOptions)1 AllFileTemplatesConfigurable (com.intellij.ide.fileTemplates.impl.AllFileTemplatesConfigurable)1 DataContext (com.intellij.openapi.actionSystem.DataContext)1 KeymapPanel (com.intellij.openapi.keymap.impl.ui.KeymapPanel)1 CompositeConfigurable (com.intellij.openapi.options.CompositeConfigurable)1 ConfigurableGroup (com.intellij.openapi.options.ConfigurableGroup)1 MasterDetails (com.intellij.openapi.options.MasterDetails)1 UnnamedConfigurable (com.intellij.openapi.options.UnnamedConfigurable)1 ConfigurableWrapper (com.intellij.openapi.options.ex.ConfigurableWrapper)1 SettingsDialog (com.intellij.openapi.options.newEditor.SettingsDialog)1 ActionCallback (com.intellij.openapi.util.ActionCallback)1 THashSet (gnu.trove.THashSet)1 File (java.io.File)1 Document (org.jdom.Document)1 Element (org.jdom.Element)1