本文整理汇总了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];
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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));
}
}
示例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);
}
示例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);
}
});
}
示例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();
}
示例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);
}
}
示例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);
}
示例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);
}
示例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;
}
示例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();
}
示例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);
}
}
}
示例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);
}