Search in sources :

Example 1 with Settings

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

the class MavenKeymapExtension method createGroup.

@Override
public KeymapGroup createGroup(Condition<AnAction> condition, final Project project) {
    KeymapGroup result = KeymapGroupFactory.getInstance().createGroup(TasksBundle.message("maven.tasks.action.group.name"), MavenIcons.MavenLogo);
    if (project == null)
        return result;
    Comparator<MavenProject> projectComparator = (o1, o2) -> o1.getDisplayName().compareToIgnoreCase(o2.getDisplayName());
    Map<MavenProject, Set<Pair<String, String>>> projectToActionsMapping = new TreeMap<>(projectComparator);
    ActionManager actionManager = ActionManager.getInstance();
    //noinspection TestOnlyProblems
    for (String eachId : actionManager.getActionIds(getActionPrefix(project, null))) {
        AnAction eachAction = actionManager.getAction(eachId);
        if (!(eachAction instanceof MavenGoalAction))
            continue;
        if (condition != null && !condition.value(actionManager.getActionOrStub(eachId)))
            continue;
        MavenGoalAction mavenAction = (MavenGoalAction) eachAction;
        MavenProject mavenProject = mavenAction.getMavenProject();
        Set<Pair<String, String>> actions = projectToActionsMapping.get(mavenProject);
        if (actions == null) {
            final List<String> projectGoals = collectGoals(mavenProject);
            actions = new TreeSet<>((o1, o2) -> {
                String goal1 = o1.getFirst();
                String goal2 = o2.getFirst();
                int index1 = projectGoals.indexOf(goal1);
                int index2 = projectGoals.indexOf(goal2);
                if (index1 == index2)
                    return goal1.compareToIgnoreCase(goal2);
                return (index1 < index2 ? -1 : 1);
            });
            projectToActionsMapping.put(mavenProject, actions);
        }
        actions.add(Pair.create(mavenAction.getGoal(), eachId));
    }
    for (Map.Entry<MavenProject, Set<Pair<String, String>>> each : projectToActionsMapping.entrySet()) {
        Set<Pair<String, String>> goalsToActionIds = each.getValue();
        for (Pair<String, String> eachGoalToActionId : goalsToActionIds) {
            result.addActionId(eachGoalToActionId.getSecond());
        }
    }
    Icon icon = SystemInfoRt.isMac ? AllIcons.ToolbarDecorator.Mac.Add : AllIcons.ToolbarDecorator.Add;
    ((Group) result).addHyperlink(new Hyperlink(icon, "Choose a phase/goal to assign a shortcut") {

        @Override
        public void onClick(MouseEvent e) {
            SelectMavenGoalDialog dialog = new SelectMavenGoalDialog(project);
            if (dialog.showAndGet() && dialog.getResult() != null) {
                MavenProjectsStructure.GoalNode goalNode = dialog.getResult();
                String goal = goalNode.getGoal();
                String actionId = MavenShortcutsManager.getInstance(project).getActionId(goalNode.getProjectPath(), goal);
                getOrRegisterAction(goalNode.getMavenProject(), actionId, goal);
                ApplicationManager.getApplication().getMessageBus().syncPublisher(KeymapListener.CHANGE_TOPIC).processCurrentKeymapChanged();
                Settings allSettings = Settings.KEY.getData(DataManager.getInstance().getDataContext(e.getComponent()));
                KeymapPanel keymapPanel = allSettings != null ? allSettings.find(KeymapPanel.class) : null;
                if (keymapPanel != null) {
                    // clear actions filter
                    keymapPanel.showOption("");
                    keymapPanel.selectAction(actionId);
                }
            }
        }
    });
    return result;
}
Also used : KeymapGroup(com.intellij.openapi.keymap.KeymapGroup) Settings(com.intellij.openapi.options.ex.Settings) KeymapGroupFactory(com.intellij.openapi.keymap.KeymapGroupFactory) KeymapPanel(com.intellij.openapi.keymap.impl.ui.KeymapPanel) SystemInfoRt(com.intellij.openapi.util.SystemInfoRt) java.util(java.util) AllIcons(com.intellij.icons.AllIcons) KeymapListener(com.intellij.openapi.keymap.impl.ui.KeymapListener) MavenActionUtil(org.jetbrains.idea.maven.utils.actions.MavenActionUtil) Hyperlink(com.intellij.openapi.keymap.impl.ui.Hyperlink) MavenRunConfigurationType(org.jetbrains.idea.maven.execution.MavenRunConfigurationType) Group(com.intellij.openapi.keymap.impl.ui.Group) SelectMavenGoalDialog(org.jetbrains.idea.maven.navigator.SelectMavenGoalDialog) MavenPluginInfo(org.jetbrains.idea.maven.utils.MavenPluginInfo) ExternalSystemKeymapExtension(com.intellij.openapi.externalSystem.service.project.manage.ExternalSystemKeymapExtension) Project(com.intellij.openapi.project.Project) MavenConstants(org.jetbrains.idea.maven.model.MavenConstants) MavenProjectsStructure(org.jetbrains.idea.maven.navigator.MavenProjectsStructure) MavenIcons(icons.MavenIcons) DataManager(com.intellij.ide.DataManager) MavenProject(org.jetbrains.idea.maven.project.MavenProject) MavenRunnerParameters(org.jetbrains.idea.maven.execution.MavenRunnerParameters) MavenAction(org.jetbrains.idea.maven.utils.actions.MavenAction) MouseEvent(java.awt.event.MouseEvent) File(java.io.File) MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager) MavenArtifactUtil(org.jetbrains.idea.maven.utils.MavenArtifactUtil) TestOnly(org.jetbrains.annotations.TestOnly) com.intellij.openapi.actionSystem(com.intellij.openapi.actionSystem) MavenPlugin(org.jetbrains.idea.maven.model.MavenPlugin) Pair(com.intellij.openapi.util.Pair) ApplicationManager(com.intellij.openapi.application.ApplicationManager) MavenExplicitProfiles(org.jetbrains.idea.maven.model.MavenExplicitProfiles) Condition(com.intellij.openapi.util.Condition) javax.swing(javax.swing) KeymapGroup(com.intellij.openapi.keymap.KeymapGroup) Group(com.intellij.openapi.keymap.impl.ui.Group) SelectMavenGoalDialog(org.jetbrains.idea.maven.navigator.SelectMavenGoalDialog) MavenProject(org.jetbrains.idea.maven.project.MavenProject) Settings(com.intellij.openapi.options.ex.Settings) Pair(com.intellij.openapi.util.Pair) MouseEvent(java.awt.event.MouseEvent) KeymapPanel(com.intellij.openapi.keymap.impl.ui.KeymapPanel) KeymapGroup(com.intellij.openapi.keymap.KeymapGroup) Hyperlink(com.intellij.openapi.keymap.impl.ui.Hyperlink)

