use of com.intellij.openapi.editor.colors.EditorColorsScheme in project intellij-community by JetBrains.
the class StudyProjectComponent method projectOpened.
@Override
public void projectOpened() {
Course course = StudyTaskManager.getInstance(myProject).getCourse();
// Check if user has javafx lib in his JDK. Now bundled JDK doesn't have this lib inside.
if (StudyUtils.hasJavaFx()) {
Platform.setImplicitExit(false);
}
if (course != null && !course.isAdaptive() && !course.isUpToDate()) {
final Notification notification = new Notification("Update.course", "Course Updates", "Course is ready to <a href=\"update\">update</a>", NotificationType.INFORMATION, new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
FileEditorManagerEx.getInstanceEx(myProject).closeAllFiles();
ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
ProgressManager.getInstance().getProgressIndicator().setIndeterminate(true);
return execCancelable(() -> {
updateCourse();
return true;
});
}, "Updating Course", true, myProject);
EduUtils.synchronize();
course.setUpdated();
}
});
notification.notify(myProject);
}
StudyUtils.registerStudyToolWindow(course, myProject);
StartupManager.getInstance(myProject).runWhenProjectIsInitialized(() -> ApplicationManager.getApplication().invokeLater((DumbAwareRunnable) () -> ApplicationManager.getApplication().runWriteAction((DumbAwareRunnable) () -> {
Course course1 = StudyTaskManager.getInstance(myProject).getCourse();
if (course1 != null) {
UISettings instance = UISettings.getInstance();
instance.setHideToolStripes(false);
instance.fireUISettingsChanged();
registerShortcuts();
EduUsagesCollector.projectTypeOpened(course1.isAdaptive() ? EduNames.ADAPTIVE : EduNames.STUDY);
}
})));
myBusConnection = ApplicationManager.getApplication().getMessageBus().connect();
myBusConnection.subscribe(EditorColorsManager.TOPIC, new EditorColorsListener() {
@Override
public void globalSchemeChange(EditorColorsScheme scheme) {
final StudyToolWindow toolWindow = StudyUtils.getStudyToolWindow(myProject);
if (toolWindow != null) {
toolWindow.updateFonts(myProject);
}
}
});
}
use of com.intellij.openapi.editor.colors.EditorColorsScheme in project intellij-community by JetBrains.
the class HighlightUtils method highlightElements.
public static void highlightElements(@NotNull final Collection<? extends PsiElement> elementCollection) {
if (elementCollection.isEmpty()) {
return;
}
if (elementCollection.contains(null)) {
throw new IllegalArgumentException("Nulls passed in collection: " + elementCollection);
}
final Application application = ApplicationManager.getApplication();
application.invokeLater(() -> {
final PsiElement[] elements = PsiUtilCore.toPsiElementArray(elementCollection);
final PsiElement firstElement = elements[0];
if (ContainerUtil.exists(elements, element -> !element.isValid())) {
return;
}
final Project project = firstElement.getProject();
if (project.isDisposed())
return;
final FileEditorManager editorManager = FileEditorManager.getInstance(project);
final EditorColorsManager editorColorsManager = EditorColorsManager.getInstance();
final Editor editor = editorManager.getSelectedTextEditor();
if (editor == null) {
return;
}
final EditorColorsScheme globalScheme = editorColorsManager.getGlobalScheme();
final TextAttributes textattributes = globalScheme.getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
final HighlightManager highlightManager = HighlightManager.getInstance(project);
highlightManager.addOccurrenceHighlights(editor, elements, textattributes, true, null);
final WindowManager windowManager = WindowManager.getInstance();
final StatusBar statusBar = windowManager.getStatusBar(project);
statusBar.setInfo(InspectionGadgetsBundle.message("press.escape.to.remove.highlighting.message"));
final FindManager findmanager = FindManager.getInstance(project);
FindModel findmodel = findmanager.getFindNextModel();
if (findmodel == null) {
findmodel = findmanager.getFindInFileModel();
}
findmodel.setSearchHighlighters(true);
findmanager.setFindWasPerformed();
findmanager.setFindNextModel(findmodel);
});
}
use of com.intellij.openapi.editor.colors.EditorColorsScheme in project intellij-community by JetBrains.
the class SrcFileAnnotator method createRangeHighlighter.
private RangeHighlighter createRangeHighlighter(final long date, final MarkupModel markupModel, final boolean coverageByTestApplicable, final TreeMap<Integer, LineData> executableLines, @Nullable final String className, final int line, final int lineNumberInCurrent, @NotNull final CoverageSuitesBundle coverageSuite, Object[] lines, @NotNull MyEditorBean editorBean) {
EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
final TextAttributes attributes = scheme.getAttributes(CoverageLineMarkerRenderer.getAttributesKey(line, executableLines));
TextAttributes textAttributes = null;
if (attributes.getBackgroundColor() != null) {
textAttributes = attributes;
}
Document document = editorBean.getDocument();
Editor editor = editorBean.getEditor();
final int startOffset = document.getLineStartOffset(lineNumberInCurrent);
final int endOffset = document.getLineEndOffset(lineNumberInCurrent);
final RangeHighlighter highlighter = markupModel.addRangeHighlighter(startOffset, endOffset, HighlighterLayer.SELECTION - 1, textAttributes, HighlighterTargetArea.LINES_IN_RANGE);
final Function<Integer, Integer> newToOldConverter = newLine -> {
if (editor == null)
return -1;
final TIntIntHashMap oldLineMapping = getNewToOldLineMapping(date, editorBean);
return oldLineMapping != null ? oldLineMapping.get(newLine.intValue()) : newLine.intValue();
};
final Function<Integer, Integer> oldToNewConverter = newLine -> {
if (editor == null)
return -1;
final TIntIntHashMap newLineMapping = getOldToNewLineMapping(date, editorBean);
return newLineMapping != null ? newLineMapping.get(newLine.intValue()) : newLine.intValue();
};
final LineMarkerRendererWithErrorStripe markerRenderer = coverageSuite.getLineMarkerRenderer(line, className, executableLines, coverageByTestApplicable, coverageSuite, newToOldConverter, oldToNewConverter, CoverageDataManager.getInstance(myProject).isSubCoverageActive());
highlighter.setLineMarkerRenderer(markerRenderer);
final LineData lineData = className != null ? (LineData) lines[line + 1] : null;
if (lineData != null && lineData.getStatus() == LineCoverage.NONE) {
highlighter.setErrorStripeMarkColor(markerRenderer.getErrorStripeColor(editor));
highlighter.setThinErrorStripeMark(true);
highlighter.setGreedyToLeft(true);
highlighter.setGreedyToRight(true);
}
return highlighter;
}
use of com.intellij.openapi.editor.colors.EditorColorsScheme in project intellij-community by JetBrains.
the class ResourceBundlePropertyStructureViewElement method getPresentation.
@Override
@NotNull
public ItemPresentation getPresentation() {
return new ResourceBundleEditorRenderer.TextAttributesPresentation() {
@Override
public String getPresentableText() {
return myPresentableName == null ? getProperty().getName() : myPresentableName.isEmpty() ? PROPERTY_GROUP_KEY_TEXT : myPresentableName;
}
@Override
public String getLocationString() {
return null;
}
@Override
public Icon getIcon(boolean open) {
return PlatformIcons.PROPERTY_ICON;
}
@Override
public TextAttributes getTextAttributes(EditorColorsScheme colorsScheme) {
final TextAttributesKey baseAttrKey = (myPresentableName != null && myPresentableName.isEmpty()) ? GROUP_KEY : PropertiesHighlighter.PROPERTY_KEY;
final TextAttributes baseAttrs = colorsScheme.getAttributes(baseAttrKey);
if (getProperty().getPsiElement().isValid()) {
if (myInspectedPropertyProblems != null) {
TextAttributes highlightingAttributes = myInspectedPropertyProblems.getTextAttributes(colorsScheme);
if (highlightingAttributes != null) {
return TextAttributes.merge(baseAttrs, highlightingAttributes);
}
}
}
return baseAttrs;
}
};
}
use of com.intellij.openapi.editor.colors.EditorColorsScheme in project intellij-community by JetBrains.
the class ComponentTree method setUI.
public void setUI(final TreeUI ui) {
super.setUI(ui);
// [vova] we cannot create this hash in constructor and just clear it here. The
// problem is that setUI is invoked by constructor of superclass.
myHighlightAttributes = new HashMap<>();
final EditorColorsScheme globalScheme = EditorColorsManager.getInstance().getGlobalScheme();
final TextAttributes attributes = globalScheme.getAttributes(JavaHighlightingColors.STRING);
myBindingAttributes = new SimpleTextAttributes(SimpleTextAttributes.STYLE_BOLD, UIUtil.getTreeForeground());
myClassAttributes = new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, UIUtil.getTreeForeground());
myPackageAttributes = new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, Color.GRAY);
myTitleAttributes = new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, attributes.getForegroundColor());
myUnknownAttributes = new SimpleTextAttributes(SimpleTextAttributes.STYLE_WAVED, JBColor.RED);
}
Aggregations