Search in sources :

Example 1 with ConfigurableGroup

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

the class SearchableOptionsTest method testFindCodeTemplates.

public void testFindCodeTemplates() {
    ConfigurableGroup[] groups = ShowSettingsUtilImpl.getConfigurableGroups(getProject(), false);
    ConfigurableHit configurables = SearchableOptionsRegistrar.getInstance().getConfigurables(groups, DocumentEvent.EventType.INSERT, null, "method", getProject());
    Set<Configurable> configurableSet = configurables.getAll();
    for (Configurable configurable : configurableSet) {
        if (configurable.getDisplayName().equals(new AllFileTemplatesConfigurable(getProject()).getDisplayName())) {
            return;
        }
    }
    fail("File Templates are not found");
}
Also used : ConfigurableHit(com.intellij.ide.ui.search.ConfigurableHit) ConfigurableGroup(com.intellij.openapi.options.ConfigurableGroup) AllFileTemplatesConfigurable(com.intellij.ide.fileTemplates.impl.AllFileTemplatesConfigurable) AllFileTemplatesConfigurable(com.intellij.ide.fileTemplates.impl.AllFileTemplatesConfigurable) Configurable(com.intellij.openapi.options.Configurable)

Example 2 with ConfigurableGroup

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

use of com.intellij.openapi.options.ConfigurableGroup in project android by JetBrains.

the class IdeSettingsDialogFixture method getProjectSettingsNames.

@NotNull
public List<String> getProjectSettingsNames() {
    List<String> names = Lists.newArrayList();
    JPanel optionsEditor = field("myEditor").ofType(JPanel.class).in(getDialogWrapper()).get();
    List<JComponent> trees = findComponentsOfType(optionsEditor, "com.intellij.openapi.options.newEditor.SettingsTreeView");
    assertThat(trees).hasSize(1);
    JComponent tree = trees.get(0);
    CachingSimpleNode root = field("myRoot").ofType(CachingSimpleNode.class).in(tree).get();
    ConfigurableGroup[] groups = field("myGroups").ofType(ConfigurableGroup[].class).in(root).get();
    for (ConfigurableGroup current : groups) {
        Configurable[] configurables = current.getConfigurables();
        for (Configurable configurable : configurables) {
            names.add(configurable.getDisplayName());
        }
    }
    return names;
}
Also used : ConfigurableGroup(com.intellij.openapi.options.ConfigurableGroup) Configurable(com.intellij.openapi.options.Configurable) CachingSimpleNode(com.intellij.ui.treeStructure.CachingSimpleNode) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with ConfigurableGroup

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

the class ShowSettingsUtilImpl method showSettingsDialog.

public <T extends Configurable> void showSettingsDialog(@Nullable Project project, @NotNull Class<T> configurableClass, @Nullable Consumer<T> additionalConfiguration) {
    assert Configurable.class.isAssignableFrom(configurableClass) : "Not a configurable: " + configurableClass.getName();
    ConfigurableGroup[] groups = getConfigurableGroups(project, true);
    Configurable config = new ConfigurableVisitor.ByType(configurableClass).find(groups);
    assert config != null : "Cannot find configurable: " + configurableClass.getName();
    if (additionalConfiguration != null) {
        T toConfigure = ConfigurableWrapper.cast(configurableClass, config);
        assert toConfigure != null : "Wrong configurable found: " + config.getClass();
        additionalConfiguration.accept(toConfigure);
    }
    getDialog(project, groups, config).show();
}
Also used : ConfigurableGroup(com.intellij.openapi.options.ConfigurableGroup) ConfigurableVisitor(com.intellij.openapi.options.ex.ConfigurableVisitor) Configurable(com.intellij.openapi.options.Configurable) TabbedConfigurable(com.intellij.openapi.options.TabbedConfigurable)

Example 5 with ConfigurableGroup

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

the class ShowSettingsUtilImpl method getConfigurables.

/**
   * @param project         a project used to load project settings or {@code null}
   * @param withIdeSettings specifies whether to load application settings or not
   * @return all configurables as a plain list except the root configurable group
   */
@NotNull
public static Configurable[] getConfigurables(@Nullable Project project, boolean withIdeSettings) {
    ConfigurableGroup group = ConfigurableExtensionPointUtil.getConfigurableGroup(project, withIdeSettings);
    List<Configurable> list = new ArrayList<>();
    collect(list, group.getConfigurables());
    return list.toArray(new Configurable[0]);
}
Also used : ConfigurableGroup(com.intellij.openapi.options.ConfigurableGroup) ArrayList(java.util.ArrayList) Configurable(com.intellij.openapi.options.Configurable) TabbedConfigurable(com.intellij.openapi.options.TabbedConfigurable) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

Configurable (com.intellij.openapi.options.Configurable)7 ConfigurableGroup (com.intellij.openapi.options.ConfigurableGroup)7 NotNull (org.jetbrains.annotations.NotNull)4 TabbedConfigurable (com.intellij.openapi.options.TabbedConfigurable)3 CachingSimpleNode (com.intellij.ui.treeStructure.CachingSimpleNode)2 ArrayList (java.util.ArrayList)2 AllFileTemplatesConfigurable (com.intellij.ide.fileTemplates.impl.AllFileTemplatesConfigurable)1 PluginManagerConfigurable (com.intellij.ide.plugins.PluginManagerConfigurable)1 ConfigurableHit (com.intellij.ide.ui.search.ConfigurableHit)1 SearchableConfigurable (com.intellij.openapi.options.SearchableConfigurable)1 ConfigurableVisitor (com.intellij.openapi.options.ex.ConfigurableVisitor)1 THashSet (gnu.trove.THashSet)1 Assert.assertNotNull (org.junit.Assert.assertNotNull)1