Search in sources :

Example 26 with EditorWindow

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

the class CloseEditorsActionBase method update.

public void update(final AnActionEvent event) {
    final Presentation presentation = event.getPresentation();
    final DataContext dataContext = event.getDataContext();
    final EditorWindow editorWindow = EditorWindow.DATA_KEY.getData(dataContext);
    final boolean inSplitter = editorWindow != null && editorWindow.inSplitter();
    presentation.setText(getPresentationText(inSplitter));
    final Project project = event.getData(CommonDataKeys.PROJECT);
    boolean enabled = (project != null && isActionEnabled(project, event));
    if (ActionPlaces.isPopupPlace(event.getPlace())) {
        presentation.setVisible(enabled);
    } else {
        presentation.setEnabled(enabled);
    }
}
Also used : Project(com.intellij.openapi.project.Project) EditorWindow(com.intellij.openapi.fileEditor.impl.EditorWindow)

Example 27 with EditorWindow

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

the class CloseEditorsActionBase method getFilesToClose.

protected ArrayList<Pair<EditorComposite, EditorWindow>> getFilesToClose(final AnActionEvent event) {
    final ArrayList<Pair<EditorComposite, EditorWindow>> res = new ArrayList<>();
    final DataContext dataContext = event.getDataContext();
    final Project project = event.getData(CommonDataKeys.PROJECT);
    final FileEditorManagerEx editorManager = FileEditorManagerEx.getInstanceEx(project);
    final EditorWindow editorWindow = EditorWindow.DATA_KEY.getData(dataContext);
    final EditorWindow[] windows;
    if (editorWindow != null) {
        windows = new EditorWindow[] { editorWindow };
    } else {
        windows = editorManager.getWindows();
    }
    final FileStatusManager fileStatusManager = FileStatusManager.getInstance(project);
    if (fileStatusManager != null) {
        for (int i = 0; i != windows.length; ++i) {
            final EditorWindow window = windows[i];
            final EditorComposite[] editors = window.getEditors();
            for (final EditorComposite editor : editors) {
                if (isFileToClose(editor, window)) {
                    res.add(Pair.create(editor, window));
                }
            }
        }
    }
    return res;
}
Also used : Project(com.intellij.openapi.project.Project) ArrayList(java.util.ArrayList) FileEditorManagerEx(com.intellij.openapi.fileEditor.ex.FileEditorManagerEx) EditorComposite(com.intellij.openapi.fileEditor.impl.EditorComposite) Pair(com.intellij.openapi.util.Pair) EditorWindow(com.intellij.openapi.fileEditor.impl.EditorWindow) FileStatusManager(com.intellij.openapi.vcs.FileStatusManager)

Example 28 with EditorWindow

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

the class CloseAllEditorsAction method update.

public void update(AnActionEvent event) {
    Presentation presentation = event.getPresentation();
    final EditorWindow editorWindow = event.getData(EditorWindow.DATA_KEY);
    if (editorWindow != null && editorWindow.inSplitter()) {
        presentation.setText(IdeBundle.message("action.close.all.editors.in.tab.group"));
    } else {
        presentation.setText(IdeBundle.message("action.close.all.editors"));
    }
    Project project = event.getData(CommonDataKeys.PROJECT);
    if (project == null) {
        presentation.setEnabled(false);
        return;
    }
    presentation.setEnabled(FileEditorManager.getInstance(project).getSelectedFiles().length > 0);
}
Also used : Project(com.intellij.openapi.project.Project) Presentation(com.intellij.openapi.actionSystem.Presentation) EditorWindow(com.intellij.openapi.fileEditor.impl.EditorWindow)

Example 29 with EditorWindow

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

the class CloseAllEditorsButActiveAction method actionPerformed.

public void actionPerformed(AnActionEvent e) {
    Project project = e.getData(CommonDataKeys.PROJECT);
    FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project);
    VirtualFile selectedFile;
    final EditorWindow window = e.getData(EditorWindow.DATA_KEY);
    if (window != null) {
        window.closeAllExcept(e.getData(CommonDataKeys.VIRTUAL_FILE));
        return;
    }
    selectedFile = fileEditorManager.getSelectedFiles()[0];
    final VirtualFile[] siblings = fileEditorManager.getSiblings(selectedFile);
    for (final VirtualFile sibling : siblings) {
        if (!Comparing.equal(selectedFile, sibling)) {
            fileEditorManager.closeFile(sibling);
        }
    }
}
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 30 with EditorWindow

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

the class PinActiveTabAction method getHandler.

protected Handler getHandler(@NotNull AnActionEvent e) {
    Project project = e.getProject();
    EditorWindow currentWindow = e.getData(EditorWindow.DATA_KEY);
    Content content = currentWindow != null ? null : getContentFromEvent(e);
    if (content != null && content.isPinnable()) {
        return createHandler(content);
    }
    final EditorWindow window = currentWindow != null ? currentWindow : project != null ? FileEditorManagerEx.getInstanceEx(project).getCurrentWindow() : null;
    VirtualFile selectedFile = window == null ? null : getFileFromEvent(e, window);
    if (selectedFile != null) {
        return createHandler(window, selectedFile);
    }
    return null;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) Content(com.intellij.ui.content.Content) 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