use of com.intellij.openapi.editor.markup.TextAttributes in project intellij-community by JetBrains.
the class IntroduceVariableHandler method getSettings.
@Override
public IntroduceVariableSettings getSettings(Project project, Editor editor, PsiExpression expr, PsiExpression[] occurrences, TypeSelectorManagerImpl typeSelectorManager, boolean declareFinalIfAll, boolean anyAssignmentLHS, final InputValidator validator, PsiElement anchor, JavaReplaceChoice replaceChoice) {
if (replaceChoice == null && ApplicationManager.getApplication().isUnitTestMode()) {
replaceChoice = JavaReplaceChoice.NO;
}
if (replaceChoice != null) {
return super.getSettings(project, editor, expr, occurrences, typeSelectorManager, declareFinalIfAll, anyAssignmentLHS, validator, anchor, replaceChoice);
}
ArrayList<RangeHighlighter> highlighters = new ArrayList<>();
HighlightManager highlightManager = null;
if (editor != null) {
highlightManager = HighlightManager.getInstance(project);
EditorColorsManager colorsManager = EditorColorsManager.getInstance();
TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
if (occurrences.length > 1) {
highlightManager.addOccurrenceHighlights(editor, occurrences, attributes, true, highlighters);
}
}
IntroduceVariableDialog dialog = new IntroduceVariableDialog(project, expr, occurrences.length, anyAssignmentLHS, declareFinalIfAll, typeSelectorManager, validator);
if (!dialog.showAndGet()) {
if (occurrences.length > 1) {
WindowManager.getInstance().getStatusBar(project).setInfo(RefactoringBundle.message("press.escape.to.remove.the.highlighting"));
}
} else {
if (editor != null) {
for (RangeHighlighter highlighter : highlighters) {
highlightManager.removeSegmentHighlighter(editor, highlighter);
}
}
}
return dialog;
}
use of com.intellij.openapi.editor.markup.TextAttributes in project intellij-community by JetBrains.
the class InplaceIntroduceParameterPopup method getTextAttributesForAdd.
private static TextAttributes getTextAttributesForAdd() {
final TextAttributes textAttributes = new TextAttributes();
textAttributes.setEffectType(EffectType.ROUNDED_BOX);
textAttributes.setEffectColor(JBColor.RED);
return textAttributes;
}
use of com.intellij.openapi.editor.markup.TextAttributes in project intellij-community by JetBrains.
the class AntTargetNodeDescriptor method update.
public boolean update() {
final CompositeAppearance oldText = myHighlightedText;
final boolean isMeta = myTarget instanceof MetaTarget;
setIcon(isMeta ? AntIcons.MetaTarget : AntIcons.Target);
myHighlightedText = new CompositeAppearance();
final AntBuildFile buildFile = isMeta ? ((MetaTarget) myTarget).getBuildFile() : myTarget.getModel().getBuildFile();
final Color color = buildFile.isTargetVisible(myTarget) ? UIUtil.getLabelForeground() : UIUtil.getLabelDisabledForeground();
TextAttributes nameAttributes = new TextAttributes(color, null, null, EffectType.BOXED, myTarget.isDefault() ? Font.BOLD : Font.PLAIN);
myHighlightedText.getEnding().addText(myTarget.getDisplayName(), nameAttributes);
AntConfigurationBase antConfiguration = AntConfigurationBase.getInstance(myProject);
final ArrayList<String> addedNames = new ArrayList<>(4);
for (final ExecutionEvent event : antConfiguration.getEventsForTarget(myTarget)) {
final String presentableName;
if ((event instanceof ExecuteCompositeTargetEvent)) {
presentableName = ((ExecuteCompositeTargetEvent) event).getMetaTargetName();
if (presentableName.equals(myTarget.getName())) {
continue;
}
} else {
presentableName = event.getPresentableName();
}
if (!addedNames.contains(presentableName)) {
addedNames.add(presentableName);
myHighlightedText.getEnding().addText(" (" + presentableName + ')', ourPostfixAttributes);
}
}
final RunManagerEx runManager = RunManagerEx.getInstanceEx(myProject);
final VirtualFile vFile = buildFile.getVirtualFile();
if (vFile != null) {
for (AntBeforeRunTask task : runManager.getBeforeRunTasks(AntBeforeRunTaskProvider.ID)) {
if (task.isRunningTarget(myTarget)) {
myHighlightedText.getEnding().addText(" (Before Run/Debug)", ourPostfixAttributes);
break;
}
}
}
myName = myHighlightedText.getText();
final AntBuildTargetBase target = getTarget();
if (!addShortcutText(target.getActionId())) {
if (target.isDefault()) {
addShortcutText(((AntBuildModelBase) target.getModel()).getDefaultTargetActionId());
}
}
return !Comparing.equal(myHighlightedText, oldText);
}
use of com.intellij.openapi.editor.markup.TextAttributes in project intellij-community by JetBrains.
the class CoverageLineMarkerRenderer method paint.
public void paint(Editor editor, Graphics g, Rectangle r) {
final TextAttributes color = editor.getColorsScheme().getAttributes(myKey);
Color bgColor = color.getBackgroundColor();
if (bgColor == null) {
bgColor = color.getForegroundColor();
}
if (editor.getSettings().isLineNumbersShown() || ((EditorGutterComponentEx) editor.getGutter()).isAnnotationsShown()) {
if (bgColor != null) {
bgColor = ColorUtil.toAlpha(bgColor, 150);
}
}
if (bgColor != null) {
g.setColor(bgColor);
}
g.fillRect(r.x, r.y, r.width, r.height);
final LineData lineData = getLineData(editor.xyToLogicalPosition(new Point(0, r.y)).line);
if (lineData != null && lineData.isCoveredByOneTest()) {
g.drawImage(ImageLoader.loadFromResource("/gutter/unique.png"), r.x, r.y, 8, 8, editor.getComponent());
}
}
use of com.intellij.openapi.editor.markup.TextAttributes in project intellij-community by JetBrains.
the class EclipseThemeOptionHandler method toBackgroundAttributes.
private static TextAttributes toBackgroundAttributes(@NotNull TextAttributes attributes) {
TextAttributes backgroundAttrs = attributes.clone();
backgroundAttrs.setBackgroundColor(attributes.getForegroundColor());
backgroundAttrs.setForegroundColor(null);
return backgroundAttrs;
}
Aggregations