Search in sources :

Example 1 with ColorAndFontOptions

use of com.intellij.application.options.colors.ColorAndFontOptions 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 ColorAndFontOptions

use of com.intellij.application.options.colors.ColorAndFontOptions in project intellij-community by JetBrains.

the class SetBackgroundImageDialog method createEditorPreview.

@NotNull
private static SimpleEditorPreview createEditorPreview() {
    EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
    ColorAndFontOptions options = new ColorAndFontOptions();
    options.reset();
    options.selectScheme(scheme.getName());
    ColorSettingsPage[] pages = ColorSettingsPages.getInstance().getRegisteredPages();
    int index;
    int attempt = 0;
    do {
        index = (int) Math.round(Math.random() * (pages.length - 1));
    } while (StringUtil.countNewLines(pages[index].getDemoText()) < 8 && ++attempt < 10);
    return new SimpleEditorPreview(options, pages[index], false);
}
Also used : ColorAndFontOptions(com.intellij.application.options.colors.ColorAndFontOptions) EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) ColorSettingsPage(com.intellij.openapi.options.colors.ColorSettingsPage) SimpleEditorPreview(com.intellij.application.options.colors.SimpleEditorPreview) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ColorAndFontOptions (com.intellij.application.options.colors.ColorAndFontOptions)2 SimpleEditorPreview (com.intellij.application.options.colors.SimpleEditorPreview)1 DataContext (com.intellij.openapi.actionSystem.DataContext)1 EditorColorsScheme (com.intellij.openapi.editor.colors.EditorColorsScheme)1 Configurable (com.intellij.openapi.options.Configurable)1 SearchableConfigurable (com.intellij.openapi.options.SearchableConfigurable)1 ColorSettingsPage (com.intellij.openapi.options.colors.ColorSettingsPage)1 Settings (com.intellij.openapi.options.ex.Settings)1 NotNull (org.jetbrains.annotations.NotNull)1