本文整理汇总了Java中com.intellij.openapi.editor.colors.EditorColors类的典型用法代码示例。如果您正苦于以下问题:Java EditorColors类的具体用法?Java EditorColors怎么用?Java EditorColors使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EditorColors类属于com.intellij.openapi.editor.colors包,在下文中一共展示了EditorColors类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createUIComponents
import com.intellij.openapi.editor.colors.EditorColors; //导入依赖的package包/类
private void createUIComponents() {
final EditorFactory editorFactory = EditorFactory.getInstance();
jsonDocument = editorFactory.createDocument(EMPTY_TEXT);
jsonEditor = editorFactory.createEditor(jsonDocument, project, JsonFileType.INSTANCE, false);
final EditorSettings settings = jsonEditor.getSettings();
settings.setWhitespacesShown(true);
settings.setLineMarkerAreaShown(false);
settings.setIndentGuidesShown(false);
settings.setLineNumbersShown(true);
settings.setFoldingOutlineShown(false);
settings.setRightMarginShown(false);
settings.setVirtualSpace(false);
settings.setWheelFontChangeEnabled(false);
settings.setUseSoftWraps(false);
settings.setAdditionalColumnsCount(0);
settings.setAdditionalLinesCount(1);
final EditorColorsScheme colorsScheme = jsonEditor.getColorsScheme();
colorsScheme.setColor(EditorColors.CARET_ROW_COLOR, null);
jsonEditor.getContentComponent().setFocusable(true);
jsonPanel = (JPanel) jsonEditor.getComponent();
}
示例2: drawAllAnswerPlaceholders
import com.intellij.openapi.editor.colors.EditorColors; //导入依赖的package包/类
public static void drawAllAnswerPlaceholders(Editor editor, TaskFile taskFile) {
editor.getMarkupModel().removeAllHighlighters();
final Project project = editor.getProject();
if (project == null) return;
final StudyTaskManager taskManager = StudyTaskManager.getInstance(project);
for (AnswerPlaceholder answerPlaceholder : taskFile.getAnswerPlaceholders()) {
final JBColor color = taskManager.getColor(answerPlaceholder);
EduAnswerPlaceholderPainter.drawAnswerPlaceholder(editor, answerPlaceholder, color);
}
final Document document = editor.getDocument();
EditorActionManager.getInstance()
.setReadonlyFragmentModificationHandler(document, new EduAnswerPlaceholderDeleteHandler(editor));
EduAnswerPlaceholderPainter.createGuardedBlocks(editor, taskFile);
editor.getColorsScheme().setColor(EditorColors.READONLY_FRAGMENT_BACKGROUND_COLOR, null);
}
示例3: createNotificationPanel
import com.intellij.openapi.editor.colors.EditorColors; //导入依赖的package包/类
@Nullable
@Override
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
if (!CCUtils.isCourseCreator(myProject)) {
return null;
}
boolean isTestFile = CCUtils.isTestsFile(myProject, file);
if (!isTestFile && StudyUtils.getTaskFile(myProject, file) == null) {
return null;
}
Task task = StudyUtils.getTaskForFile(myProject, file);
if (task instanceof TaskWithSubtasks) {
final TaskWithSubtasks withSubtasks = (TaskWithSubtasks)task;
EditorNotificationPanel panel = new EditorNotificationPanel(EditorColors.GUTTER_BACKGROUND);
String header = (isTestFile ? "test" : "task") + " file";
int activeSubtaskIndex = withSubtasks.getActiveSubtaskIndex() + 1;
int subtaskSize = withSubtasks.getLastSubtaskIndex() + 1;
panel.setText("This is a " + header + " for " + EduNames.SUBTASK + " " + activeSubtaskIndex + "/" + subtaskSize);
panel
.createActionLabel(SWITCH_SUBTASK, () -> createPopup(withSubtasks, myProject).show(RelativePoint.getSouthEastOf(panel)));
return panel;
}
return null;
}
示例4: addHighlights
import com.intellij.openapi.editor.colors.EditorColors; //导入依赖的package包/类
private static void addHighlights(List<TextRange> ranges, Editor editor, ArrayList<RangeHighlighter> highlighters) {
EditorColorsManager colorsManager = EditorColorsManager.getInstance();
TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.WRITE_SEARCH_RESULT_ATTRIBUTES);
HighlightManager highlightManager = HighlightManager.getInstance(editor.getProject());
Iterator iterator = ranges.iterator();
while (iterator.hasNext()) {
TextRange range = (TextRange) iterator.next();
//highlightManager.addOccurrenceHighlight(editor, range.getStartOffset() + 1, range.getEndOffset() - 1, attributes, 0, highlighters, (Color) null);
highlightManager.addRangeHighlight(editor, range.getStartOffset() + 1, range.getEndOffset() - 1, attributes, false, highlighters);
}
iterator = highlighters.iterator();
while (iterator.hasNext()) {
RangeHighlighter highlighter = (RangeHighlighter) iterator.next();
highlighter.setGreedyToLeft(true);
highlighter.setGreedyToRight(true);
}
}
示例5: showSideEffectsWarning
import com.intellij.openapi.editor.colors.EditorColors; //导入依赖的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];
}
示例6: highlightOccurrences
import com.intellij.openapi.editor.colors.EditorColors; //导入依赖的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);
}
}
示例7: getTextAttributes
import com.intellij.openapi.editor.colors.EditorColors; //导入依赖的package包/类
@Nullable
@Override
public TextAttributes getTextAttributes(@NotNull EditorColorsScheme scheme, @NotNull ArrangementSettingsToken token, boolean selected) {
if (selected) {
TextAttributes attributes = new TextAttributes();
attributes.setForegroundColor(scheme.getColor(EditorColors.SELECTION_FOREGROUND_COLOR));
attributes.setBackgroundColor(scheme.getColor(EditorColors.SELECTION_BACKGROUND_COLOR));
return attributes;
}
else if (SUPPORTED_TYPES.contains(token)) {
return getAttributes(scheme, JavaHighlightingColors.KEYWORD);
}
else if (SUPPORTED_MODIFIERS.contains(token)) {
getAttributes(scheme, JavaHighlightingColors.KEYWORD);
}
return null;
}
示例8: highlightAllOccurrences
import com.intellij.openapi.editor.colors.EditorColors; //导入依赖的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;
}
示例9: paint
import com.intellij.openapi.editor.colors.EditorColors; //导入依赖的package包/类
@Override
public void paint(Editor editor, Graphics g, Rectangle r) {
if (!myCondition.get()) return;
int y = r.y;
int lineHeight = myEditor.getLineHeight();
EditorGutterComponentEx gutter = ((EditorEx)editor).getGutterComponentEx();
int annotationsOffset = gutter.getAnnotationsAreaOffset();
int annotationsWidth = gutter.getAnnotationsAreaWidth();
if (annotationsWidth != 0) {
g.setColor(editor.getColorsScheme().getColor(EditorColors.GUTTER_BACKGROUND));
g.fillRect(annotationsOffset, y, annotationsWidth, lineHeight);
}
draw(g, 0, y, lineHeight, myEditor.getColorsScheme());
}
示例10: paintSelectionOnSecondSoftWrapLineIfNecessary
import com.intellij.openapi.editor.colors.EditorColors; //导入依赖的package包/类
private void paintSelectionOnSecondSoftWrapLineIfNecessary(Graphics2D g, int columnEnd, float xEnd, int y) {
VisualPosition selectionStartPosition = myEditor.getSelectionModel().getSelectionStartPosition();
VisualPosition selectionEndPosition = myEditor.getSelectionModel().getSelectionEndPosition();
int visualLine = myView.yToVisualLine(y);
if (selectionStartPosition.equals(selectionEndPosition) ||
visualLine < selectionStartPosition.line ||
visualLine > selectionEndPosition.line ||
visualLine == selectionStartPosition.line && selectionStartPosition.column >= columnEnd) {
return;
}
float startX = (selectionStartPosition.line == visualLine && selectionStartPosition.column > 0) ?
myView.visualPositionToXY(selectionStartPosition).x : 0;
float endX = (selectionEndPosition.line == visualLine && selectionEndPosition.column < columnEnd) ?
myView.visualPositionToXY(selectionEndPosition).x : xEnd;
paintBackground(g, myEditor.getColorsScheme().getColor(EditorColors.SELECTION_BACKGROUND_COLOR), startX, y, endX - startX);
}
示例11: paintSelectionOnFirstSoftWrapLineIfNecessary
import com.intellij.openapi.editor.colors.EditorColors; //导入依赖的package包/类
private void paintSelectionOnFirstSoftWrapLineIfNecessary(Graphics2D g, int columnStart, float xStart, float xEnd, int y) {
VisualPosition selectionStartPosition = myEditor.getSelectionModel().getSelectionStartPosition();
VisualPosition selectionEndPosition = myEditor.getSelectionModel().getSelectionEndPosition();
int visualLine = myView.yToVisualLine(y);
if (selectionStartPosition.equals(selectionEndPosition) ||
visualLine < selectionStartPosition.line ||
visualLine > selectionEndPosition.line ||
visualLine == selectionEndPosition.line && selectionEndPosition.column <= columnStart) {
return;
}
float startX = selectionStartPosition.line == visualLine && selectionStartPosition.column > columnStart ?
myView.visualPositionToXY(selectionStartPosition).x : xStart;
float endX = selectionEndPosition.line == visualLine ?
myView.visualPositionToXY(selectionEndPosition).x : xEnd;
paintBackground(g, myEditor.getColorsScheme().getColor(EditorColors.SELECTION_BACKGROUND_COLOR), startX, y, endX - startX);
}
示例12: paintLineMarkerSeparator
import com.intellij.openapi.editor.colors.EditorColors; //导入依赖的package包/类
private void paintLineMarkerSeparator(RangeHighlighter marker, Rectangle clip, Graphics g) {
Color separatorColor = marker.getLineSeparatorColor();
LineSeparatorRenderer lineSeparatorRenderer = marker.getLineSeparatorRenderer();
if (separatorColor == null && lineSeparatorRenderer == null) {
return;
}
int line = myDocument.getLineNumber(marker.getLineSeparatorPlacement() == SeparatorPlacement.TOP
? marker.getStartOffset()
: marker.getEndOffset());
int visualLine = myView.logicalToVisualPosition(new LogicalPosition(line + (marker.getLineSeparatorPlacement() ==
SeparatorPlacement.TOP ? 0 : 1), 0), false).line;
int y = myView.visualLineToY(visualLine) - 1;
int endShift = clip.x + clip.width;
EditorSettings settings = myEditor.getSettings();
if (settings.isRightMarginShown() && myEditor.getColorsScheme().getColor(EditorColors.RIGHT_MARGIN_COLOR) != null) {
endShift = Math.min(endShift, settings.getRightMargin(myEditor.getProject()) * myView.getPlainSpaceWidth());
}
g.setColor(separatorColor);
if (lineSeparatorRenderer != null) {
lineSeparatorRenderer.drawLine(g, 0, endShift, y);
}
else {
UIUtil.drawLine(g, 0, y, endShift, y);
}
}
示例13: getTableCellRendererComponent
import com.intellij.openapi.editor.colors.EditorColors; //导入依赖的package包/类
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean selected, boolean focused, int row, int column) {
RendererComponent panel = getEditorPanel(table);
EditorEx editor = panel.getEditor();
editor.getColorsScheme().setEditorFontSize(table.getFont().getSize());
editor.getColorsScheme().setColor(EditorColors.SELECTION_BACKGROUND_COLOR, table.getSelectionBackground());
editor.getColorsScheme().setColor(EditorColors.SELECTION_FOREGROUND_COLOR, table.getSelectionForeground());
editor.setBackgroundColor(selected ? table.getSelectionBackground() : table.getBackground());
panel.setSelected(!Comparing.equal(editor.getBackgroundColor(), table.getBackground()));
panel.setBorder(null); // prevents double border painting when ExtendedItemRendererComponentWrapper is used
customizeEditor(editor, table, value, selected, row, column);
return panel;
}
示例14: performHighlighting
import com.intellij.openapi.editor.colors.EditorColors; //导入依赖的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);
}
}
示例15: installHighlighterSet
import com.intellij.openapi.editor.colors.EditorColors; //导入依赖的package包/类
@NotNull
private HighlightersSet installHighlighterSet(@NotNull Info info, @NotNull Editor editor) {
final JComponent internalComponent = editor.getContentComponent();
internalComponent.addKeyListener(myEditorKeyListener);
editor.getScrollingModel().addVisibleAreaListener(myVisibleAreaListener);
final Cursor cursor = internalComponent.getCursor();
internalComponent.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
myFileEditorManager.addFileEditorManagerListener(myFileEditorManagerListener);
List<RangeHighlighter> highlighters = new ArrayList<RangeHighlighter>();
TextAttributes attributes = myEditorColorsManager.getGlobalScheme().getAttributes(EditorColors.REFERENCE_HYPERLINK_COLOR);
for (TextRange range : info.getRanges()) {
TextAttributes attr = NavigationUtil.patchAttributesColor(attributes, range, editor);
final RangeHighlighter highlighter = editor.getMarkupModel().addRangeHighlighter(range.getStartOffset(), range.getEndOffset(),
HighlighterLayer.SELECTION + 1,
attr,
HighlighterTargetArea.EXACT_RANGE);
highlighters.add(highlighter);
}
return new HighlightersSet(highlighters, editor, cursor, info);
}