Search in sources :

Example 16 with FileEditorManagerEx

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

the class CloseAllEditorsButActiveAction method update.

public void update(AnActionEvent event) {
    Presentation presentation = event.getPresentation();
    Project project = event.getData(CommonDataKeys.PROJECT);
    if (project == null) {
        presentation.setEnabled(false);
        return;
    }
    FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project);
    VirtualFile selectedFile;
    final EditorWindow window = event.getData(EditorWindow.DATA_KEY);
    if (window != null) {
        presentation.setEnabled(window.getFiles().length > 1);
        return;
    } else {
        if (fileEditorManager.getSelectedFiles().length == 0) {
            presentation.setEnabled(false);
            return;
        }
        selectedFile = fileEditorManager.getSelectedFiles()[0];
    }
    VirtualFile[] siblings = fileEditorManager.getSiblings(selectedFile);
    presentation.setEnabled(siblings.length > 1);
}
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 17 with FileEditorManagerEx

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

the class CloseEditorAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final Project project = e.getData(CommonDataKeys.PROJECT);
    FileEditorManagerEx editorManager = getEditorManager(project);
    EditorWindow window = e.getData(EditorWindow.DATA_KEY);
    VirtualFile file = null;
    if (window == null) {
        window = editorManager.getCurrentWindow();
        if (window != null) {
            file = window.getSelectedFile();
        }
    } else {
        file = e.getData(CommonDataKeys.VIRTUAL_FILE);
    }
    if (file != null) {
        editorManager.closeFile(file, window);
    }
}
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 18 with FileEditorManagerEx

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

the class InfoAndProgressPanel method getAnchor.

@NotNull
private static Component getAnchor(@NotNull JRootPane pane) {
    Component tabWrapper = UIUtil.findComponentOfType(pane, TabbedPaneWrapper.TabWrapper.class);
    if (tabWrapper != null)
        return tabWrapper;
    Component splitters = UIUtil.findComponentOfType(pane, EditorsSplitters.class);
    if (splitters != null)
        return splitters;
    FileEditorManagerEx ex = FileEditorManagerEx.getInstanceEx(ProjectUtil.guessCurrentProject(pane));
    return ex == null ? pane : ex.getSplitters();
}
Also used : TabbedPaneWrapper(com.intellij.ui.TabbedPaneWrapper) FileEditorManagerEx(com.intellij.openapi.fileEditor.ex.FileEditorManagerEx) NotNull(org.jetbrains.annotations.NotNull)

Example 19 with FileEditorManagerEx

use of com.intellij.openapi.fileEditor.ex.FileEditorManagerEx 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 20 with FileEditorManagerEx

use of com.intellij.openapi.fileEditor.ex.FileEditorManagerEx 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)

Aggregations

FileEditorManagerEx (com.intellij.openapi.fileEditor.ex.FileEditorManagerEx)37 EditorWindow (com.intellij.openapi.fileEditor.impl.EditorWindow)19 Project (com.intellij.openapi.project.Project)18 VirtualFile (com.intellij.openapi.vfs.VirtualFile)16 FileEditor (com.intellij.openapi.fileEditor.FileEditor)5 CommandProcessor (com.intellij.openapi.command.CommandProcessor)4 ToolWindowManager (com.intellij.openapi.wm.ToolWindowManager)3 NotNull (org.jetbrains.annotations.NotNull)3 Presentation (com.intellij.openapi.actionSystem.Presentation)2 Document (com.intellij.openapi.editor.Document)2 Editor (com.intellij.openapi.editor.Editor)2 TextEditor (com.intellij.openapi.fileEditor.TextEditor)2 Pair (com.intellij.openapi.util.Pair)2 EditorBoundHighlightingPass (com.intellij.codeHighlighting.EditorBoundHighlightingPass)1 HighlightingPass (com.intellij.codeHighlighting.HighlightingPass)1 TextEditorHighlightingPass (com.intellij.codeHighlighting.TextEditorHighlightingPass)1 AllIcons (com.intellij.icons.AllIcons)1 GeneralSettings (com.intellij.ide.GeneralSettings)1 IdeEventQueue (com.intellij.ide.IdeEventQueue)1 CloseAction (com.intellij.ide.actions.CloseAction)1