Search in sources :

Example 56 with EditorColorsScheme

use of com.intellij.openapi.editor.colors.EditorColorsScheme in project android by JetBrains.

the class HtmlBuilderHelper method fixFontStyles.

/**
   * Adjust the font styles of the given text component, provided it's
   * an HTML styled document, to use fonts from the current IDE scheme.
   * <p>
   * Note: Calling setText() on a component will reset the document styles
   * so you will need to call this method repeatedly after each document
   * replace.
   *
   * @param component the component
   */
public static void fixFontStyles(@NotNull JTextComponent component) {
    Document document = component.getDocument();
    if (!(document instanceof StyledDocument)) {
        return;
    }
    StyledDocument styledDocument = (StyledDocument) document;
    EditorColorsManager colorsManager = EditorColorsManager.getInstance();
    EditorColorsScheme scheme = colorsManager.getGlobalScheme();
    Style style = styledDocument.addStyle("active", null);
    StyleConstants.setFontFamily(style, scheme.getEditorFontName());
    StyleConstants.setFontSize(style, scheme.getEditorFontSize());
    styledDocument.setCharacterAttributes(0, document.getLength(), style, false);
}
Also used : EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) EditorColorsManager(com.intellij.openapi.editor.colors.EditorColorsManager)

Example 57 with EditorColorsScheme

use of com.intellij.openapi.editor.colors.EditorColorsScheme in project android by JetBrains.

the class AndroidStudioInitializer method run.

@Override
public void run() {
    checkInstallation();
    removeIdeSettings();
    setUpNewFilePopupActions();
    setUpMakeActions();
    disableGroovyLanguageInjection();
    setUpNewProjectActions();
    setUpExperimentalFeatures();
    setupAnalytics();
    disableGradleOrderEnumeratorHandler();
    disableIdeaJUnitConfigurations();
    // Modify built-in "Default" color scheme to remove background from XML tags.
    // "Darcula" and user schemes will not be touched.
    EditorColorsScheme colorsScheme = EditorColorsManager.getInstance().getScheme(EditorColorsScheme.DEFAULT_SCHEME_NAME);
    TextAttributes textAttributes = colorsScheme.getAttributes(HighlighterColors.TEXT);
    TextAttributes xmlTagAttributes = colorsScheme.getAttributes(XmlHighlighterColors.XML_TAG);
    xmlTagAttributes.setBackgroundColor(textAttributes.getBackgroundColor());
/* Causes IDE startup failure (from the command line)
          Caused by: java.lang.IllegalAccessError: tried to access class com.intellij.ui.tabs.FileColorConfiguration from class com.intellij.ui.tabs.FileColorConfigurationUtil
          at com.intellij.ui.tabs.FileColorConfigurationUtil.createFileColorConfigurationIfNotExist(FileColorConfigurationUtil.java:37)
          at com.intellij.ui.tabs.FileColorConfigurationUtil.createAndroidTestFileColorConfigurationIfNotExist(FileColorConfigurationUtil.java:28)
          at com.android.tools.idea.startup.AndroidStudioInitializer.run(AndroidStudioInitializer.java:90)
    FileColorConfigurationUtil.createAndroidTestFileColorConfigurationIfNotExist(ProjectManager.getInstance().getDefaultProject());
     */
}
Also used : TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme)

Example 58 with EditorColorsScheme

use of com.intellij.openapi.editor.colors.EditorColorsScheme in project Perl5-IDEA by Camelcade.

the class PerlLightTestCase method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    myDisposable = Disposer.newDisposable();
    EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
    myReadAttributes = scheme.getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
    myWriteAttributes = scheme.getAttributes(EditorColors.WRITE_SEARCH_RESULT_ATTRIBUTES);
    ElementManipulators.INSTANCE.addExplicitExtension(PerlStringMixin.class, new PerlStringManipulator());
    ElementManipulators.INSTANCE.addExplicitExtension(PerlStringBareMixin.class, new PerlBareStringManipulator());
    ElementManipulators.INSTANCE.addExplicitExtension(PerlStringContentElement.class, new PerlStringContentManipulator());
    setUpLibrary();
    myCodeInsightSettings = Perl5CodeInsightSettings.getInstance().copy();
}
Also used : PerlBareStringManipulator(com.perl5.lang.perl.idea.manipulators.PerlBareStringManipulator) EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) PerlStringContentManipulator(com.perl5.lang.perl.idea.manipulators.PerlStringContentManipulator) PerlStringManipulator(com.perl5.lang.perl.idea.manipulators.PerlStringManipulator)

Example 59 with EditorColorsScheme

use of com.intellij.openapi.editor.colors.EditorColorsScheme in project intellij-plugins by StepicOrg.

the class StudyBrowserWindow method getContent.

@NotNull
private String getContent(@NotNull final String template, @NotNull Map<String, Object> params) {
    final EditorColorsScheme editorColorsScheme = EditorColorsManager.getInstance().getGlobalScheme();
    int fontSize = editorColorsScheme.getEditorFontSize();
    Map<String, Object> map = new HashMap<>();
    map.put("font_size", String.valueOf(fontSize - 2));
    map.put("highlight", getExternalURL("/highlight/highlight.pack.js"));
    if (LafManager.getInstance().getCurrentLookAndFeel() instanceof DarculaLookAndFeelInfo) {
        map.put("css_highlight", getExternalURL("/highlight/styles/darcula.css"));
    } else {
        map.put("css_highlight", getExternalURL("/highlight/styles/idea.css"));
    }
    map.put("charset", Charset.defaultCharset().displayName());
    map.put("loader", getExternalURL("/templates/img/loader.svg"));
    map.put("login_css", getExternalURL("/templates/login/css/login.css"));
    map.putAll(params);
    return Templater.processTemplate(template, map);
}
Also used : HashMap(java.util.HashMap) EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) JSObject(netscape.javascript.JSObject) DarculaLookAndFeelInfo(com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo) NotNull(org.jetbrains.annotations.NotNull)

Example 60 with EditorColorsScheme

use of com.intellij.openapi.editor.colors.EditorColorsScheme 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

EditorColorsScheme (com.intellij.openapi.editor.colors.EditorColorsScheme)105 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)31 NotNull (org.jetbrains.annotations.NotNull)28 EditorColorsManager (com.intellij.openapi.editor.colors.EditorColorsManager)17 Nullable (org.jetbrains.annotations.Nullable)15 Document (com.intellij.openapi.editor.Document)14 Project (com.intellij.openapi.project.Project)14 TextAttributesKey (com.intellij.openapi.editor.colors.TextAttributesKey)12 Editor (com.intellij.openapi.editor.Editor)11 DocumentMarkupModel (com.intellij.openapi.editor.impl.DocumentMarkupModel)10 EditorEx (com.intellij.openapi.editor.ex.EditorEx)8 TextRange (com.intellij.openapi.util.TextRange)8 EditorHighlighter (com.intellij.openapi.editor.highlighter.EditorHighlighter)7 PsiFile (com.intellij.psi.PsiFile)7 List (java.util.List)7 HighlightSeverity (com.intellij.lang.annotation.HighlightSeverity)6 ApplicationManager (com.intellij.openapi.application.ApplicationManager)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)6 java.awt (java.awt)6 java.util (java.util)6