Search in sources :

Example 76 with TextEditor

use of com.intellij.openapi.fileEditor.TextEditor in project intellij-community by JetBrains.

the class BreadcrumbsInitializingActivity method removeBreadcrumbs.

private static void removeBreadcrumbs(@NotNull FileEditorManager fileEditorManager, @NotNull VirtualFile file) {
    final FileEditor[] fileEditors = fileEditorManager.getAllEditors(file);
    for (FileEditor fileEditor : fileEditors) {
        if (fileEditor instanceof TextEditor) {
            Editor editor = ((TextEditor) fileEditor).getEditor();
            BreadcrumbsXmlWrapper wrapper = BreadcrumbsXmlWrapper.getBreadcrumbsComponent(editor);
            if (wrapper != null) {
                disposeWrapper(fileEditorManager, fileEditor, wrapper);
            }
        }
    }
}
Also used : FileEditor(com.intellij.openapi.fileEditor.FileEditor) TextEditor(com.intellij.openapi.fileEditor.TextEditor) TextEditor(com.intellij.openapi.fileEditor.TextEditor) Editor(com.intellij.openapi.editor.Editor) FileEditor(com.intellij.openapi.fileEditor.FileEditor)

Example 77 with TextEditor

use of com.intellij.openapi.fileEditor.TextEditor in project intellij-community by JetBrains.

the class XmlTagTreeHighlightingConfigurable method clearTagTreeHighlighting.

private static void clearTagTreeHighlighting() {
    for (Project project : ProjectManager.getInstance().getOpenProjects()) {
        for (FileEditor fileEditor : FileEditorManager.getInstance(project).getAllEditors()) {
            if (fileEditor instanceof TextEditor) {
                final Editor editor = ((TextEditor) fileEditor).getEditor();
                XmlTagTreeHighlightingPass.clearHighlightingAndLineMarkers(editor, project);
                final BreadcrumbsXmlWrapper breadcrumbsXmlWrapper = BreadcrumbsXmlWrapper.getBreadcrumbsComponent(editor);
                if (breadcrumbsXmlWrapper != null) {
                    breadcrumbsXmlWrapper.queueUpdate();
                }
            }
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) FileEditor(com.intellij.openapi.fileEditor.FileEditor) TextEditor(com.intellij.openapi.fileEditor.TextEditor) Editor(com.intellij.openapi.editor.Editor) FileEditor(com.intellij.openapi.fileEditor.FileEditor) TextEditor(com.intellij.openapi.fileEditor.TextEditor) BreadcrumbsXmlWrapper(com.intellij.xml.breadcrumbs.BreadcrumbsXmlWrapper)

Example 78 with TextEditor

use of com.intellij.openapi.fileEditor.TextEditor in project intellij-plugins by JetBrains.

the class MarkdownActionUtil method findMarkdownTextEditor.

@Nullable
public static Editor findMarkdownTextEditor(AnActionEvent e) {
    final SplitFileEditor splitEditor = findSplitEditor(e);
    if (splitEditor == null) {
        // This fallback is used primarily for testing
        final PsiFile psiFile = e.getData(CommonDataKeys.PSI_FILE);
        if (psiFile != null && psiFile.getLanguage() == MarkdownLanguage.INSTANCE && ApplicationManager.getApplication().isUnitTestMode()) {
            return e.getData(CommonDataKeys.EDITOR);
        } else {
            return null;
        }
    }
    if (!(splitEditor.getMainEditor() instanceof TextEditor)) {
        return null;
    }
    final TextEditor mainEditor = (TextEditor) splitEditor.getMainEditor();
    if (!mainEditor.getComponent().isVisible()) {
        return null;
    }
    return mainEditor.getEditor();
}
Also used : TextEditor(com.intellij.openapi.fileEditor.TextEditor) PsiFile(com.intellij.psi.PsiFile) SplitFileEditor(org.intellij.plugins.markdown.ui.split.SplitFileEditor) Nullable(org.jetbrains.annotations.Nullable)

Example 79 with TextEditor

use of com.intellij.openapi.fileEditor.TextEditor in project oxy-template-support-plugin by mutant-industries.

the class CompiledPreviewUpdater method run.

@Override
public void run() {
    for (FileEditor fileEditor : FileEditorManager.getInstance(project).getAllEditors()) {
        if (!(fileEditor instanceof TextEditor)) {
            continue;
        }
        EditorEx editor = (EditorEx) ((TextEditor) fileEditor).getEditor();
        VirtualFile virtualFile = editor.getVirtualFile();
        Language language = virtualFile instanceof LightVirtualFile ? ((LightVirtualFile) virtualFile).getLanguage() : null;
        if (language != CompiledPreview.INSTANCE) {
            continue;
        }
        PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
        PsiFile originalFile;
        if (psiFile == null || (originalFile = psiFile.getUserData(CompiledPreviewController.ORIGINAL_FILE_KEY)) == null) {
            continue;
        }
        project.getComponent(CompiledPreviewController.class).showCompiledCode(originalFile, editor.getDocument());
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) FileEditor(com.intellij.openapi.fileEditor.FileEditor) TextEditor(com.intellij.openapi.fileEditor.TextEditor) EditorEx(com.intellij.openapi.editor.ex.EditorEx) Language(com.intellij.lang.Language) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) PsiFile(com.intellij.psi.PsiFile)

Example 80 with TextEditor

use of com.intellij.openapi.fileEditor.TextEditor in project psiviewer by cmf.

the class PluginPsiUtil method getEditorIfSelected.

@Nullable
public static Editor getEditorIfSelected(Project project, PsiElement psiElement) {
    VirtualFile elementFile = getVirtualFile(project, psiElement);
    if (elementFile == null) {
        return null;
    }
    FileEditor fileEditor = FileEditorManager.getInstance(project).getSelectedEditor(elementFile);
    Editor editor = null;
    if (fileEditor != null && fileEditor instanceof TextEditor) {
        editor = ((TextEditor) fileEditor).getEditor();
    }
    return editor;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileEditor(com.intellij.openapi.fileEditor.FileEditor) TextEditor(com.intellij.openapi.fileEditor.TextEditor) Editor(com.intellij.openapi.editor.Editor) FileEditor(com.intellij.openapi.fileEditor.FileEditor) TextEditor(com.intellij.openapi.fileEditor.TextEditor) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

TextEditor (com.intellij.openapi.fileEditor.TextEditor)81 FileEditor (com.intellij.openapi.fileEditor.FileEditor)57 Editor (com.intellij.openapi.editor.Editor)32 VirtualFile (com.intellij.openapi.vfs.VirtualFile)28 Project (com.intellij.openapi.project.Project)21 Document (com.intellij.openapi.editor.Document)14 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)13 Nullable (org.jetbrains.annotations.Nullable)13 PsiFile (com.intellij.psi.PsiFile)11 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)6 NotNull (org.jetbrains.annotations.NotNull)6 Disposable (com.intellij.openapi.Disposable)3 EditorEx (com.intellij.openapi.editor.ex.EditorEx)3 EditorNotificationPanel (com.intellij.ui.EditorNotificationPanel)3 LightweightHint (com.intellij.ui.LightweightHint)3 NonNls (org.jetbrains.annotations.NonNls)3 HighlightingPass (com.intellij.codeHighlighting.HighlightingPass)2 TextEditorHighlightingPass (com.intellij.codeHighlighting.TextEditorHighlightingPass)2 TemplateBuilder (com.intellij.codeInsight.template.TemplateBuilder)2 UndoManager (com.intellij.openapi.command.undo.UndoManager)2