Java 类com.intellij.openapi.editor.HighlighterColors 实例源码

项目:intellij-ce-playground    文件:Annotation.java   
/**
 * Returns the text attribute key used for highlighting the annotation. If not specified
 * explicitly, the key is determined automatically based on the problem highlight type and
 * the annotation severity.
 *
 * @return the text attribute key used for highlighting
 */
@NotNull
public TextAttributesKey getTextAttributes() {
  if (myEnforcedAttributesKey != null) return myEnforcedAttributesKey;

  if (myHighlightType == ProblemHighlightType.GENERIC_ERROR_OR_WARNING) {
    if (mySeverity == HighlightSeverity.ERROR) return CodeInsightColors.ERRORS_ATTRIBUTES;
    if (mySeverity == HighlightSeverity.WARNING) return CodeInsightColors.WARNINGS_ATTRIBUTES;
    if (mySeverity == HighlightSeverity.WEAK_WARNING) return CodeInsightColors.WEAK_WARNING_ATTRIBUTES;
  }

  if (myHighlightType == ProblemHighlightType.GENERIC_ERROR) {
    return CodeInsightColors.ERRORS_ATTRIBUTES;
  }

  if (myHighlightType == ProblemHighlightType.LIKE_DEPRECATED) {
    return CodeInsightColors.DEPRECATED_ATTRIBUTES;
  }
  if (myHighlightType == ProblemHighlightType.LIKE_UNUSED_SYMBOL) {
    return CodeInsightColors.NOT_USED_ELEMENT_ATTRIBUTES;
  }
  if (myHighlightType == ProblemHighlightType.LIKE_UNKNOWN_SYMBOL || myHighlightType == ProblemHighlightType.ERROR) {
    return CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES;
  }
  return HighlighterColors.NO_HIGHLIGHTING;
}
项目:intellij-ce-playground    文件:DocumentMarkupModelTest.java   
public void testInfoTestAttributes() throws Exception {
  LanguageExtensionPoint<Annotator> extension = new LanguageExtensionPoint<Annotator>();
  extension.language="TEXT";
  extension.implementationClass = TestAnnotator.class.getName();
  PlatformTestUtil.registerExtension(ExtensionPointName.create(LanguageAnnotators.EP_NAME), extension, 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();
  assertEquals(1, highlighters.length);
  TextAttributes attributes = highlighters[0].getTextAttributes();
  assertNotNull(attributes);
  assertNull(attributes.getBackgroundColor());
  assertNull(attributes.getForegroundColor());
}
项目:tools-idea    文件:Annotation.java   
/**
 * Returns the text attribute key used for highlighting the annotation. If not specified
 * explicitly, the key is determined automatically based on the problem highlight type and
 * the annotation severity.
 *
 * @return the text attribute key used for highlighting
 */
public TextAttributesKey getTextAttributes() {
  if (myEnforcedAttributesKey != null) return myEnforcedAttributesKey;

  if (myHighlightType == ProblemHighlightType.GENERIC_ERROR_OR_WARNING) {
    if (mySeverity == HighlightSeverity.ERROR) return CodeInsightColors.ERRORS_ATTRIBUTES;
    if (mySeverity == HighlightSeverity.WARNING) return CodeInsightColors.WARNINGS_ATTRIBUTES;
    if (mySeverity == HighlightSeverity.WEAK_WARNING) return CodeInsightColors.WEAK_WARNING_ATTRIBUTES;
  }

  if (myHighlightType == ProblemHighlightType.GENERIC_ERROR) {
    return CodeInsightColors.ERRORS_ATTRIBUTES;
  }

  if (myHighlightType == ProblemHighlightType.LIKE_DEPRECATED) {
    return CodeInsightColors.DEPRECATED_ATTRIBUTES;
  }
  if (myHighlightType == ProblemHighlightType.LIKE_UNUSED_SYMBOL) {
    return CodeInsightColors.NOT_USED_ELEMENT_ATTRIBUTES;
  }
  if (myHighlightType == ProblemHighlightType.LIKE_UNKNOWN_SYMBOL || myHighlightType == ProblemHighlightType.ERROR) {
    return CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES;
  }
  return HighlighterColors.TEXT;
}
项目:consulo    文件:Annotation.java   
/**
 * Returns the text attribute key used for highlighting the annotation. If not specified
 * explicitly, the key is determined automatically based on the problem highlight type and
 * the annotation severity.
 *
 * @return the text attribute key used for highlighting
 */
@Nonnull
public TextAttributesKey getTextAttributes() {
  if (myEnforcedAttributesKey != null) return myEnforcedAttributesKey;

  if (myHighlightType == ProblemHighlightType.GENERIC_ERROR_OR_WARNING) {
    if (mySeverity == HighlightSeverity.ERROR) return CodeInsightColors.ERRORS_ATTRIBUTES;
    if (mySeverity == HighlightSeverity.WARNING) return CodeInsightColors.WARNINGS_ATTRIBUTES;
    if (mySeverity == HighlightSeverity.WEAK_WARNING) return CodeInsightColors.WEAK_WARNING_ATTRIBUTES;
  }

  if (myHighlightType == ProblemHighlightType.GENERIC_ERROR) {
    return CodeInsightColors.ERRORS_ATTRIBUTES;
  }

  if (myHighlightType == ProblemHighlightType.LIKE_DEPRECATED) {
    return CodeInsightColors.DEPRECATED_ATTRIBUTES;
  }
  if (myHighlightType == ProblemHighlightType.LIKE_UNUSED_SYMBOL) {
    return CodeInsightColors.NOT_USED_ELEMENT_ATTRIBUTES;
  }
  if (myHighlightType == ProblemHighlightType.LIKE_UNKNOWN_SYMBOL || myHighlightType == ProblemHighlightType.ERROR) {
    return CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES;
  }
  return HighlighterColors.NO_HIGHLIGHTING;
}
项目:intellij-ce-playground    文件:HighlightInfo.java   
@NotNull
static HighlightInfo fromAnnotation(@NotNull Annotation annotation, @Nullable TextRange fixedRange, boolean batchMode) {
  final TextAttributes forcedAttributes = annotation.getEnforcedTextAttributes();
  TextAttributesKey key = annotation.getTextAttributes();
  final TextAttributesKey forcedAttributesKey = forcedAttributes == null ? (key == HighlighterColors.NO_HIGHLIGHTING ? null : key) : null;

  HighlightInfo info = new HighlightInfo(forcedAttributes, forcedAttributesKey, convertType(annotation),
                                         fixedRange != null? fixedRange.getStartOffset() : annotation.getStartOffset(),
                                         fixedRange != null? fixedRange.getEndOffset() : annotation.getEndOffset(),
                                         annotation.getMessage(), annotation.getTooltip(),
                                         annotation.getSeverity(), annotation.isAfterEndOfLine(), annotation.needsUpdateOnTyping(), annotation.isFileLevelAnnotation(),
                                         0, annotation.getProblemGroup(), annotation.getGutterIconRenderer());
  appendFixes(fixedRange, info, batchMode ? annotation.getBatchFixes() : annotation.getQuickFixes());
  return info;
}
项目:intellij-ce-playground    文件:ClickNavigator.java   
public static String highlightingTypeFromTokenType(IElementType tokenType, SyntaxHighlighter highlighter) {
  TextAttributesKey[] highlights = highlighter.getTokenHighlights(tokenType);
  String s = null;
  for (int i = highlights.length - 1; i >= 0; i--) {
    if (highlights[i] != HighlighterColors.TEXT) {
      s = highlights[i].getExternalName();
      break;
    }
  }
  return s == null ? HighlighterColors.TEXT.getExternalName() : s;
}
项目:intellij-ce-playground    文件:HighlightData.java   
public void addHighlToView(final Editor view, EditorColorsScheme scheme, final Map<TextAttributesKey,String> displayText) {

    // XXX: Hack
    if (HighlighterColors.BAD_CHARACTER.equals(myHighlightType)) {
      return;
    }

    final TextAttributes attr = scheme.getAttributes(myHighlightType);
    if (attr != null) {
      UIUtil.invokeAndWaitIfNeeded(new Runnable() {
        @Override
        public void run() {
          try {
            // IDEA-53203: add ERASE_MARKER for manually defined attributes
            view.getMarkupModel().addRangeHighlighter(myStartOffset, myEndOffset, HighlighterLayer.ADDITIONAL_SYNTAX,
                                                      TextAttributes.ERASE_MARKER, HighlighterTargetArea.EXACT_RANGE);
            RangeHighlighter highlighter = view.getMarkupModel()
              .addRangeHighlighter(myStartOffset, myEndOffset, HighlighterLayer.ADDITIONAL_SYNTAX, attr,
                                   HighlighterTargetArea.EXACT_RANGE);
            final Color errorStripeColor = attr.getErrorStripeColor();
            highlighter.setErrorStripeMarkColor(errorStripeColor);
            final String tooltip = displayText.get(myHighlightType);
            highlighter.setErrorStripeTooltip(tooltip);
          }
          catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
      });
    }
  }
项目:intellij-ce-playground    文件:PyHighlighter.java   
/**
 * The 'heavy' constructor that initializes everything. PySyntaxHighlighterFactory caches such instances per level.
 * @param languageLevel
 */
public PyHighlighter(LanguageLevel languageLevel) {
  myLanguageLevel = languageLevel;
  keys = new HashMap<IElementType, TextAttributesKey>();

  fillMap(keys, PythonDialectsTokenSetProvider.INSTANCE.getKeywordTokens(), PY_KEYWORD);
  fillMap(keys, PyTokenTypes.OPERATIONS, PY_OPERATION_SIGN);

  keys.put(PyTokenTypes.INTEGER_LITERAL, PY_NUMBER);
  keys.put(PyTokenTypes.FLOAT_LITERAL, PY_NUMBER);
  keys.put(PyTokenTypes.IMAGINARY_LITERAL, PY_NUMBER);
  keys.put(PyTokenTypes.SINGLE_QUOTED_STRING, PY_BYTE_STRING);
  keys.put(PyTokenTypes.TRIPLE_QUOTED_STRING, PY_BYTE_STRING);
  keys.put(PyTokenTypes.SINGLE_QUOTED_UNICODE, PY_UNICODE_STRING);
  keys.put(PyTokenTypes.TRIPLE_QUOTED_UNICODE, PY_UNICODE_STRING);

  keys.put(PyTokenTypes.DOCSTRING, PY_DOC_COMMENT);

  keys.put(PyTokenTypes.LPAR, PY_PARENTHS);
  keys.put(PyTokenTypes.RPAR, PY_PARENTHS);

  keys.put(PyTokenTypes.LBRACE, PY_BRACES);
  keys.put(PyTokenTypes.RBRACE, PY_BRACES);

  keys.put(PyTokenTypes.LBRACKET, PY_BRACKETS);
  keys.put(PyTokenTypes.RBRACKET, PY_BRACKETS);

  keys.put(PyTokenTypes.COMMA, PY_COMMA);
  keys.put(PyTokenTypes.DOT, PY_DOT);

  keys.put(PyTokenTypes.END_OF_LINE_COMMENT, PY_LINE_COMMENT);
  keys.put(PyTokenTypes.BAD_CHARACTER, HighlighterColors.BAD_CHARACTER);

  keys.put(StringEscapesTokenTypes.VALID_STRING_ESCAPE_TOKEN, PY_VALID_STRING_ESCAPE);
  keys.put(StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN, PY_INVALID_STRING_ESCAPE);
  keys.put(StringEscapesTokenTypes.INVALID_UNICODE_ESCAPE_TOKEN, PY_INVALID_STRING_ESCAPE);
}
项目:intellij-ce-playground    文件:PyConsoleSourceHighlighter.java   
protected TextAttributes convertAttributes(TextAttributesKey[] keys) {
  EditorColorsScheme scheme = myScheme;
  TextAttributes attrs = scheme.getAttributes(HighlighterColors.TEXT);
  for (TextAttributesKey key : keys) {
    TextAttributes attrs2 = scheme.getAttributes(key);
    if (attrs2 != null) {
      attrs = TextAttributes.merge(attrs, attrs2);
    }
  }
  return attrs;
}
项目:jetbrains-plugin-st4    文件:STGroupSyntaxHighlighter.java   
@NotNull
@Override
public TextAttributesKey[] getAttributesKey(Token t) {
    switch (t.getType()) {
        case STGLexer.DOC_COMMENT:
            return COMMENT_KEYS;
        case STGLexer.LINE_COMMENT:
            return COMMENT_KEYS;
        case STGLexer.BLOCK_COMMENT:
            return COMMENT_KEYS;
        case STGLexer.ID:
            return new TextAttributesKey[]{STGroup_TEMPLATE_NAME};

        case STGLexer.DELIMITERS:
        case STGLexer.IMPORT:
        case STGLexer.DEFAULT:
        case STGLexer.KEY:
        case STGLexer.VALUE:
        case STGLexer.FIRST:
        case STGLexer.LAST:
        case STGLexer.REST:
        case STGLexer.TRUNC:
        case STGLexer.STRIP:
        case STGLexer.TRIM:
        case STGLexer.LENGTH:
        case STGLexer.STRLEN:
        case STGLexer.REVERSE:
        case STGLexer.GROUP:
        case STGLexer.WRAP:
        case STGLexer.ANCHOR:
        case STGLexer.SEPARATOR:
            return new TextAttributesKey[]{DefaultLanguageHighlighterColors.KEYWORD};
        case Token.INVALID_TYPE:
            return new TextAttributesKey[]{HighlighterColors.BAD_CHARACTER};
        default:
            return EMPTY;
    }
}
项目:jetbrains-plugin-st4    文件:STSyntaxHighlighter.java   
@NotNull
@Override
public TextAttributesKey[] getAttributesKey(Token t) {
    int tokenType = t.getType();
    TextAttributesKey key;
    switch ( tokenType ) {
        case STLexer.IF:
        case STLexer.ELSE:
        case STLexer.REGION_END:
        case STLexer.TRUE:
        case STLexer.FALSE:
        case STLexer.ELSEIF:
        case STLexer.ENDIF:
        case STLexer.SUPER:
            key = DefaultLanguageHighlighterColors.KEYWORD;
            break;
        case STLexer.ID:
            key = ST_ID;
            break;
        case STLexer.STRING:
        case STLexer.TEXT:
            key = STGroup_TEMPLATE_TEXT;
            break;
        case STLexer.COMMENT:
            key = DefaultLanguageHighlighterColors.LINE_COMMENT;
            break;
        case STLexer.ERROR_TYPE :
            key = HighlighterColors.BAD_CHARACTER;
            break;
        default:
            return EMPTY;
    }
    return new TextAttributesKey[]{key};
}
项目:tools-idea    文件:ChunkExtractor.java   
@NotNull
private TextAttributes convertAttributes(@NotNull TextAttributesKey[] keys) {
  TextAttributes attrs = myColorsScheme.getAttributes(HighlighterColors.TEXT);

  for (TextAttributesKey key : keys) {
    TextAttributes attrs2 = myColorsScheme.getAttributes(key);
    if (attrs2 != null) {
      attrs = TextAttributes.merge(attrs, attrs2);
    }
  }

  attrs = attrs.clone();
  return attrs;
}
项目:tools-idea    文件:FragmentedEditorHighlighter.java   
private boolean isUsualAttributes(final TextAttributes ta) {
  if (myUsualAttributes == null) {
    final EditorColorsManager manager = EditorColorsManager.getInstance();
    final EditorColorsScheme[] schemes = manager.getAllSchemes();
    EditorColorsScheme defaultScheme = schemes[0];
    for (EditorColorsScheme scheme : schemes) {
      if (manager.isDefaultScheme(scheme)) {
        defaultScheme = scheme;
        break;
      }
    }
    myUsualAttributes = defaultScheme.getAttributes(HighlighterColors.TEXT);
  }
  return myUsualAttributes.equals(ta);
}
项目:tools-idea    文件:LexerEditorHighlighter.java   
protected TextAttributes convertAttributes(@NotNull TextAttributesKey[] keys) {
  TextAttributes attrs = myScheme.getAttributes(HighlighterColors.TEXT);
  for (TextAttributesKey key : keys) {
    TextAttributes attrs2 = myScheme.getAttributes(key);
    if (attrs2 != null) {
      attrs = TextAttributes.merge(attrs, attrs2);
    }
  }
  return attrs;
}
项目:tools-idea    文件:ClickNavigator.java   
public static String highlightingTypeFromTokenType(IElementType tokenType, SyntaxHighlighter highlighter) {
  TextAttributesKey[] highlights = highlighter.getTokenHighlights(tokenType);
  String s = null;
  for (int i = highlights.length - 1; i >= 0; i--) {
    if (highlights[i] != HighlighterColors.TEXT) {
      s = highlights[i].getExternalName();
      break;
    }
  }
  return s == null ? HighlighterColors.TEXT.getExternalName() : s;
}
项目:tools-idea    文件:HighlightData.java   
public void addHighlToView(final Editor view, EditorColorsScheme scheme, final Map<TextAttributesKey,String> displayText) {

    // XXX: Hack
    if (HighlighterColors.BAD_CHARACTER.equals(myHighlightType)) {
      return;
    }

    final TextAttributes attr = scheme.getAttributes(myHighlightType);
    if (attr != null) {
      UIUtil.invokeAndWaitIfNeeded(new Runnable() {
        @Override
        public void run() {
          try {
            // IDEA-53203: add ERASE_MARKER for manually defined attributes
            view.getMarkupModel().addRangeHighlighter(myStartOffset, myEndOffset, HighlighterLayer.ADDITIONAL_SYNTAX,
                                                      TextAttributes.ERASE_MARKER, HighlighterTargetArea.EXACT_RANGE);
            RangeHighlighter highlighter = view.getMarkupModel()
              .addRangeHighlighter(myStartOffset, myEndOffset, HighlighterLayer.ADDITIONAL_SYNTAX, attr,
                                   HighlighterTargetArea.EXACT_RANGE);
            final Color errorStripeColor = attr.getErrorStripeColor();
            highlighter.setErrorStripeMarkColor(errorStripeColor);
            final String tooltip = displayText.get(myHighlightType);
            highlighter.setErrorStripeTooltip(tooltip);
          }
          catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
      });
    }
  }
项目:consulo    文件:ChunkExtractor.java   
@Nonnull
private TextAttributes convertAttributes(@Nonnull TextAttributesKey[] keys) {
  TextAttributes attrs = myColorsScheme.getAttributes(HighlighterColors.TEXT);

  for (TextAttributesKey key : keys) {
    TextAttributes attrs2 = myColorsScheme.getAttributes(key);
    if (attrs2 != null) {
      attrs = TextAttributes.merge(attrs, attrs2);
    }
  }

  attrs = attrs.clone();
  return attrs;
}
项目:consulo    文件:FragmentedEditorHighlighter.java   
private boolean isUsualAttributes(final TextAttributes ta) {
  if (myUsualAttributes == null) {
    final EditorColorsManager manager = EditorColorsManager.getInstance();
    final EditorColorsScheme[] schemes = manager.getAllSchemes();
    EditorColorsScheme defaultScheme = schemes[0];
    for (EditorColorsScheme scheme : schemes) {
      if (manager.isDefaultScheme(scheme)) {
        defaultScheme = scheme;
        break;
      }
    }
    myUsualAttributes = defaultScheme.getAttributes(HighlighterColors.TEXT);
  }
  return myUsualAttributes.equals(ta);
}
项目:consulo    文件:HighlightInfo.java   
@Nonnull
static HighlightInfo fromAnnotation(@Nonnull Annotation annotation, @Nullable TextRange fixedRange, boolean batchMode) {
  final TextAttributes forcedAttributes = annotation.getEnforcedTextAttributes();
  TextAttributesKey key = annotation.getTextAttributes();
  final TextAttributesKey forcedAttributesKey = forcedAttributes == null ? (key == HighlighterColors.NO_HIGHLIGHTING ? null : key) : null;

  HighlightInfo info = new HighlightInfo(forcedAttributes, forcedAttributesKey, convertType(annotation),
                                         fixedRange != null? fixedRange.getStartOffset() : annotation.getStartOffset(),
                                         fixedRange != null? fixedRange.getEndOffset() : annotation.getEndOffset(),
                                         annotation.getMessage(), annotation.getTooltip(),
                                         annotation.getSeverity(), annotation.isAfterEndOfLine(), annotation.needsUpdateOnTyping(), annotation.isFileLevelAnnotation(),
                                         0, annotation.getProblemGroup(), annotation.getGutterIconRenderer());
  appendFixes(fixedRange, info, batchMode ? annotation.getBatchFixes() : annotation.getQuickFixes());
  return info;
}
项目:consulo    文件:ClickNavigator.java   
public static String highlightingTypeFromTokenType(IElementType tokenType, SyntaxHighlighter highlighter) {
  TextAttributesKey[] highlights = highlighter.getTokenHighlights(tokenType);
  String s = null;
  for (int i = highlights.length - 1; i >= 0; i--) {
    if (highlights[i] != HighlighterColors.TEXT) {
      s = highlights[i].getExternalName();
      break;
    }
  }
  return s == null ? HighlighterColors.TEXT.getExternalName() : s;
}
项目:consulo    文件:HighlightData.java   
public void addHighlToView(final Editor view, EditorColorsScheme scheme, final Map<TextAttributesKey,String> displayText) {

    // XXX: Hack
    if (HighlighterColors.BAD_CHARACTER.equals(myHighlightType)) {
      return;
    }

    final TextAttributes attr = scheme.getAttributes(myHighlightType);
    if (attr != null) {
      UIUtil.invokeAndWaitIfNeeded((Runnable)() -> {
        try {
          // IDEA-53203: add ERASE_MARKER for manually defined attributes
          view.getMarkupModel().addRangeHighlighter(myStartOffset, myEndOffset, HighlighterLayer.ADDITIONAL_SYNTAX,
                                                    TextAttributes.ERASE_MARKER, HighlighterTargetArea.EXACT_RANGE);
          RangeHighlighter highlighter = view.getMarkupModel()
                  .addRangeHighlighter(myStartOffset, myEndOffset, HighlighterLayer.ADDITIONAL_SYNTAX, attr,
                                       HighlighterTargetArea.EXACT_RANGE);
          final Color errorStripeColor = attr.getErrorStripeColor();
          highlighter.setErrorStripeMarkColor(errorStripeColor);
          final String tooltip = displayText.get(myHighlightType);
          highlighter.setErrorStripeTooltip(tooltip);
        }
        catch (Exception e) {
          throw new RuntimeException(e);
        }
      });
    }
  }
项目:intellij-ce-playground    文件:AbstractColorsScheme.java   
@NotNull
@Override
public Color getDefaultBackground() {
  final Color c = getAttributes(HighlighterColors.TEXT).getBackgroundColor();
  return c != null ? c : Color.white;
}
项目:intellij-ce-playground    文件:AbstractColorsScheme.java   
@NotNull
@Override
public Color getDefaultForeground() {
  final Color c = getAttributes(HighlighterColors.TEXT).getForegroundColor();
  return c != null ? c : Color.black;
}
项目:intellij-ce-playground    文件:EmptyEditorHighlighter.java   
@Override
public void setColorScheme(@NotNull EditorColorsScheme scheme) {
  setAttributes(scheme.getAttributes(HighlighterColors.TEXT));
}
项目:intellij-ce-playground    文件:AndroidStudioSpecificInitializer.java   
@Override
public void run() {
  checkInstallation();
  cleanUpIdePreferences();

  if (!Boolean.getBoolean(USE_IDEA_NEW_PROJECT_WIZARDS)) {
    replaceIdeaNewProjectActions();
  }

  if (!Boolean.getBoolean(USE_IDEA_PROJECT_STRUCTURE)) {
    replaceProjectStructureActions();
  }

  if (!Boolean.getBoolean(USE_JPS_MAKE_ACTIONS)) {
    replaceIdeaMakeActions();
  }

  if (!Boolean.getBoolean(USE_IDEA_NEW_FILE_POPUPS)) {
    hideIdeaNewFilePopupActions();
  }

  try {
    // Setup JDK and Android SDK if necessary
    setupSdks();
  } catch (Exception e) {
    LOG.error("Unexpected error while setting up SDKs: ", e);
  }

  addExtraBuildActions();

  hideMiscActions();

  registerAppClosing();

  // Always reset the Default scheme to match Android standards
  // User modifications won't be lost since they are made in a separate scheme (copied off of this default scheme)
  CodeStyleScheme scheme = CodeStyleSchemes.getInstance().getDefaultScheme();
  if (scheme != null) {
    CodeStyleSettings settings = scheme.getCodeStyleSettings();
    if (settings != null) {
      AndroidCodeStyleSettingsModifier.modify(settings);
    }
  }

  // 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());

  checkAndSetAndroidSdkSources();
}
项目:tools-idea    文件:EmptyEditorHighlighter.java   
@Override
public void setColorScheme(EditorColorsScheme scheme) {
  setAttributes(scheme.getAttributes(HighlighterColors.TEXT));
}
项目:tools-idea    文件:AbstractColorsScheme.java   
@NotNull
@Override
public Color getDefaultBackground() {
  final Color c = getAttributes(HighlighterColors.TEXT).getBackgroundColor();
  return c != null ? c : Color.white;
}
项目:tools-idea    文件:AbstractColorsScheme.java   
@NotNull
@Override
public Color getDefaultForeground() {
  final Color c = getAttributes(HighlighterColors.TEXT).getForegroundColor();
  return c != null ? c : Color.black;
}
项目:tools-idea    文件:AbstractColorsScheme.java   
private void readScheme(Element node) throws InvalidDataException {
  myDeprecatedBackgroundColor = null;
  if (SCHEME_ELEMENT.equals(node.getName())) {
    setName(node.getAttributeValue(NAME_ATTR));
    int readVersion = Integer.parseInt(node.getAttributeValue(VERSION_ATTR, "0"));
    if (readVersion > CURR_VERSION) throw new InvalidDataException("Unsupported color scheme version: " + readVersion);
    myVersion = readVersion;
    String isDefaultScheme = node.getAttributeValue(DEFAULT_SCHEME_ATTR);
    if (isDefaultScheme == null || !Boolean.parseBoolean(isDefaultScheme)) {
      String parentSchemeName = node.getAttributeValue(PARENT_SCHEME_ATTR);
      if (parentSchemeName == null) parentSchemeName = DEFAULT_SCHEME_NAME;
      myParentScheme = myDefaultColorSchemesManager.getScheme(parentSchemeName);
    }

    for (final Object o : node.getChildren()) {
      Element childNode = (Element)o;
      String childName = childNode.getName();
      if (OPTION_ELEMENT.equals(childName)) {
        readSettings(childNode);
      }
      else if (EDITOR_FONT.equals(childName)) {
        readFontSettings(childNode, myFontPreferences);
      }
      else if (CONSOLE_FONT.equals(childName)) {
        readFontSettings(childNode, myConsoleFontPreferences);
      }
      else if (COLORS_ELEMENT.equals(childName)) {
        readColors(childNode);
      }
      else if (ATTRIBUTES_ELEMENT.equals(childName)) {
        readAttributes(childNode);
      }
    }

    if (myDeprecatedBackgroundColor != null) {
      TextAttributes textAttributes = myAttributesMap.get(HighlighterColors.TEXT);
      if (textAttributes == null) {
        textAttributes = new TextAttributes(Color.black, myDeprecatedBackgroundColor, null, EffectType.BOXED, Font.PLAIN);
        myAttributesMap.put(HighlighterColors.TEXT, textAttributes);
      }
      else {
        textAttributes.setBackgroundColor(myDeprecatedBackgroundColor);
      }
    }

    if (myConsoleFontPreferences.getEffectiveFontFamilies().isEmpty()) {
      myFontPreferences.copyTo(myConsoleFontPreferences);
    }

    initFonts();
  }
}
项目:consulo    文件:AbstractColorsScheme.java   
@Nonnull
@Override
public Color getDefaultBackground() {
  final Color c = getAttributes(HighlighterColors.TEXT).getBackgroundColor();
  return c != null ? c : Color.white;
}
项目:consulo    文件:AbstractColorsScheme.java   
@Nonnull
@Override
public Color getDefaultForeground() {
  final Color c = getAttributes(HighlighterColors.TEXT).getForegroundColor();
  return c != null ? c : Color.black;
}
项目:consulo    文件:AbstractColorsScheme.java   
private void readScheme(Element node) {
  myDeprecatedBackgroundColor = null;
  if (!SCHEME_ELEMENT.equals(node.getName())) {
    return;
  }

  setName(node.getAttributeValue(NAME_ATTR));
  int readVersion = Integer.parseInt(node.getAttributeValue(VERSION_ATTR, "0"));
  if (readVersion > CURR_VERSION) {
    throw new IllegalStateException("Unsupported color scheme version: " + readVersion);
  }

  myVersion = readVersion;
  String isDefaultScheme = node.getAttributeValue(DEFAULT_SCHEME_ATTR);
  if (isDefaultScheme == null || !Boolean.parseBoolean(isDefaultScheme)) {
    String defaultAttributeValue = node.getAttributeValue(PARENT_SCHEME_ATTR, DEFAULT_SCHEME_NAME);
    myParentScheme = myEditorColorsManager.getBundledSchemes().get(defaultAttributeValue);
  }

  for (final Element childNode : node.getChildren()) {
    String childName = childNode.getName();
    if (OPTION_ELEMENT.equals(childName)) {
      readSettings(childNode);
    }
    else if (EDITOR_FONT.equals(childName)) {
      readFontSettings(childNode, myFontPreferences);
    }
    else if (CONSOLE_FONT.equals(childName)) {
      readFontSettings(childNode, myConsoleFontPreferences);
    }
    else if (COLORS_ELEMENT.equals(childName)) {
      readColors(childNode);
    }
    else if (ATTRIBUTES_ELEMENT.equals(childName)) {
      readAttributes(childNode);
    }
  }

  if (myDeprecatedBackgroundColor != null) {
    TextAttributes textAttributes = myAttributesMap.get(HighlighterColors.TEXT);
    if (textAttributes == null) {
      textAttributes = new TextAttributes(Color.black, myDeprecatedBackgroundColor, null, EffectType.BOXED, Font.PLAIN);
      myAttributesMap.put(HighlighterColors.TEXT, textAttributes);
    }
    else {
      textAttributes.setBackgroundColor(myDeprecatedBackgroundColor);
    }
  }

  if (myConsoleFontPreferences.getEffectiveFontFamilies().isEmpty()) {
    myFontPreferences.copyTo(myConsoleFontPreferences);
  }

  initFonts();
}
项目:consulo    文件:EmptyEditorHighlighter.java   
@Override
public void setColorScheme(EditorColorsScheme scheme) {
  setAttributes(scheme.getAttributes(HighlighterColors.TEXT));
}