Example 2 with Settings

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

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

the class ExternalSystemKeymapExtension method createGroup.

public KeymapGroup createGroup(Condition<AnAction> condition, final Project project) {
    KeymapGroup result = KeymapGroupFactory.getInstance().createGroup(ExternalSystemBundle.message("external.system.keymap.group"), ExternalSystemIcons.TaskGroup);
    AnAction[] externalSystemActions = ActionsTreeUtil.getActions("ExternalSystem.Actions");
    for (AnAction action : externalSystemActions) {
        ActionsTreeUtil.addAction(result, action, condition);
    }
    if (project == null)
        return result;
    MultiMap<ProjectSystemId, String> projectToActionsMapping = MultiMap.create();
    for (ExternalSystemManager<?, ?, ?, ?, ?> manager : ExternalSystemApiUtil.getAllManagers()) {
        projectToActionsMapping.putValues(manager.getSystemId(), ContainerUtil.<String>emptyList());
    }
    ActionManager actionManager = ActionManager.getInstance();
    if (actionManager != null) {
        for (String eachId : actionManager.getActionIds(getActionPrefix(project, null))) {
            AnAction eachAction = actionManager.getAction(eachId);
            if (!(eachAction instanceof MyExternalSystemAction))
                continue;
            if (condition != null && !condition.value(actionManager.getActionOrStub(eachId)))
                continue;
            MyExternalSystemAction taskAction = (MyExternalSystemAction) eachAction;
            projectToActionsMapping.putValue(taskAction.getSystemId(), eachId);
        }
    }
    Map<ProjectSystemId, KeymapGroup> keymapGroupMap = ContainerUtil.newHashMap();
    for (ProjectSystemId systemId : projectToActionsMapping.keySet()) {
        if (!keymapGroupMap.containsKey(systemId)) {
            final Icon projectIcon = ExternalSystemUiUtil.getUiAware(systemId).getProjectIcon();
            KeymapGroup group = KeymapGroupFactory.getInstance().createGroup(systemId.getReadableName(), projectIcon);
            keymapGroupMap.put(systemId, group);
        }
    }
    for (Map.Entry<ProjectSystemId, Collection<String>> each : projectToActionsMapping.entrySet()) {
        Collection<String> tasks = each.getValue();
        final ProjectSystemId systemId = each.getKey();
        final KeymapGroup systemGroup = keymapGroupMap.get(systemId);
        if (systemGroup == null)
            continue;
        for (String actionId : tasks) {
            systemGroup.addActionId(actionId);
        }
        if (systemGroup instanceof Group) {
            Icon icon = SystemInfoRt.isMac ? AllIcons.ToolbarDecorator.Mac.Add : AllIcons.ToolbarDecorator.Add;
            ((Group) systemGroup).addHyperlink(new Hyperlink(icon, "Choose a task to assign a shortcut") {

                @Override
                public void onClick(MouseEvent e) {
                    SelectExternalTaskDialog dialog = new SelectExternalTaskDialog(systemId, project);
                    if (dialog.showAndGet() && dialog.getResult() != null) {
                        TaskData taskData = dialog.getResult().second;
                        String ownerModuleName = dialog.getResult().first;
                        ExternalSystemTaskAction externalSystemAction = (ExternalSystemTaskAction) getOrRegisterAction(project, ownerModuleName, taskData);
                        ApplicationManager.getApplication().getMessageBus().syncPublisher(KeymapListener.CHANGE_TOPIC).processCurrentKeymapChanged();
                        Settings allSettings = Settings.KEY.getData(DataManager.getInstance().getDataContext(e.getComponent()));
                        KeymapPanel keymapPanel = allSettings != null ? allSettings.find(KeymapPanel.class) : null;
                        if (keymapPanel != null) {
                            // clear actions filter
                            keymapPanel.showOption("");
                            keymapPanel.selectAction(externalSystemAction.myId);
                        }
                    }
                }
            });
        }
    }
    for (KeymapGroup keymapGroup : keymapGroupMap.values()) {
        if (isGroupFiltered(condition, keymapGroup)) {
            result.addGroup(keymapGroup);
        }
    }
    for (ActionsProvider extension : ActionsProvider.EP_NAME.getExtensions()) {
        KeymapGroup keymapGroup = extension.createGroup(condition, project);
        if (isGroupFiltered(condition, keymapGroup)) {
            result.addGroup(keymapGroup);
        }
    }
    return result;
}
Also used : KeymapGroup(com.intellij.openapi.keymap.KeymapGroup) TaskData(com.intellij.openapi.externalSystem.model.task.TaskData) Settings(com.intellij.openapi.options.ex.Settings) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) MouseEvent(java.awt.event.MouseEvent) KeymapGroup(com.intellij.openapi.keymap.KeymapGroup) SelectExternalTaskDialog(com.intellij.openapi.externalSystem.service.ui.SelectExternalTaskDialog) Collection(java.util.Collection) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId) Map(java.util.Map) MultiMap(com.intellij.util.containers.MultiMap)

