Search in sources :

Example 16 with EditorWindow

use of com.intellij.openapi.fileEditor.impl.EditorWindow in project ActiveTabHighlighterPlugin by tobszarny.

the class TabHighlighterFileEditorListener method selectionChanged.

@Override
public void selectionChanged(@NotNull FileEditorManagerEvent fileEditorManagerEvent) {
    final Project project = fileEditorManagerEvent.getManager().getProject();
    final FileEditorManagerEx manager = FileEditorManagerEx.getInstanceEx(project);
    final FileColorManager fileColorManager = FileColorManager.getInstance(project);
    final HighlighterSettingsConfig highlighterSettingsConfig = HighlighterSettingsConfig.getInstance();
    final VirtualFile oldFile = fileEditorManagerEvent.getOldFile();
    final VirtualFile newFile = fileEditorManagerEvent.getNewFile();
    for (EditorWindow editorWindow : manager.getWindows()) {
        setUnfocusedTabWithColorManagerDefaultColor(fileColorManager, oldFile, editorWindow);
        setFocusedTabHighlighterColor(highlighterSettingsConfig, newFile, editorWindow);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) FileColorManager(com.intellij.ui.FileColorManager) FileEditorManagerEx(com.intellij.openapi.fileEditor.ex.FileEditorManagerEx) EditorWindow(com.intellij.openapi.fileEditor.impl.EditorWindow)

Example 17 with EditorWindow

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

the class CompiledPreviewController method showCompiledCode.

public boolean showCompiledCode(@NotNull final PsiFile originalFile) {
    PsiFile psiFile;
    Document document = null;
    VirtualFile virtualFile = null;
    EditorWindow editorWindow = null;
    boolean result, newTabCreated = false;
    FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(myProject);
    // check for already opened editor with compiled source first
    for (FileEditor fileEditor : fileEditorManager.getAllEditors()) {
        if (!(fileEditor instanceof TextEditor)) {
            continue;
        }
        EditorEx editor = (EditorEx) ((TextEditor) fileEditor).getEditor();
        virtualFile = editor.getVirtualFile();
        psiFile = PsiManager.getInstance(myProject).findFile(virtualFile);
        if (psiFile != null && originalFile.isEquivalentTo(psiFile.getUserData(ORIGINAL_FILE_KEY))) {
            document = editor.getDocument();
            // find editor window where the file is opened
            for (EditorWindow window : fileEditorManager.getWindows()) {
                if (findFileIndex(window, virtualFile) != -1) {
                    editorWindow = window;
                    break;
                }
            }
            break;
        }
    }
    // create new editor
    if (document == null) {
        virtualFile = new LightVirtualFile(originalFile.getName() + COMPILED_FILE_SUFFIX);
        ((LightVirtualFile) virtualFile).setLanguage(CompiledPreview.INSTANCE);
        ((LightVirtualFile) virtualFile).setFileType(CompiledPreviewFileType.INSTANCE);
        psiFile = PsiManager.getInstance(myProject).findFile(virtualFile);
        assert psiFile != null;
        document = PsiDocumentManager.getInstance(myProject).getDocument(psiFile);
        assert document != null;
        psiFile.putUserData(ORIGINAL_FILE_KEY, originalFile);
        editorWindow = fileEditorManager.getCurrentWindow();
        newTabCreated = true;
    }
    assert editorWindow != null;
    if (result = showCompiledCode(originalFile, document)) {
        if (newTabCreated) {
            editorWindow.split(SwingConstants.HORIZONTAL, false, virtualFile, false);
        }
        if (findFileIndex(editorWindow, virtualFile) == -1) {
            fileEditorManager.openFile(virtualFile, false);
        }
        // switch to editor with recompiled source
        editorWindow.setEditor(editorWindow.findFileComposite(virtualFile), false);
    }
    return result;
}
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) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) PsiFile(com.intellij.psi.PsiFile) Document(com.intellij.openapi.editor.Document) FileEditorManagerEx(com.intellij.openapi.fileEditor.ex.FileEditorManagerEx) EditorWindow(com.intellij.openapi.fileEditor.impl.EditorWindow)

