当前位置: 首页>>代码示例>>Java>>正文


Java EditorColorsManager.getInstance方法代码示例

本文整理汇总了Java中com.intellij.openapi.editor.colors.EditorColorsManager.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java EditorColorsManager.getInstance方法的具体用法?Java EditorColorsManager.getInstance怎么用?Java EditorColorsManager.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.editor.colors.EditorColorsManager的用法示例。


在下文中一共展示了EditorColorsManager.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showSideEffectsWarning

import com.intellij.openapi.editor.colors.EditorColorsManager; //导入方法依赖的package包/类
public static RemoveUnusedVariableUtil.RemoveMode showSideEffectsWarning(List<PsiElement> sideEffects,
                                         PsiVariable variable,
                                         Editor editor,
                                         boolean canCopeWithSideEffects,
                                         @NonNls String beforeText,
                                         @NonNls String afterText) {
  if (sideEffects.isEmpty()) return RemoveUnusedVariableUtil.RemoveMode.DELETE_ALL;
  if (ApplicationManager.getApplication().isUnitTestMode()) {
    return canCopeWithSideEffects
           ? RemoveUnusedVariableUtil.RemoveMode.MAKE_STATEMENT
           : RemoveUnusedVariableUtil.RemoveMode.DELETE_ALL;
  }
  Project project = editor.getProject();
  HighlightManager highlightManager = HighlightManager.getInstance(project);
  PsiElement[] elements = PsiUtilCore.toPsiElementArray(sideEffects);
  EditorColorsManager manager = EditorColorsManager.getInstance();
  TextAttributes attributes = manager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
  highlightManager.addOccurrenceHighlights(editor, elements, attributes, true, null);

  SideEffectWarningDialog dialog = new SideEffectWarningDialog(project, false, variable, beforeText, afterText, canCopeWithSideEffects);
  dialog.show();
  int code = dialog.getExitCode();
  return RemoveUnusedVariableUtil.RemoveMode.values()[code];
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:RemoveUnusedVariableFix.java

示例2: highlightOccurrences

import com.intellij.openapi.editor.colors.EditorColorsManager; //导入方法依赖的package包/类
private static void highlightOccurrences(String filter, Project project, Editor editor) {
  final HighlightManager highlightManager = HighlightManager.getInstance(project);
  EditorColorsManager colorManager = EditorColorsManager.getInstance();
  final TextAttributes attributes = colorManager.getGlobalScheme().getAttributes(EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES);
  String documentText = editor.getDocument().getText();
  int i = -1;
  while (true) {
    int nextOccurrence = StringUtil.indexOfIgnoreCase(documentText, filter, i + 1);
    if (nextOccurrence < 0) {
      break;
    }
    i = nextOccurrence;
    highlightManager.addOccurrenceHighlight(editor, i, i + filter.length(), attributes,
                                             HighlightManager.HIDE_BY_TEXT_CHANGE, null, null);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:ThreadDumpPanel.java

示例3: performHighlighting

import com.intellij.openapi.editor.colors.EditorColorsManager; //导入方法依赖的package包/类
protected void performHighlighting() {
  boolean clearHighlights = HighlightUsagesHandler.isClearHighlights(myEditor);
  EditorColorsManager manager = EditorColorsManager.getInstance();
  TextAttributes attributes = manager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
  TextAttributes writeAttributes = manager.getGlobalScheme().getAttributes(EditorColors.WRITE_SEARCH_RESULT_ATTRIBUTES);
  HighlightUsagesHandler.highlightRanges(HighlightManager.getInstance(myEditor.getProject()),
                                         myEditor, attributes, clearHighlights, myReadUsages);
  HighlightUsagesHandler.highlightRanges(HighlightManager.getInstance(myEditor.getProject()),
                                         myEditor, writeAttributes, clearHighlights, myWriteUsages);
  if (!clearHighlights) {
    WindowManager.getInstance().getStatusBar(myEditor.getProject()).setInfo(myStatusText);

    HighlightHandlerBase.setupFindModel(myEditor.getProject()); // enable f3 navigation
  }
  if (myHintText != null) {
    HintManager.getInstance().showInformationHint(myEditor, myHintText);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:HighlightUsagesHandlerBase.java

示例4: highlightAllOccurrences

import com.intellij.openapi.editor.colors.EditorColorsManager; //导入方法依赖的package包/类
/**
 * @return List of highlighters
 */
public static List<RangeHighlighter> highlightAllOccurrences(Project project, PsiElement[] occurrences, Editor editor) {
  ArrayList<RangeHighlighter> highlighters = new ArrayList<RangeHighlighter>();
  HighlightManager highlightManager = HighlightManager.getInstance(project);
  EditorColorsManager colorsManager = EditorColorsManager.getInstance();
  TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
  if (occurrences.length > 1) {
    for (PsiElement occurrence : occurrences) {
      final RangeMarker rangeMarker = occurrence.getUserData(ElementToWorkOn.TEXT_RANGE);
      if (rangeMarker != null && rangeMarker.isValid()) {
        highlightManager
          .addRangeHighlight(editor, rangeMarker.getStartOffset(), rangeMarker.getEndOffset(), attributes, true, highlighters);
      }
      else {
        final TextRange textRange = occurrence.getTextRange();
        highlightManager.addRangeHighlight(editor, textRange.getStartOffset(), textRange.getEndOffset(), attributes, true, highlighters);
      }
    }
  }
  return highlighters;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:RefactoringUtil.java

示例5: highlightTemplateVariables

import com.intellij.openapi.editor.colors.EditorColorsManager; //导入方法依赖的package包/类
private void highlightTemplateVariables(Template template, Editor topLevelEditor) {
  //add highlights
  if (myHighlighters != null) { // can be null if finish is called during testing
    Map<TextRange, TextAttributes> rangesToHighlight = new HashMap<TextRange, TextAttributes>();
    final TemplateState templateState = TemplateManagerImpl.getTemplateState(topLevelEditor);
    if (templateState != null) {
      EditorColorsManager colorsManager = EditorColorsManager.getInstance();
      for (int i = 0; i < templateState.getSegmentsCount(); i++) {
        final TextRange segmentOffset = templateState.getSegmentRange(i);
        final String name = template.getSegmentName(i);
        TextAttributes attributes = null;
        if (name.equals(PRIMARY_VARIABLE_NAME)) {
          attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.WRITE_SEARCH_RESULT_ATTRIBUTES);
        }
        else if (name.equals(OTHER_VARIABLE_NAME)) {
          attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
        }
        if (attributes == null) continue;
        rangesToHighlight.put(segmentOffset, attributes);
      }
    }
    addHighlights(rangesToHighlight, topLevelEditor, myHighlighters, HighlightManager.getInstance(myProject));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:InplaceRefactoring.java

示例6: setupStyle

import com.intellij.openapi.editor.colors.EditorColorsManager; //导入方法依赖的package包/类
private void setupStyle() {
  Document document = myHTMLViewer.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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:Browser.java

示例7: applyFontSize

import com.intellij.openapi.editor.colors.EditorColorsManager; //导入方法依赖的package包/类
private void applyFontSize() {
  Document document = myEditorPane.getDocument();
  if (!(document instanceof StyledDocument)) {
    return;
  }

  final StyledDocument styledDocument = (StyledDocument)document;

  EditorColorsManager colorsManager = EditorColorsManager.getInstance();
  EditorColorsScheme scheme = colorsManager.getGlobalScheme();
  StyleConstants.setFontSize(myFontSizeStyle, scheme.getQuickDocFontSize().getSize());
  if (Registry.is("documentation.component.editor.font")) {
    StyleConstants.setFontFamily(myFontSizeStyle, scheme.getEditorFontName());
  }

  ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
    @Override
    public void run() {
      styledDocument.setCharacterAttributes(0, styledDocument.getLength(), myFontSizeStyle, false);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:DocumentationComponent.java

示例8: testYieldInNestedFunction

import com.intellij.openapi.editor.colors.EditorColorsManager; //导入方法依赖的package包/类
public void testYieldInNestedFunction() {
  // highlight func declaration first, lest we get an "Extra fragment highlighted" error.
  EditorColorsManager manager = EditorColorsManager.getInstance();
  EditorColorsScheme scheme = (EditorColorsScheme)manager.getGlobalScheme().clone();
  manager.addColorsScheme(scheme);
  EditorColorsManager.getInstance().setGlobalScheme(scheme);

  TextAttributesKey xKey = TextAttributesKey.find("PY.FUNC_DEFINITION");
  TextAttributes xAttributes = new TextAttributes(Color.red, Color.black, Color.white, EffectType.BOXED, Font.BOLD);
  scheme.setAttributes(xKey, xAttributes);

  doTest();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:PythonHighlightingTest.java

示例9: highlightOccurrences

import com.intellij.openapi.editor.colors.EditorColorsManager; //导入方法依赖的package包/类
public static void highlightOccurrences(Project project, @Nullable Editor editor, PsiElement[] elements) {
  if (editor == null) return;
  ArrayList<RangeHighlighter> highlighters = new ArrayList<RangeHighlighter>();
  HighlightManager highlightManager = HighlightManager.getInstance(project);
  EditorColorsManager colorsManager = EditorColorsManager.getInstance();
  TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
  if (elements.length > 0) {
    highlightManager.addOccurrenceHighlights(editor, elements, attributes, false, highlighters);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:GroovyRefactoringUtil.java

示例10: highlightInEditor

import com.intellij.openapi.editor.colors.EditorColorsManager; //导入方法依赖的package包/类
private static void highlightInEditor(@NotNull final Project project, @NotNull final SimpleMatch match,
                               @NotNull final Editor editor, Map<SimpleMatch, RangeHighlighter> highlighterMap) {
  final List<RangeHighlighter> highlighters = new ArrayList<RangeHighlighter>();
  final HighlightManager highlightManager = HighlightManager.getInstance(project);
  final EditorColorsManager colorsManager = EditorColorsManager.getInstance();
  final TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
  final int startOffset = match.getStartElement().getTextRange().getStartOffset();
  final int endOffset = match.getEndElement().getTextRange().getEndOffset();
  highlightManager.addRangeHighlight(editor, startOffset, endOffset, attributes, true, highlighters);
  highlighterMap.put(match, highlighters.get(0));
  final LogicalPosition logicalPosition = editor.offsetToLogicalPosition(startOffset);
  editor.getScrollingModel().scrollTo(logicalPosition, ScrollType.MAKE_VISIBLE);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:ExtractMethodHelper.java

示例11: highlightOtherOccurrences

import com.intellij.openapi.editor.colors.EditorColorsManager; //导入方法依赖的package包/类
public static void highlightOtherOccurrences(final List<PsiElement> otherOccurrences, Editor editor, boolean clearHighlights) {
  EditorColorsManager manager = EditorColorsManager.getInstance();
  TextAttributes attributes = manager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);

  PsiElement[] elements = PsiUtilCore.toPsiElementArray(otherOccurrences);
  doHighlightElements(editor, elements, attributes, clearHighlights);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:HighlightUsagesHandler.java

示例12: showDialog

import com.intellij.openapi.editor.colors.EditorColorsManager; //导入方法依赖的package包/类
@Nullable
private Settings showDialog(@NotNull GrIntroduceContext context) {

  // Add occurrences highlighting
  ArrayList<RangeHighlighter> highlighters = new ArrayList<RangeHighlighter>();
  HighlightManager highlightManager = null;
  if (context.getEditor() != null) {
    highlightManager = HighlightManager.getInstance(context.getProject());
    EditorColorsManager colorsManager = EditorColorsManager.getInstance();
    TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
    if (context.getOccurrences().length > 1) {
      highlightManager.addOccurrenceHighlights(context.getEditor(), context.getOccurrences(), attributes, true, highlighters);
    }
  }

  GrIntroduceDialog<Settings> dialog = getDialog(context);

  dialog.show();
  if (dialog.isOK()) {
    if (context.getEditor() != null) {
      for (RangeHighlighter highlighter : highlighters) {
        highlightManager.removeSegmentHighlighter(context.getEditor(), highlighter);
      }
    }
    return dialog.getSettings();
  }
  else {
    if (context.getOccurrences().length > 1) {
      WindowManager.getInstance().getStatusBar(context.getProject())
        .setInfo(GroovyRefactoringBundle.message("press.escape.to.remove.the.highlighting"));
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:GrIntroduceHandlerBase.java

示例13: getColorInner

import com.intellij.openapi.editor.colors.EditorColorsManager; //导入方法依赖的package包/类
@Nullable
public Color getColorInner() {
  final EditorColorsManager manager = EditorColorsManager.getInstance();
  if (manager != null) {
    TextAttributes attributes = manager.getGlobalScheme().getAttributes(myKey);
    Color stripe = attributes.getErrorStripeColor();
    if (stripe != null) return stripe;
    return attributes.getEffectColor();
  }
  TextAttributes defaultAttributes = myKey.getDefaultAttributes();
  if (defaultAttributes == null) defaultAttributes = TextAttributes.ERASE_MARKER;
  return defaultAttributes.getErrorStripeColor();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:HighlightDisplayLevel.java

示例14: updateEditorTexts

import com.intellij.openapi.editor.colors.EditorColorsManager; //导入方法依赖的package包/类
private void updateEditorTexts(final MethodNodeBase<M> node) {
  final MethodNodeBase<M> parentNode = getCalleeNode(node);
  final MethodNodeBase<M> callerNode = getCallerNode(node);
  final String callerText = node != myRoot ? getText(callerNode.getMethod()) : getEmptyCallerText();
  final Document callerDocument = myCallerEditor.getDocument();
  final String calleeText = node != myRoot ? getText(parentNode.getMethod()) : getEmptyCalleeText();
  final Document calleeDocument = myCalleeEditor.getDocument();

  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    @Override
    public void run() {
      callerDocument.setText(callerText);
      calleeDocument.setText(calleeText);
    }
  });

  final M caller = callerNode.getMethod();
  final PsiElement callee = parentNode != null ? parentNode.getElementToSearch() : null;
  if (caller != null && caller.isPhysical() && callee != null) {
    HighlightManager highlighter = HighlightManager.getInstance(myProject);
    EditorColorsManager colorManager = EditorColorsManager.getInstance();
    TextAttributes attributes = colorManager.getGlobalScheme().getAttributes(EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES);
    int start = getStartOffset(caller);
    for (PsiElement element : findElementsToHighlight(caller, callee)) {
      highlighter.addRangeHighlight(myCallerEditor, element.getTextRange().getStartOffset() - start,
                                    element.getTextRange().getEndOffset() - start, attributes, false, null);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:CallerChooserBase.java

示例15: highlightWord

import com.intellij.openapi.editor.colors.EditorColorsManager; //导入方法依赖的package包/类
private static void highlightWord(final CompletionVariant variant, final Project project) {
  HighlightManager highlightManager = HighlightManager.getInstance(project);
  EditorColorsManager colorManager = EditorColorsManager.getInstance();
  TextAttributes attributes = colorManager.getGlobalScheme().getAttributes(EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES);
  highlightManager.addOccurrenceHighlight(variant.editor, variant.offset, variant.offset + variant.variant.length(), attributes,
                                          HighlightManager.HIDE_BY_ANY_KEY, null, null);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:HippieWordCompletionHandler.java


注:本文中的com.intellij.openapi.editor.colors.EditorColorsManager.getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。