Example 4 with Settings

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

the class JumpToColorsAndFontsAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    // todo handle ColorKey's as well
    Project project = e.getData(CommonDataKeys.PROJECT);
    Editor editor = e.getData(CommonDataKeys.EDITOR);
    if (project == null || editor == null)
        return;
    Map<TextAttributesKey, Pair<ColorSettingsPage, AttributesDescriptor>> keyMap = ContainerUtil.newHashMap();
    Processor<RangeHighlighterEx> processor = r -> {
        Object tt = r.getErrorStripeTooltip();
        TextAttributesKey key = tt instanceof HighlightInfo ? ObjectUtils.chooseNotNull(((HighlightInfo) tt).forcedTextAttributesKey, ((HighlightInfo) tt).type.getAttributesKey()) : null;
        Pair<ColorSettingsPage, AttributesDescriptor> p = key == null ? null : ColorSettingsPages.getInstance().getAttributeDescriptor(key);
        if (p != null)
            keyMap.put(key, p);
        return true;
    };
    JBIterable<Editor> editors = editor instanceof EditorWindow ? JBIterable.of(editor, ((EditorWindow) editor).getDelegate()) : JBIterable.of(editor);
    for (Editor ed : editors) {
        TextRange selection = EditorUtil.getSelectionInAnyMode(ed);
        MarkupModel forDocument = DocumentMarkupModel.forDocument(ed.getDocument(), project, false);
        if (forDocument != null) {
            ((MarkupModelEx) forDocument).processRangeHighlightersOverlappingWith(selection.getStartOffset(), selection.getEndOffset(), processor);
        }
        ((MarkupModelEx) ed.getMarkupModel()).processRangeHighlightersOverlappingWith(selection.getStartOffset(), selection.getEndOffset(), processor);
        EditorHighlighter highlighter = ed instanceof EditorEx ? ((EditorEx) ed).getHighlighter() : null;
        SyntaxHighlighter syntaxHighlighter = highlighter instanceof LexerEditorHighlighter ? ((LexerEditorHighlighter) highlighter).getSyntaxHighlighter() : null;
        if (syntaxHighlighter != null) {
            HighlighterIterator iterator = highlighter.createIterator(selection.getStartOffset());
            while (!iterator.atEnd()) {
                for (TextAttributesKey key : syntaxHighlighter.getTokenHighlights(iterator.getTokenType())) {
                    Pair<ColorSettingsPage, AttributesDescriptor> p = key == null ? null : ColorSettingsPages.getInstance().getAttributeDescriptor(key);
                    if (p != null)
                        keyMap.put(key, p);
                }
                if (iterator.getEnd() >= selection.getEndOffset())
                    break;
                iterator.advance();
            }
        }
    }
    if (keyMap.isEmpty()) {
        HintManager.getInstance().showErrorHint(editor, "No text attributes found");
    } else if (keyMap.size() == 1) {
        Pair<ColorSettingsPage, AttributesDescriptor> p = keyMap.values().iterator().next();
        if (!openSettingsAndSelectKey(project, p.first, p.second)) {
            HintManager.getInstance().showErrorHint(editor, "No appropriate settings page found");
        }
    } else {
        ArrayList<Pair<ColorSettingsPage, AttributesDescriptor>> attrs = ContainerUtil.newArrayList(keyMap.values());
        Collections.sort(attrs, (o1, o2) -> StringUtil.naturalCompare(o1.first.getDisplayName() + o1.second.getDisplayName(), o2.first.getDisplayName() + o2.second.getDisplayName()));
        EditorColorsScheme colorsScheme = editor.getColorsScheme();
        JBList<Pair<ColorSettingsPage, AttributesDescriptor>> list = new JBList<>(attrs);
        list.setCellRenderer(new ColoredListCellRenderer<Pair<ColorSettingsPage, AttributesDescriptor>>() {

            @Override
            protected void customizeCellRenderer(@NotNull JList<? extends Pair<ColorSettingsPage, AttributesDescriptor>> list, Pair<ColorSettingsPage, AttributesDescriptor> value, int index, boolean selected, boolean hasFocus) {
                TextAttributes ta = colorsScheme.getAttributes(value.second.getKey());
                Color fg = ObjectUtils.chooseNotNull(ta.getForegroundColor(), colorsScheme.getDefaultForeground());
                Color bg = ObjectUtils.chooseNotNull(ta.getBackgroundColor(), colorsScheme.getDefaultBackground());
                SimpleTextAttributes sa = fromTextAttributes(ta);
                SimpleTextAttributes saOpaque = sa.derive(STYLE_OPAQUE | sa.getStyle(), fg, bg, null);
                SimpleTextAttributes saSelected = REGULAR_ATTRIBUTES.derive(sa.getStyle(), null, null, null);
                SimpleTextAttributes saCur = REGULAR_ATTRIBUTES;
                List<String> split = StringUtil.split(value.first.getDisplayName() + "//" + value.second.getDisplayName(), "//");
                for (int i = 0, len = split.size(); i < len; i++) {
                    boolean last = i == len - 1;
                    saCur = !last ? REGULAR_ATTRIBUTES : selected ? saSelected : saOpaque;
                    if (last)
                        append(" ", saCur);
                    append(split.get(i), saCur);
                    if (last)
                        append(" ", saCur);
                    else
                        append(" > ", GRAYED_ATTRIBUTES);
                }
                Color stripeColor = ta.getErrorStripeColor();
                boolean addStripe = stripeColor != null && stripeColor != saCur.getBgColor();
                boolean addBoxed = ta.getEffectType() == EffectType.BOXED && ta.getEffectColor() != null;
                if (addBoxed) {
                    append("▢" + (addStripe ? "" : " "), saCur.derive(-1, ta.getEffectColor(), null, null));
                }
                if (addStripe) {
                    append(" ", saCur.derive(STYLE_OPAQUE, null, stripeColor, null));
                }
            }
        });
        JBPopupFactory.getInstance().createListPopupBuilder(list).setTitle(StringUtil.notNullize(e.getPresentation().getText())).setMovable(false).setResizable(false).setRequestFocus(true).setItemChoosenCallback(() -> {
            Pair<ColorSettingsPage, AttributesDescriptor> p = list.getSelectedValue();
            if (p != null && !openSettingsAndSelectKey(project, p.first, p.second)) {
                HintManager.getInstance().showErrorHint(editor, "No appropriate settings page found");
            }
        }).createPopup().showInBestPositionFor(editor);
    }
}
Also used : Settings(com.intellij.openapi.options.ex.Settings) JBIterable(com.intellij.util.containers.JBIterable) HighlightInfo(com.intellij.codeInsight.daemon.impl.HighlightInfo) EditorUtil(com.intellij.openapi.editor.ex.util.EditorUtil) MarkupModelEx(com.intellij.openapi.editor.ex.MarkupModelEx) DocumentMarkupModel(com.intellij.openapi.editor.impl.DocumentMarkupModel) ContainerUtil(com.intellij.util.containers.ContainerUtil) ColorSettingsPage(com.intellij.openapi.options.colors.ColorSettingsPage) ArrayList(java.util.ArrayList) SyntaxHighlighter(com.intellij.openapi.fileTypes.SyntaxHighlighter) ShowSettingsUtilImpl(com.intellij.ide.actions.ShowSettingsUtilImpl) RangeHighlighterEx(com.intellij.openapi.editor.ex.RangeHighlighterEx) HighlighterIterator(com.intellij.openapi.editor.highlighter.HighlighterIterator) Map(java.util.Map) EffectType(com.intellij.openapi.editor.markup.EffectType) Project(com.intellij.openapi.project.Project) EditorEx(com.intellij.openapi.editor.ex.EditorEx) CommonDataKeys(com.intellij.openapi.actionSystem.CommonDataKeys) LexerEditorHighlighter(com.intellij.openapi.editor.ex.util.LexerEditorHighlighter) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) JBList(com.intellij.ui.components.JBList) ColorSettingsPages(com.intellij.openapi.options.colors.ColorSettingsPages) EditorHighlighter(com.intellij.openapi.editor.highlighter.EditorHighlighter) StringUtil(com.intellij.openapi.util.text.StringUtil) ActionCallback(com.intellij.openapi.util.ActionCallback) EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) AttributesDescriptor(com.intellij.openapi.options.colors.AttributesDescriptor) SettingsDialog(com.intellij.openapi.options.newEditor.SettingsDialog) TextRange(com.intellij.openapi.util.TextRange) Editor(com.intellij.openapi.editor.Editor) EditorWindow(com.intellij.injected.editor.EditorWindow) MarkupModel(com.intellij.openapi.editor.markup.MarkupModel) java.awt(java.awt) TextAttributesKey(com.intellij.openapi.editor.colors.TextAttributesKey) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction) List(java.util.List) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory) ColoredListCellRenderer(com.intellij.ui.ColoredListCellRenderer) Processor(com.intellij.util.Processor) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) Pair(com.intellij.openapi.util.Pair) ObjectUtils(com.intellij.util.ObjectUtils) HintManager(com.intellij.codeInsight.hint.HintManager) NotNull(org.jetbrains.annotations.NotNull) Collections(java.util.Collections) SearchableConfigurable(com.intellij.openapi.options.SearchableConfigurable) javax.swing(javax.swing) EditorEx(com.intellij.openapi.editor.ex.EditorEx) HighlightInfo(com.intellij.codeInsight.daemon.impl.HighlightInfo) ArrayList(java.util.ArrayList) TextAttributesKey(com.intellij.openapi.editor.colors.TextAttributesKey) SyntaxHighlighter(com.intellij.openapi.fileTypes.SyntaxHighlighter) LexerEditorHighlighter(com.intellij.openapi.editor.ex.util.LexerEditorHighlighter) NotNull(org.jetbrains.annotations.NotNull) RangeHighlighterEx(com.intellij.openapi.editor.ex.RangeHighlighterEx) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) ColorSettingsPage(com.intellij.openapi.options.colors.ColorSettingsPage) Pair(com.intellij.openapi.util.Pair) LexerEditorHighlighter(com.intellij.openapi.editor.ex.util.LexerEditorHighlighter) EditorHighlighter(com.intellij.openapi.editor.highlighter.EditorHighlighter) AttributesDescriptor(com.intellij.openapi.options.colors.AttributesDescriptor) TextRange(com.intellij.openapi.util.TextRange) ColoredListCellRenderer(com.intellij.ui.ColoredListCellRenderer) EditorWindow(com.intellij.injected.editor.EditorWindow) Project(com.intellij.openapi.project.Project) MarkupModelEx(com.intellij.openapi.editor.ex.MarkupModelEx) JBList(com.intellij.ui.components.JBList) Editor(com.intellij.openapi.editor.Editor) DocumentMarkupModel(com.intellij.openapi.editor.impl.DocumentMarkupModel) MarkupModel(com.intellij.openapi.editor.markup.MarkupModel) HighlighterIterator(com.intellij.openapi.editor.highlighter.HighlighterIterator)

