Search in sources :

Example 16 with Configurable

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

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

the class ConfigurableEditor method requestUpdate.

private void requestUpdate() {
    final Configurable configurable = myConfigurable;
    myQueue.queue(new Update(this) {

        @Override
        public void run() {
            updateIfCurrent(configurable);
        }

        @Override
        public boolean isExpired() {
            return myConfigurable != configurable;
        }
    });
}
Also used : Configurable(com.intellij.openapi.options.Configurable) BaseConfigurable(com.intellij.openapi.options.BaseConfigurable) Update(com.intellij.util.ui.update.Update)

Example 18 with Configurable

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

the class ConfigurableEditor method getString.

private static String getString(Configurable configurable, String key) {
    JBIterable<Configurable> it = JBIterable.of(configurable).append(JBIterable.of(configurable instanceof Configurable.Composite ? ((Configurable.Composite) configurable).getConfigurables() : null));
    ResourceBundle bundle = ConfigurableExtensionPointUtil.getBundle(key, it, null);
    return bundle != null ? bundle.getString(key) : null;
}
Also used : ResourceBundle(java.util.ResourceBundle) Configurable(com.intellij.openapi.options.Configurable) BaseConfigurable(com.intellij.openapi.options.BaseConfigurable)

Example 19 with Configurable

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

the class ConfigurableEditor method createDefaultContent.

private JComponent createDefaultContent(Configurable configurable) {
    JComponent content = new JPanel(new BorderLayout());
    content.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    String key = configurable == null ? null : ConfigurableVisitor.ByID.getID(configurable) + ".settings.description";
    String description = key == null ? null : getString(configurable, key);
    if (description == null) {
        description = "Select configuration element in the tree to edit its settings";
        content.add(BorderLayout.CENTER, new JLabel(description, SwingConstants.CENTER));
        content.setPreferredSize(JBUI.size(800, 600));
    } else {
        content.add(BorderLayout.NORTH, new JLabel(description));
        if (configurable instanceof Configurable.Composite) {
            Configurable.Composite composite = (Configurable.Composite) configurable;
            JPanel panel = new JPanel();
            panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
            content.add(BorderLayout.CENTER, panel);
            panel.add(Box.createVerticalStrut(10));
            for (Configurable current : composite.getConfigurables()) {
                LinkLabel label = LinkLabel.create(current.getDisplayName(), () -> openLink(current));
                label.setBorder(BorderFactory.createEmptyBorder(1, 17, 3, 1));
                panel.add(label);
            }
        }
    }
    return content;
}
Also used : LinkLabel(com.intellij.ui.components.labels.LinkLabel) Configurable(com.intellij.openapi.options.Configurable) BaseConfigurable(com.intellij.openapi.options.BaseConfigurable)

Example 20 with Configurable

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

the class ConfigurableVisitor method add.

private void add(List<Configurable> list, Configurable... configurables) {
    for (Configurable configurable : configurables) {
        if (accept(configurable)) {
            list.add(configurable);
        }
        if (configurable instanceof Configurable.Composite) {
            Configurable.Composite composite = (Configurable.Composite) configurable;
            add(list, composite.getConfigurables());
        }
    }
}
Also used : Configurable(com.intellij.openapi.options.Configurable) SearchableConfigurable(com.intellij.openapi.options.SearchableConfigurable)

Aggregations

Configurable (com.intellij.openapi.options.Configurable)66 SearchableConfigurable (com.intellij.openapi.options.SearchableConfigurable)32 BaseConfigurable (com.intellij.openapi.options.BaseConfigurable)8 NotNull (org.jetbrains.annotations.NotNull)8 ConfigurableGroup (com.intellij.openapi.options.ConfigurableGroup)7 UnnamedConfigurable (com.intellij.openapi.options.UnnamedConfigurable)7 Nullable (org.jetbrains.annotations.Nullable)6 Project (com.intellij.openapi.project.Project)5 ArrayList (java.util.ArrayList)5 ConfigurationException (com.intellij.openapi.options.ConfigurationException)4 ArtifactsStructureConfigurable (com.intellij.openapi.roots.ui.configuration.artifacts.ArtifactsStructureConfigurable)4 ApplicationConfigurable (com.intellij.execution.application.ApplicationConfigurable)3 JUnitConfigurable (com.intellij.execution.junit2.configuration.JUnitConfigurable)3 DataContext (com.intellij.openapi.actionSystem.DataContext)3 Module (com.intellij.openapi.module.Module)3 TabbedConfigurable (com.intellij.openapi.options.TabbedConfigurable)3 Settings (com.intellij.openapi.options.ex.Settings)3 ActionCallback (com.intellij.openapi.util.ActionCallback)3 ExtensionsArea (com.intellij.openapi.extensions.ExtensionsArea)2 CompositeConfigurable (com.intellij.openapi.options.CompositeConfigurable)2