下面列出了怎么用com.intellij.openapi.editor.colors.EditorColors的API类实例代码及写法,或者点击链接到github查看源代码。
private static void highlightPsiElement(PsiElement psiElement, boolean openInEditor) {
if (openInEditor) {
EditorHelper.openInEditor(psiElement);
}
Editor editor = FileEditorManager.getInstance(psiElement.getProject()).getSelectedTextEditor();
if (editor == null) {
return;
}
TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
editor.getMarkupModel().addRangeHighlighter(
psiElement.getTextRange().getStartOffset(),
psiElement.getTextRange().getEndOffset(),
HighlighterLayer.SELECTION,
attributes,
HighlighterTargetArea.EXACT_RANGE
);
}
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();
}
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);
}
}
FlutterSampleActionsPanel(@NotNull List<FlutterSample> samples) {
super(EditorColors.GUTTER_BACKGROUND);
icon(FlutterIcons.Flutter);
text("View hosted code sample");
for (int i = 0; i < samples.size(); i++) {
if (i != 0) {
myLinksPanel.add(new JSeparator(SwingConstants.VERTICAL));
}
final FlutterSample sample = samples.get(i);
final HyperlinkLabel label = createActionLabel(sample.getClassName(), () -> browseTo(sample));
label.setToolTipText(sample.getHostedDocsUrl());
}
}
NativeEditorActionsPanel(VirtualFile file, VirtualFile root, String actionName) {
super(EditorColors.GUTTER_BACKGROUND);
myFile = file;
myRoot = root;
myAction = ActionManager.getInstance().getAction(actionName);
icon(FlutterIcons.Flutter);
text("Flutter commands");
// Ensure this project is a Flutter project by updating the menu action. It will only be visible for Flutter projects.
myAction.update(AnActionEvent.createFromDataContext(ActionPlaces.EDITOR_TOOLBAR, myAction.getTemplatePresentation(), makeContext()));
isVisible = myAction.getTemplatePresentation().isVisible();
createActionLabel(myAction.getTemplatePresentation().getText(), this::performAction)
.setToolTipText(myAction.getTemplatePresentation().getDescription());
createActionLabel(FlutterBundle.message("flutter.androidstudio.open.hide.notification.text"), () -> {
showNotification = false;
EditorNotifications.getInstance(myProject).updateAllNotifications();
}).setToolTipText(FlutterBundle.message("flutter.androidstudio.open.hide.notification.description"));
}
FlutterSampleActionsPanel(@NotNull List<FlutterSample> samples) {
super(EditorColors.GUTTER_BACKGROUND);
icon(FlutterIcons.Flutter);
text("View hosted code sample");
for (int i = 0; i < samples.size(); i++) {
if (i != 0) {
myLinksPanel.add(new JSeparator(SwingConstants.VERTICAL));
}
final FlutterSample sample = samples.get(i);
final HyperlinkLabel label = createActionLabel(sample.getClassName(), () -> browseTo(sample));
label.setToolTipText(sample.getHostedDocsUrl());
}
}
NativeEditorActionsPanel(VirtualFile file, VirtualFile root, String actionName) {
super(EditorColors.GUTTER_BACKGROUND);
myFile = file;
myRoot = root;
myAction = ActionManager.getInstance().getAction(actionName);
icon(FlutterIcons.Flutter);
text("Flutter commands");
// Ensure this project is a Flutter project by updating the menu action. It will only be visible for Flutter projects.
myAction.update(AnActionEvent.createFromDataContext(ActionPlaces.EDITOR_TOOLBAR, myAction.getTemplatePresentation(), makeContext()));
isVisible = myAction.getTemplatePresentation().isVisible();
createActionLabel(myAction.getTemplatePresentation().getText(), this::performAction)
.setToolTipText(myAction.getTemplatePresentation().getDescription());
createActionLabel(FlutterBundle.message("flutter.androidstudio.open.hide.notification.text"), () -> {
showNotification = false;
EditorNotifications.getInstance(myProject).updateAllNotifications();
}).setToolTipText(FlutterBundle.message("flutter.androidstudio.open.hide.notification.description"));
}
/**
* Creates and configures template preview editor.
*
* @param document virtual editor document
* @param project current project
* @return editor
*/
@NotNull
public static Editor createPreviewEditor(@NotNull Document document, @Nullable Project project, boolean isViewer) {
EditorEx editor = (EditorEx) EditorFactory.getInstance().createEditor(document, project,
IgnoreFileType.INSTANCE, isViewer);
editor.setCaretEnabled(!isViewer);
final EditorSettings settings = editor.getSettings();
settings.setLineNumbersShown(false);
settings.setAdditionalColumnsCount(1);
settings.setAdditionalLinesCount(0);
settings.setRightMarginShown(false);
settings.setFoldingOutlineShown(false);
settings.setLineMarkerAreaShown(false);
settings.setIndentGuidesShown(false);
settings.setVirtualSpace(false);
settings.setWheelFontChangeEnabled(false);
EditorColorsScheme colorsScheme = editor.getColorsScheme();
colorsScheme.setColor(EditorColors.CARET_ROW_COLOR, null);
return editor;
}
public static void highlightElement(Editor editor, @NotNull com.intellij.openapi.project.Project project, @NotNull PsiElement[] elements)
{
final HighlightManager highlightManager =
HighlightManager.getInstance(project);
final EditorColorsManager editorColorsManager =
EditorColorsManager.getInstance();
final EditorColorsScheme globalScheme =
editorColorsManager.getGlobalScheme();
final TextAttributes textattributes =
globalScheme.getAttributes(
EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES);
highlightManager.addOccurrenceHighlights(
editor, elements, textattributes, true, null);
final WindowManager windowManager = WindowManager.getInstance();
final StatusBar statusBar = windowManager.getStatusBar(project);
statusBar.setInfo("Press Esc to remove highlighting");
}
@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());
}
private boolean paintFoldingBackground(TextAttributes innerAttributes, float x, int y, float width, @Nonnull FoldRegion foldRegion) {
if (innerAttributes.getBackgroundColor() != null && !isSelected(foldRegion)) {
paintBackground(innerAttributes, x, y, width);
Color borderColor = myEditor.getColorsScheme().getColor(EditorColors.FOLDED_TEXT_BORDER_COLOR);
if (borderColor != null) {
Shape border = getBorderShape(x, y, width, myLineHeight, 2, false);
if (border != null) {
myGraphics.setColor(borderColor);
myGraphics.fill(border);
}
}
return true;
}
else {
return false;
}
}
@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;
}
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);
}
}
@Nonnull
private HighlightersSet installHighlighterSet(@Nonnull Info info, @Nonnull EditorEx editor, boolean highlighterOnly) {
editor.getContentComponent().addKeyListener(myEditorKeyListener);
editor.getScrollingModel().addVisibleAreaListener(myVisibleAreaListener);
if (info.isNavigatable()) {
editor.setCustomCursor(CtrlMouseHandler.class, Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
List<RangeHighlighter> highlighters = new ArrayList<>();
if (!highlighterOnly || info.isNavigatable()) {
TextAttributes attributes = info.isNavigatable()
? EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.REFERENCE_HYPERLINK_COLOR)
: new TextAttributes(null, HintUtil.getInformationColor(), null, null, Font.PLAIN);
for (TextRange range : info.getRanges()) {
TextAttributes attr = NavigationUtil.patchAttributesColor(attributes, range, editor);
final RangeHighlighter highlighter = editor.getMarkupModel().addRangeHighlighter(range.getStartOffset(), range.getEndOffset(), HighlighterLayer.HYPERLINK, attr, HighlighterTargetArea.EXACT_RANGE);
highlighters.add(highlighter);
}
}
return new HighlightersSet(highlighters, editor, info);
}
private static Editor createEditor(boolean isReadOnly, final Document document, final Project project) {
EditorFactory editorFactory = EditorFactory.getInstance();
Editor editor = (isReadOnly ? editorFactory.createViewer(document, project) : editorFactory.createEditor(document, project));
EditorSettings editorSettings = editor.getSettings();
editorSettings.setVirtualSpace(false);
editorSettings.setLineMarkerAreaShown(false);
editorSettings.setIndentGuidesShown(false);
editorSettings.setLineNumbersShown(false);
editorSettings.setFoldingOutlineShown(false);
EditorColorsScheme scheme = editor.getColorsScheme();
scheme.setColor(EditorColors.CARET_ROW_COLOR, null);
VirtualFile file = FileDocumentManager.getInstance().getFile(document);
if (file != null) {
EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(file, scheme, project);
((EditorEx) editor).setHighlighter(highlighter);
}
return editor;
}
private void updateCursorHighlighting() {
hideBalloon();
if (myCursorHighlighter != null) {
removeHighlighter(myCursorHighlighter);
myCursorHighlighter = null;
}
final FindResult cursor = mySearchResults.getCursor();
Editor editor = mySearchResults.getEditor();
if (cursor != null && cursor.getEndOffset() <= editor.getDocument().getTextLength()) {
Color color = editor.getColorsScheme().getColor(EditorColors.CARET_COLOR);
myCursorHighlighter = addHighlighter(cursor.getStartOffset(), cursor.getEndOffset(), new TextAttributes(null, null, color, EffectType.ROUNDED_BOX, Font.PLAIN));
editor.getScrollingModel().runActionOnScrollingFinished(() -> showReplacementPreview());
}
}
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));
}
}
public static EditorEx createPreviewComponent(Project project, FileType languageFileType) {
Document document = EditorFactory.getInstance().createDocument("");
UndoUtil.disableUndoFor(document);
EditorEx previewEditor = (EditorEx)EditorFactory.getInstance().createEditor(document, project, languageFileType, true);
previewEditor.setOneLineMode(true);
final EditorSettings settings = previewEditor.getSettings();
settings.setAdditionalLinesCount(0);
settings.setAdditionalColumnsCount(1);
settings.setRightMarginShown(false);
settings.setFoldingOutlineShown(false);
settings.setLineNumbersShown(false);
settings.setLineMarkerAreaShown(false);
settings.setIndentGuidesShown(false);
settings.setVirtualSpace(false);
previewEditor.setHorizontalScrollbarVisible(false);
previewEditor.setVerticalScrollbarVisible(false);
previewEditor.setCaretEnabled(false);
settings.setLineCursorWidth(1);
final Color bg = previewEditor.getColorsScheme().getColor(EditorColors.CARET_ROW_COLOR);
previewEditor.setBackgroundColor(bg);
previewEditor.setBorder(BorderFactory.createCompoundBorder(new DottedBorder(Color.gray), new LineBorder(bg, 2)));
return previewEditor;
}
/**
* Opens definition of method and highlights statements, which should be extracted.
*
* @param sourceMethod method from which code is proposed to be extracted into separate method.
* @param scope scope of the current project.
* @param slice computation slice.
*/
private static void openDefinition(@Nullable PsiMethod sourceMethod, AnalysisScope scope, ASTSlice slice) {
new Task.Backgroundable(scope.getProject(), "Search Definition") {
@Override
public void run(@NotNull ProgressIndicator indicator) {
indicator.setIndeterminate(true);
}
@Override
public void onSuccess() {
if (sourceMethod != null) {
Set<SmartPsiElementPointer<PsiElement>> statements = slice.getSliceStatements();
PsiStatement psiStatement = (PsiStatement) statements.iterator().next().getElement();
if (psiStatement != null && psiStatement.isValid()) {
EditorHelper.openInEditor(psiStatement);
Editor editor = FileEditorManager.getInstance(sourceMethod.getProject()).getSelectedTextEditor();
if (editor != null) {
TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
editor.getMarkupModel().removeAllHighlighters();
statements.stream()
.filter(statement -> statement.getElement() != null)
.forEach(statement ->
editor.getMarkupModel().addRangeHighlighter(statement.getElement().getTextRange().getStartOffset(),
statement.getElement().getTextRange().getEndOffset(), HighlighterLayer.SELECTION,
attributes, HighlighterTargetArea.EXACT_RANGE));
}
}
}
}
}.queue();
}
FlutterPubspecActionsPanel(@NotNull Project project, @NotNull VirtualFile file) {
super(EditorColors.GUTTER_BACKGROUND);
this.project = project;
myFile = file;
icon(FlutterIcons.Flutter);
text("Flutter commands");
// "flutter.pub.get"
HyperlinkLabel label = createActionLabel("Pub get", () -> runPubGet(false));
label.setToolTipText("Install referenced packages");
// "flutter.pub.upgrade"
label = createActionLabel("Pub upgrade", () -> runPubGet(true));
label.setToolTipText("Upgrade referenced packages to the latest versions");
// If the SDK is the right version, add a 'flutter pub outdated' command.
final FlutterSdk sdk = FlutterSdk.getFlutterSdk(project);
if (sdk != null && sdk.getVersion().isPubOutdatedSupported()) {
// "flutter.pub.outdated"
label = createActionLabel("Pub outdated", this::runPubOutdated);
label.setToolTipText("Analyze packages to determine which ones can be upgraded");
}
myLinksPanel.add(new JSeparator(SwingConstants.VERTICAL));
label = createActionLabel("Flutter doctor", "flutter.doctor");
label.setToolTipText("Validate installed tools and their versions");
}
FlutterPubspecActionsPanel(@NotNull Project project, @NotNull VirtualFile file) {
super(EditorColors.GUTTER_BACKGROUND);
this.project = project;
myFile = file;
icon(FlutterIcons.Flutter);
text("Flutter commands");
// "flutter.pub.get"
HyperlinkLabel label = createActionLabel("Pub get", () -> runPubGet(false));
label.setToolTipText("Install referenced packages");
// "flutter.pub.upgrade"
label = createActionLabel("Pub upgrade", () -> runPubGet(true));
label.setToolTipText("Upgrade referenced packages to the latest versions");
// If the SDK is the right version, add a 'flutter pub outdated' command.
final FlutterSdk sdk = FlutterSdk.getFlutterSdk(project);
if (sdk != null && sdk.getVersion().isPubOutdatedSupported()) {
// "flutter.pub.outdated"
label = createActionLabel("Pub outdated", this::runPubOutdated);
label.setToolTipText("Analyze packages to determine which ones can be upgraded");
}
myLinksPanel.add(new JSeparator(SwingConstants.VERTICAL));
label = createActionLabel("Flutter doctor", "flutter.doctor");
label.setToolTipText("Validate installed tools and their versions");
}
public void fillUi(JPanel canvas) {
String tooltip =
"Enter a project view descriptor file."
+ (Blaze.defaultBuildSystem() == BuildSystem.Blaze
? " See 'go/intellij/docs/project-views.md' for more information."
: "");
projectViewEditor = createEditor(tooltip);
projectViewEditor
.getColorsScheme()
.setColor(EditorColors.READONLY_BACKGROUND_COLOR, UIManager.getColor("Label.background"));
Disposer.register(
parentDisposable, () -> EditorFactory.getInstance().releaseEditor(projectViewEditor));
JBLabel labelsLabel = new JBLabel("Project View");
labelsLabel.setToolTipText(tooltip);
canvas.add(labelsLabel, UiUtil.getFillLineConstraints(0));
canvas.add(projectViewEditor.getComponent(), UiUtil.getFillLineConstraints(0));
useShared = new JCheckBox(USE_SHARED_PROJECT_VIEW);
useShared.addActionListener(
e -> {
useSharedProjectView = useShared.isSelected();
if (useSharedProjectView) {
setProjectViewText(sharedProjectViewText);
}
updateTextAreasEnabled();
});
canvas.add(useShared, UiUtil.getFillLineConstraints(0));
}
@Override
public void visitLinqExpression(CSharpLinqExpressionImpl expression)
{
super.visitLinqExpression(expression);
myHighlightInfoHolder.add(HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION).range(expression).textAttributes(EditorColors.INJECTED_LANGUAGE_FRAGMENT).create());
}
private void installTypingSupport() {
if (!isEditable(myMasterSide, false)) return;
updateEditorCanBeTyped();
myEditor.getColorsScheme().setColor(EditorColors.READONLY_FRAGMENT_BACKGROUND_COLOR, null); // guarded blocks
EditorActionManager.getInstance().setReadonlyFragmentModificationHandler(myDocument, new MyReadonlyFragmentModificationHandler());
myDocument.putUserData(UndoManager.ORIGINAL_DOCUMENT, getDocument(myMasterSide)); // use undo of master document
myDocument.addDocumentListener(new MyOnesideDocumentListener());
}
@Nonnull
public static Color getDividerColorFromScheme(@Nonnull EditorColorsScheme scheme) {
Color gutterBackground = scheme.getColor(EditorColors.GUTTER_BACKGROUND);
if (gutterBackground == null) {
gutterBackground = EditorColors.GUTTER_BACKGROUND.getDefaultColor();
}
return gutterBackground;
}
protected JComponent createActionsToolbar(final Editor editor, final int lineNumber) {
final JComponent editorComponent = editor.getComponent();
final DefaultActionGroup group = new DefaultActionGroup();
final GotoPreviousCoveredLineAction prevAction = new GotoPreviousCoveredLineAction(editor, lineNumber);
final GotoNextCoveredLineAction nextAction = new GotoNextCoveredLineAction(editor, lineNumber);
group.add(prevAction);
group.add(nextAction);
prevAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.ALT_MASK|InputEvent.SHIFT_MASK)), editorComponent);
nextAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.ALT_MASK|InputEvent.SHIFT_MASK)), editorComponent);
final LineData lineData = getLineData(lineNumber);
if (myCoverageByTestApplicable) {
group.add(new ShowCoveringTestsAction(myClassName, lineData));
}
final AnAction byteCodeViewAction = ActionManager.getInstance().getAction("ByteCodeViewer");
if (byteCodeViewAction != null) {
group.add(byteCodeViewAction);
}
group.add(new EditCoverageColorsAction(editor, lineNumber));
group.add(new HideCoverageInfoAction());
final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.FILEHISTORY_VIEW_TOOLBAR, group, true);
final JComponent toolbarComponent = toolbar.getComponent();
final Color background = ((EditorEx)editor).getBackgroundColor();
final Color foreground = editor.getColorsScheme().getColor(EditorColors.CARET_COLOR);
toolbarComponent.setBackground(background);
toolbarComponent.setBorder(new ColoredSideBorder(foreground, foreground, lineData == null || lineData.getStatus() == LineCoverage.NONE || mySubCoverageActive ? foreground : null, foreground, 1));
toolbar.updateActionsImmediately();
return toolbarComponent;
}
@Override
public final Color getBackground() {
if (myBackgroundColor != null) {
return myBackgroundColor;
}
Color color = EditorColorsManager.getInstance().getGlobalScheme().getColor(EditorColors.NOTIFICATION_BACKGROUND);
return color == null ? UIUtil.getToolTipBackground() : color;
}
public static Color getBackgroundColor(Editor editor, boolean useCaretRowBackground) {
EditorColorsScheme colorsScheme = editor.getColorsScheme();
Color color = colorsScheme.getColor(EditorColors.CARET_ROW_COLOR);
if (!useCaretRowBackground || color == null) {
color = colorsScheme.getDefaultBackground();
}
return color;
}
@Nonnull
public static CompoundBorder createEditorFragmentBorder(@Nonnull Editor editor) {
Color borderColor = editor.getColorsScheme().getColor(EditorColors.SELECTED_TEARLINE_COLOR);
Border outsideBorder = JBUI.Borders.customLine(borderColor, LINE_BORDER_THICKNESS);
Border insideBorder = JBUI.Borders.empty(EMPTY_BORDER_THICKNESS, EMPTY_BORDER_THICKNESS);
return BorderFactory.createCompoundBorder(outsideBorder, insideBorder);
}
@Nonnull
private static SideBorder createTopBottomSideBorder(boolean top) {
return new SideBorder(null, top ? SideBorder.BOTTOM : SideBorder.TOP) {
@Override
public Color getLineColor() {
Color result = EditorColorsManager.getInstance().getGlobalScheme().getColor(EditorColors.TEARLINE_COLOR);
return result == null ? JBColor.BLACK : result;
}
};
}