Example 5 with Settings

use of com.intellij.openapi.options.ex.Settings 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)

Aggregations

Settings (com.intellij.openapi.options.ex.Settings)10 DataContext (com.intellij.openapi.actionSystem.DataContext)5 SearchableConfigurable (com.intellij.openapi.options.SearchableConfigurable)4 Configurable (com.intellij.openapi.options.Configurable)3 Project (com.intellij.openapi.project.Project)3 KeymapGroup (com.intellij.openapi.keymap.KeymapGroup)2 SettingsDialog (com.intellij.openapi.options.newEditor.SettingsDialog)2 ActionCallback (com.intellij.openapi.util.ActionCallback)2 Pair (com.intellij.openapi.util.Pair)2 MouseEvent (java.awt.event.MouseEvent)2 Map (java.util.Map)2 javax.swing (javax.swing)2 CodeStyleSchemesConfigurable (com.intellij.application.options.CodeStyleSchemesConfigurable)1 ColorAndFontOptions (com.intellij.application.options.colors.ColorAndFontOptions)1 HighlightInfo (com.intellij.codeInsight.daemon.impl.HighlightInfo)1 HintManager (com.intellij.codeInsight.hint.HintManager)1 CompilerConfigurable (com.intellij.compiler.options.CompilerConfigurable)1 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)1 AllIcons (com.intellij.icons.AllIcons)1 DataManager (com.intellij.ide.DataManager)1