Example 18 with EditorWindow

use of com.intellij.openapi.fileEditor.impl.EditorWindow in project ideavim by JetBrains.

the class WindowGroup method selectWindowInRow.

public void selectWindowInRow(@NotNull DataContext context, int relativePosition, boolean vertical) {
    final FileEditorManagerEx fileEditorManager = getFileEditorManager(context);
    final EditorWindow currentWindow = fileEditorManager.getCurrentWindow();
    if (currentWindow != null) {
        final EditorWindow[] windows = fileEditorManager.getWindows();
        final List<EditorWindow> row = findWindowsInRow(currentWindow, Arrays.asList(windows), vertical);
        selectWindow(currentWindow, row, relativePosition);
    }
}
Also used : FileEditorManagerEx(com.intellij.openapi.fileEditor.ex.FileEditorManagerEx) EditorWindow(com.intellij.openapi.fileEditor.impl.EditorWindow)

Example 19 with EditorWindow

use of com.intellij.openapi.fileEditor.impl.EditorWindow in project ideavim by JetBrains.

the class WindowGroup method splitWindow.

private void splitWindow(int orientation, @NotNull DataContext context, @NotNull String filename) {
    final Project project = PlatformDataKeys.PROJECT.getData(context);
    final FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project);
    VirtualFile virtualFile = null;
    if (filename.length() > 0 && project != null) {
        virtualFile = VimPlugin.getFile().findFile(filename, project);
        if (virtualFile == null) {
            VimPlugin.showMessage("Could not find file: " + filename);
            return;
        }
    }
    final EditorWindow editorWindow = fileEditorManager.getSplitters().getCurrentWindow();
    if (editorWindow != null) {
        editorWindow.split(orientation, true, virtualFile, true);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) FileEditorManagerEx(com.intellij.openapi.fileEditor.ex.FileEditorManagerEx) EditorWindow(com.intellij.openapi.fileEditor.impl.EditorWindow)

Example 20 with EditorWindow

use of com.intellij.openapi.fileEditor.impl.EditorWindow in project ideavim by JetBrains.

the class WindowGroup method selectWindow.

public void selectWindow(@NotNull DataContext context, int index) {
    final FileEditorManagerEx fileEditorManager = getFileEditorManager(context);
    final EditorWindow[] windows = fileEditorManager.getWindows();
    if (index - 1 < windows.length) {
        windows[index - 1].setAsCurrentWindow(true);
    }
}
Also used : FileEditorManagerEx(com.intellij.openapi.fileEditor.ex.FileEditorManagerEx) EditorWindow(com.intellij.openapi.fileEditor.impl.EditorWindow)

Aggregations

EditorWindow (com.intellij.openapi.fileEditor.impl.EditorWindow)33 FileEditorManagerEx (com.intellij.openapi.fileEditor.ex.FileEditorManagerEx)22 Project (com.intellij.openapi.project.Project)16 VirtualFile (com.intellij.openapi.vfs.VirtualFile)14 EditorWithProviderComposite (com.intellij.openapi.fileEditor.impl.EditorWithProviderComposite)5 FileEditor (com.intellij.openapi.fileEditor.FileEditor)3 EditorComposite (com.intellij.openapi.fileEditor.impl.EditorComposite)3 Pair (com.intellij.openapi.util.Pair)3 CommandProcessor (com.intellij.openapi.command.CommandProcessor)2 Document (com.intellij.openapi.editor.Document)2 FileColorManager (com.intellij.ui.FileColorManager)2 NotNull (org.jetbrains.annotations.NotNull)2 Nullable (org.jetbrains.annotations.Nullable)2 HprofEditor (com.android.tools.idea.editors.hprof.HprofEditor)1 Presentation (com.intellij.openapi.actionSystem.Presentation)1 EditorEx (com.intellij.openapi.editor.ex.EditorEx)1 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)1 TextEditor (com.intellij.openapi.fileEditor.TextEditor)1 EditorTabbedContainer (com.intellij.openapi.fileEditor.impl.EditorTabbedContainer)1 EditorsSplitters (com.intellij.openapi.fileEditor.impl.EditorsSplitters)1