summaryrefslogtreecommitdiff
path: root/platform/lang-impl/src/com/intellij/find/impl/livePreview
diff options
context:
space:
mode:
Diffstat (limited to 'platform/lang-impl/src/com/intellij/find/impl/livePreview')
-rw-r--r--platform/lang-impl/src/com/intellij/find/impl/livePreview/LivePreview.java31
-rw-r--r--platform/lang-impl/src/com/intellij/find/impl/livePreview/ReplacementView.java20
2 files changed, 25 insertions, 26 deletions
diff --git a/platform/lang-impl/src/com/intellij/find/impl/livePreview/LivePreview.java b/platform/lang-impl/src/com/intellij/find/impl/livePreview/LivePreview.java
index 4ba97e0151e5..995a67ecafa1 100644
--- a/platform/lang-impl/src/com/intellij/find/impl/livePreview/LivePreview.java
+++ b/platform/lang-impl/src/com/intellij/find/impl/livePreview/LivePreview.java
@@ -21,7 +21,10 @@ import com.intellij.find.FindModel;
import com.intellij.find.FindResult;
import com.intellij.ide.IdeTooltipManager;
import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.editor.*;
+import com.intellij.openapi.editor.Document;
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.editor.SelectionModel;
+import com.intellij.openapi.editor.colors.CodeInsightColors;
import com.intellij.openapi.editor.colors.EditorColors;
import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.event.*;
@@ -46,7 +49,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.awt.*;
-import java.io.*;
+import java.io.PrintStream;
import java.util.*;
import java.util.List;
@@ -95,11 +98,8 @@ public class LivePreview extends DocumentAdapter implements SearchResults.Search
private RangeHighlighter myCursorHighlighter;
private final List<VisibleAreaListener> myVisibleAreaListenersToRemove = new ArrayList<VisibleAreaListener>();
- private static TextAttributes strikout(TextAttributes attributes) {
- TextAttributes textAttributes = attributes.clone();
- textAttributes.setEffectColor(Color.BLACK);
- textAttributes.setEffectType(EffectType.STRIKEOUT);
- return textAttributes;
+ private static TextAttributes strikout() {
+ return EditorColorsManager.getInstance().getGlobalScheme().getAttributes(CodeInsightColors.DEPRECATED_ATTRIBUTES).clone();
}
private Delegate myDelegate;
@@ -161,7 +161,7 @@ public class LivePreview extends DocumentAdapter implements SearchResults.Search
ranges.add(new Pair<Integer, Character>(editor.getDocument().getTextLength()+1, '\n'));
ContainerUtil.sort(ranges, new Comparator<Pair<Integer, Character>>() {
@Override
- public int compare(Pair<Integer, Character> pair, Pair<Integer, Character> pair2) {
+ public int compare(@NotNull Pair<Integer, Character> pair, @NotNull Pair<Integer, Character> pair2) {
int res = pair.first - pair2.first;
if (res == 0) {
@@ -210,7 +210,7 @@ public class LivePreview extends DocumentAdapter implements SearchResults.Search
}
myHighlighters.removeAll(unused);
Project project = mySearchResults.getProject();
- if (!project.isDisposed()) {
+ if (project != null && !project.isDisposed()) {
for (RangeHighlighter highlighter : unused) {
HighlightManager.getInstance(project).removeSegmentHighlighter(mySearchResults.getEditor(), highlighter);
}
@@ -240,7 +240,8 @@ public class LivePreview extends DocumentAdapter implements SearchResults.Search
Editor editor = mySearchResults.getEditor();
if (cursor != null) {
Set<RangeHighlighter> dummy = new HashSet<RangeHighlighter>();
- highlightRange(cursor, new TextAttributes(null, null, Color.BLACK, EffectType.ROUNDED_BOX, 0), dummy);
+ Color color = editor.getColorsScheme().getColor(EditorColors.CARET_COLOR);
+ highlightRange(cursor, new TextAttributes(null, null, color, EffectType.ROUNDED_BOX, 0), dummy);
if (!dummy.isEmpty()) {
myCursorHighlighter = dummy.iterator().next();
}
@@ -322,7 +323,7 @@ public class LivePreview extends DocumentAdapter implements SearchResults.Search
attributes.setEffectColor(attributes.getBackgroundColor());
}
if (mySearchResults.isExcluded(range)) {
- highlightRange(range, strikout(attributes), myHighlighters);
+ highlightRange(range, strikout(), myHighlighters);
} else {
highlightRange(range, attributes, myHighlighters);
}
@@ -389,18 +390,18 @@ public class LivePreview extends DocumentAdapter implements SearchResults.Search
final FindModel findModel = mySearchResults.getFindModel();
if (findModel.isRegularExpressions() && findModel.isReplaceState()) {
- showBalloon(cursor, editor, replacementPreviewText);
+ showBalloon(editor, replacementPreviewText);
}
}
}
- private void showBalloon(FindResult cursor, Editor editor, String replacementPreviewText) {
+ private void showBalloon(Editor editor, String replacementPreviewText) {
if (ApplicationManager.getApplication().isUnitTestMode()) {
myReplacementPreviewText = replacementPreviewText;
return;
}
- ReplacementView replacementView = new ReplacementView(replacementPreviewText, cursor);
+ ReplacementView replacementView = new ReplacementView(replacementPreviewText);
BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createBalloonBuilder(replacementView);
balloonBuilder.setFadeoutTime(0);
@@ -546,7 +547,7 @@ public class LivePreview extends DocumentAdapter implements SearchResults.Search
}
}
- private void requestBalloonHiding(final Balloon object) {
+ private static void requestBalloonHiding(final Balloon object) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
diff --git a/platform/lang-impl/src/com/intellij/find/impl/livePreview/ReplacementView.java b/platform/lang-impl/src/com/intellij/find/impl/livePreview/ReplacementView.java
index 4f87efd8c970..b9b01667a656 100644
--- a/platform/lang-impl/src/com/intellij/find/impl/livePreview/ReplacementView.java
+++ b/platform/lang-impl/src/com/intellij/find/impl/livePreview/ReplacementView.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,30 +15,28 @@
*/
package com.intellij.find.impl.livePreview;
-import com.intellij.find.FindResult;
+import com.intellij.ui.Gray;
import com.intellij.ui.JBColor;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
public class ReplacementView extends JPanel {
-
private static final String MALFORMED_REPLACEMENT_STRING = "Malformed replacement string";
- private final String myReplacement;
@Override
- protected void paintComponent(Graphics graphics) {
-
+ protected void paintComponent(@NotNull Graphics graphics) {
}
- public ReplacementView(final String replacement, final FindResult occurrence) {
- myReplacement = replacement;
- String textToShow = myReplacement;
- if (myReplacement == null) {
+ public ReplacementView(@Nullable String replacement) {
+ String textToShow = replacement;
+ if (replacement == null) {
textToShow = MALFORMED_REPLACEMENT_STRING;
}
JLabel jLabel = new JLabel(textToShow);
- jLabel.setForeground(myReplacement != null ? Color.WHITE : JBColor.RED);
+ jLabel.setForeground(replacement != null ? new JBColor(Gray._240, Gray._200) : JBColor.RED);
add(jLabel);
}
}