Search in sources :

Example 1 with DefaultColorsScheme

use of com.intellij.openapi.editor.colors.impl.DefaultColorsScheme in project intellij-community by JetBrains.

the class DocumentMarkupModelTest method testInfoTestAttributes.

public void testInfoTestAttributes() throws Exception {
    LanguageExtensionPoint<Annotator> extension = new LanguageExtensionPoint<>();
    extension.language = "TEXT";
    extension.implementationClass = TestAnnotator.class.getName();
    PlatformTestUtil.registerExtension(ExtensionPointName.create(LanguageAnnotators.EP_NAME), extension, myFixture.getTestRootDisposable());
    myFixture.configureByText(PlainTextFileType.INSTANCE, "foo");
    EditorColorsScheme scheme = new EditorColorsSchemeImpl(new DefaultColorsScheme()) {

        {
            initFonts();
        }
    };
    scheme.setAttributes(HighlighterColors.TEXT, new TextAttributes(Color.black, Color.white, null, null, Font.PLAIN));
    ((EditorEx) myFixture.getEditor()).setColorsScheme(scheme);
    myFixture.doHighlighting();
    MarkupModel model = DocumentMarkupModel.forDocument(myFixture.getEditor().getDocument(), getProject(), false);
    RangeHighlighter[] highlighters = model.getAllHighlighters();
    assertThat(highlighters).hasSize(1);
    TextAttributes attributes = highlighters[0].getTextAttributes();
    assertThat(attributes).isNotNull();
    assertThat(attributes.getBackgroundColor()).isNull();
    assertThat(attributes.getForegroundColor()).isNull();
}
Also used : RangeHighlighter(com.intellij.openapi.editor.markup.RangeHighlighter) EditorEx(com.intellij.openapi.editor.ex.EditorEx) Annotator(com.intellij.lang.annotation.Annotator) EditorColorsSchemeImpl(com.intellij.openapi.editor.colors.impl.EditorColorsSchemeImpl) DefaultColorsScheme(com.intellij.openapi.editor.colors.impl.DefaultColorsScheme) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) LanguageExtensionPoint(com.intellij.lang.LanguageExtensionPoint) MarkupModel(com.intellij.openapi.editor.markup.MarkupModel)

Example 2 with DefaultColorsScheme

use of com.intellij.openapi.editor.colors.impl.DefaultColorsScheme in project intellij-community by JetBrains.

the class ColorSchemeActions method exportScheme.

@Override
protected void exportScheme(@NotNull EditorColorsScheme scheme, @NotNull String exporterName) {
    EditorColorsScheme schemeToExport = scheme;
    if (scheme instanceof AbstractColorsScheme) {
        EditorColorsScheme parent = ((AbstractColorsScheme) scheme).getParentScheme();
        if (!(parent instanceof DefaultColorsScheme)) {
            schemeToExport = parent;
        }
    }
    if (schemeToExport.getName().startsWith(SchemeManager.EDITABLE_COPY_PREFIX)) {
        schemeToExport = (EditorColorsScheme) schemeToExport.clone();
        schemeToExport.setName(SchemeManager.getDisplayName(schemeToExport));
    }
    super.exportScheme(schemeToExport, exporterName);
}
Also used : AbstractColorsScheme(com.intellij.openapi.editor.colors.impl.AbstractColorsScheme) DefaultColorsScheme(com.intellij.openapi.editor.colors.impl.DefaultColorsScheme) EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme)

Example 3 with DefaultColorsScheme

use of com.intellij.openapi.editor.colors.impl.DefaultColorsScheme in project intellij-community by JetBrains.

the class DefaultColorSchemesManager method loadState.

@Override
public void loadState(Element state) {
    List<DefaultColorsScheme> schemes = new ArrayList<>();
    for (Element schemeElement : state.getChildren(SCHEME_ELEMENT)) {
        boolean isUpdated = false;
        Attribute nameAttr = schemeElement.getAttribute(NAME_ATTR);
        if (nameAttr != null) {
            for (DefaultColorsScheme oldScheme : mySchemes) {
                if (StringUtil.equals(nameAttr.getValue(), oldScheme.getName())) {
                    oldScheme.readExternal(schemeElement);
                    schemes.add(oldScheme);
                    isUpdated = true;
                }
            }
        }
        if (!isUpdated) {
            DefaultColorsScheme newScheme = new DefaultColorsScheme();
            newScheme.readExternal(schemeElement);
            schemes.add(newScheme);
        }
    }
    schemes.add(EmptyColorScheme.INSTANCE);
    mySchemes = schemes;
}
Also used : DefaultColorsScheme(com.intellij.openapi.editor.colors.impl.DefaultColorsScheme) Attribute(org.jdom.Attribute) Element(org.jdom.Element) ArrayList(java.util.ArrayList)

Aggregations

DefaultColorsScheme (com.intellij.openapi.editor.colors.impl.DefaultColorsScheme)3 EditorColorsScheme (com.intellij.openapi.editor.colors.EditorColorsScheme)2 LanguageExtensionPoint (com.intellij.lang.LanguageExtensionPoint)1 Annotator (com.intellij.lang.annotation.Annotator)1 AbstractColorsScheme (com.intellij.openapi.editor.colors.impl.AbstractColorsScheme)1 EditorColorsSchemeImpl (com.intellij.openapi.editor.colors.impl.EditorColorsSchemeImpl)1 EditorEx (com.intellij.openapi.editor.ex.EditorEx)1 MarkupModel (com.intellij.openapi.editor.markup.MarkupModel)1 RangeHighlighter (com.intellij.openapi.editor.markup.RangeHighlighter)1 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)1 ArrayList (java.util.ArrayList)1 Attribute (org.jdom.Attribute)1 Element (org.jdom.Element)1