use of com.intellij.openapi.fileEditor.TextEditor in project intellij-community by JetBrains.
the class ForcedSoftWrapsNotificationProvider method createNotificationPanel.
@Nullable
@Override
public EditorNotificationPanel createNotificationPanel(@NotNull final VirtualFile file, @NotNull final FileEditor fileEditor) {
if (!(fileEditor instanceof TextEditor))
return null;
final Editor editor = ((TextEditor) fileEditor).getEditor();
final Project project = editor.getProject();
if (project == null || !Boolean.TRUE.equals(editor.getUserData(EditorImpl.FORCED_SOFT_WRAPS)) || PropertiesComponent.getInstance().isTrueValue(DISABLED_NOTIFICATION_KEY))
return null;
final EditorNotificationPanel panel = new EditorNotificationPanel();
panel.setText(EditorBundle.message("forced.soft.wrap.message"));
panel.createActionLabel(EditorBundle.message("forced.soft.wrap.hide.message"), () -> {
editor.putUserData(EditorImpl.FORCED_SOFT_WRAPS, null);
EditorNotifications.getInstance(project).updateNotifications(file);
});
panel.createActionLabel(EditorBundle.message("forced.soft.wrap.dont.show.again.message"), () -> {
PropertiesComponent.getInstance().setValue(DISABLED_NOTIFICATION_KEY, "true");
EditorNotifications.getInstance(project).updateAllNotifications();
});
return panel;
}
use of com.intellij.openapi.fileEditor.TextEditor in project intellij-community by JetBrains.
the class CoverageDataManagerImpl method applyInformationToEditor.
private void applyInformationToEditor(FileEditor[] editors, final VirtualFile file) {
final PsiFile psiFile = doInReadActionIfProjectOpen(() -> PsiManager.getInstance(myProject).findFile(file));
if (psiFile != null && myCurrentSuitesBundle != null && psiFile.isPhysical()) {
final CoverageEngine engine = myCurrentSuitesBundle.getCoverageEngine();
if (!engine.coverageEditorHighlightingApplicableTo(psiFile)) {
return;
}
for (FileEditor editor : editors) {
if (editor instanceof TextEditor) {
final Editor textEditor = ((TextEditor) editor).getEditor();
SrcFileAnnotator annotator;
synchronized (ANNOTATORS_LOCK) {
annotator = myAnnotators.remove(textEditor);
}
if (annotator != null) {
Disposer.dispose(annotator);
}
break;
}
}
for (FileEditor editor : editors) {
if (editor instanceof TextEditor) {
final Editor textEditor = ((TextEditor) editor).getEditor();
SrcFileAnnotator annotator = getAnnotator(textEditor);
if (annotator == null) {
annotator = new SrcFileAnnotator(psiFile, textEditor);
synchronized (ANNOTATORS_LOCK) {
myAnnotators.put(textEditor, annotator);
}
}
if (myCurrentSuitesBundle != null && engine.acceptedByFilters(psiFile, myCurrentSuitesBundle)) {
annotator.showCoverageInformation(myCurrentSuitesBundle);
}
}
}
}
}
use of com.intellij.openapi.fileEditor.TextEditor in project intellij-community by JetBrains.
the class SrcFileAnnotator method showEditorWarningMessage.
private void showEditorWarningMessage(final String message) {
Editor textEditor = myEditor;
PsiFile file = myFile;
ApplicationManager.getApplication().invokeLater(() -> {
if (textEditor == null || textEditor.isDisposed() || file == null)
return;
final FileEditorManager fileEditorManager = FileEditorManager.getInstance(myProject);
final VirtualFile vFile = file.getVirtualFile();
assert vFile != null;
Map<FileEditor, EditorNotificationPanel> map = file.getCopyableUserData(NOTIFICATION_PANELS);
if (map == null) {
map = new HashMap<>();
file.putCopyableUserData(NOTIFICATION_PANELS, map);
}
final FileEditor[] editors = fileEditorManager.getAllEditors(vFile);
for (final FileEditor editor : editors) {
if (isCurrentEditor(editor)) {
final EditorNotificationPanel panel = new EditorNotificationPanel() {
{
myLabel.setIcon(AllIcons.General.ExclMark);
myLabel.setText(message);
}
};
panel.createActionLabel("Close", () -> fileEditorManager.removeTopComponent(editor, panel));
map.put(editor, panel);
fileEditorManager.addTopComponent(editor, panel);
break;
}
}
});
}
use of com.intellij.openapi.fileEditor.TextEditor in project intellij-community by JetBrains.
the class XDebuggerInlayUtil method clearInlays.
public static void clearInlays(@NotNull Project project) {
UIUtil.invokeLaterIfNeeded(() -> {
FileEditor[] editors = FileEditorManager.getInstance(project).getAllEditors();
for (FileEditor editor : editors) {
if (editor instanceof TextEditor) {
Editor e = ((TextEditor) editor).getEditor();
List<Inlay> existing = e.getInlayModel().getInlineElementsInRange(0, e.getDocument().getTextLength());
for (Inlay inlay : existing) {
if (inlay.getRenderer() instanceof MyRenderer) {
Disposer.dispose(inlay);
}
}
}
}
});
}
use of com.intellij.openapi.fileEditor.TextEditor in project intellij-community by JetBrains.
the class ExecutionPointHighlighter method doShow.
private void doShow(boolean navigate) {
ApplicationManager.getApplication().assertIsDispatchThread();
if (ApplicationManager.getApplication().isUnitTestMode())
return;
removeHighlighter();
OpenFileDescriptor fileDescriptor = myOpenFileDescriptor;
if (!navigate && myOpenFileDescriptor != null) {
fileDescriptor = new OpenFileDescriptor(myProject, myOpenFileDescriptor.getFile());
}
myEditor = null;
if (fileDescriptor != null) {
if (!navigate) {
FileEditor editor = FileEditorManager.getInstance(fileDescriptor.getProject()).getSelectedEditor(fileDescriptor.getFile());
if (editor instanceof TextEditor) {
myEditor = ((TextEditor) editor).getEditor();
}
}
if (myEditor == null) {
myEditor = XDebuggerUtilImpl.createEditor(fileDescriptor);
}
}
if (myEditor != null) {
addHighlighter();
}
}
Aggregations