use of com.intellij.openapi.fileEditor.TextEditor in project intellij-community by JetBrains.
the class AnnotateLocalFileAction method perform.
private static void perform(AnActionEvent e, boolean selected) {
final VcsContext context = VcsContextFactory.SERVICE.getInstance().createContextOn(e);
if (!selected) {
for (Editor editor : getEditors(context)) {
editor.getGutter().closeAllAnnotations();
}
} else {
Project project = assertNotNull(context.getProject());
VirtualFile selectedFile = assertNotNull(context.getSelectedFile());
Editor editor = context.getEditor();
if (editor == null) {
FileEditor[] fileEditors = FileEditorManager.getInstance(project).openFile(selectedFile, false);
for (FileEditor fileEditor : fileEditors) {
if (fileEditor instanceof TextEditor) {
editor = ((TextEditor) fileEditor).getEditor();
}
}
}
LOG.assertTrue(editor != null);
doAnnotate(editor, project);
}
}
use of com.intellij.openapi.fileEditor.TextEditor in project intellij-community by JetBrains.
the class EditorNotificationsImpl method createTask.
@Nullable
private ReadTask createTask(@NotNull final ProgressIndicator indicator, @NotNull final VirtualFile file) {
List<FileEditor> editors = ContainerUtil.filter(FileEditorManager.getInstance(myProject).getAllEditors(file), editor -> !(editor instanceof TextEditor) || AsyncEditorLoader.isEditorLoaded(((TextEditor) editor).getEditor()));
if (editors.isEmpty())
return null;
return new ReadTask() {
private boolean isOutdated() {
if (myProject.isDisposed() || !file.isValid() || indicator != getCurrentProgress(file)) {
return true;
}
for (FileEditor editor : editors) {
if (!editor.isValid()) {
return true;
}
}
return false;
}
@Nullable
@Override
public Continuation performInReadAction(@NotNull ProgressIndicator indicator) throws ProcessCanceledException {
if (isOutdated())
return null;
final List<Provider> providers = DumbService.getInstance(myProject).filterByDumbAwareness(EXTENSION_POINT_NAME.getExtensions(myProject));
final List<Runnable> updates = ContainerUtil.newArrayList();
for (final FileEditor editor : editors) {
for (final Provider<?> provider : providers) {
final JComponent component = provider.createNotificationPanel(file, editor);
updates.add(() -> updateNotification(editor, provider.getKey(), component));
}
}
return new Continuation(() -> {
if (!isOutdated()) {
file.putUserData(CURRENT_UPDATES, null);
for (Runnable update : updates) {
update.run();
}
}
}, ModalityState.any());
}
@Override
public void onCanceled(@NotNull ProgressIndicator ignored) {
if (getCurrentProgress(file) == indicator) {
updateNotifications(file);
}
}
};
}
use of com.intellij.openapi.fileEditor.TextEditor in project intellij-community by JetBrains.
the class XDebuggerSmartStepIntoHandler method perform.
@Override
protected void perform(@NotNull XDebugSession session, DataContext dataContext) {
XSmartStepIntoHandler<?> handler = session.getDebugProcess().getSmartStepIntoHandler();
XSourcePosition position = session.getTopFramePosition();
if (position == null || handler == null)
return;
FileEditor editor = FileEditorManager.getInstance(session.getProject()).getSelectedEditor(position.getFile());
if (editor instanceof TextEditor) {
doSmartStepInto(handler, position, session, ((TextEditor) editor).getEditor());
}
}
use of com.intellij.openapi.fileEditor.TextEditor in project intellij-community by JetBrains.
the class XDebuggerInlayUtil method createInlay.
public static void createInlay(@NotNull Project project, @NotNull VirtualFile file, int offset, String inlayText) {
UIUtil.invokeLaterIfNeeded(() -> {
FileEditor editor = FileEditorManager.getInstance(project).getSelectedEditor(file);
if (editor instanceof TextEditor) {
Editor e = ((TextEditor) editor).getEditor();
CharSequence text = e.getDocument().getImmutableCharSequence();
int insertOffset = offset;
while (insertOffset < text.length() && Character.isJavaIdentifierPart(text.charAt(insertOffset))) insertOffset++;
List<Inlay> existing = e.getInlayModel().getInlineElementsInRange(insertOffset, insertOffset);
for (Inlay inlay : existing) {
if (inlay.getRenderer() instanceof MyRenderer) {
Disposer.dispose(inlay);
}
}
e.getInlayModel().addInlineElement(insertOffset, new MyRenderer(inlayText));
}
});
}
use of com.intellij.openapi.fileEditor.TextEditor in project intellij-community by JetBrains.
the class DetectableIndentOptionsProvider method getNotificationInfo.
@Nullable
@Override
public EditorNotificationInfo getNotificationInfo(@NotNull final Project project, @NotNull final VirtualFile file, @NotNull final FileEditor fileEditor, @NotNull IndentOptions userOptions, @NotNull IndentOptions detectedOptions) {
final NotificationLabels labels = getNotificationLabels(userOptions, detectedOptions);
final Editor editor = fileEditor instanceof TextEditor ? ((TextEditor) fileEditor).getEditor() : null;
if (labels == null || editor == null)
return null;
ActionLabelData okAction = new ActionLabelData(ApplicationBundle.message("code.style.indents.detector.accept"), () -> setAccepted(file));
ActionLabelData disableForSingleFile = new ActionLabelData(labels.revertToOldSettingsLabel, () -> {
disableForFile(file);
if (editor instanceof EditorEx) {
((EditorEx) editor).reinitSettings();
}
});
ActionLabelData showSettings = new ActionLabelData(ApplicationBundle.message("code.style.indents.detector.show.settings"), () -> ShowSettingsUtilImpl.showSettingsDialog(project, "preferences.sourceCode", "detect indent"));
final List<ActionLabelData> actions = ContainerUtil.newArrayList(okAction, disableForSingleFile, showSettings);
return new EditorNotificationInfo() {
@NotNull
@Override
public List<ActionLabelData> getLabelAndActions() {
return actions;
}
@NotNull
@Override
public String getTitle() {
return labels.title;
}
};
}
Aggregations