Search in sources :

Example 11 with EditorWindow

use of com.intellij.openapi.fileEditor.impl.EditorWindow 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 12 with EditorWindow

use of com.intellij.openapi.fileEditor.impl.EditorWindow 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 13 with EditorWindow

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

the class FileEditorManagerTest method testWindowClosingRetainsOtherWindows.

public void testWindowClosingRetainsOtherWindows() throws Exception {
    VirtualFile file = getFile("/src/1.txt");
    assertNotNull(file);
    myManager.openFile(file, false);
    EditorWindow primaryWindow = myManager.getCurrentWindow();
    assertNotNull(primaryWindow);
    myManager.createSplitter(SwingConstants.VERTICAL, primaryWindow);
    EditorWindow secondaryWindow = myManager.getNextWindow(primaryWindow);
    assertNotNull(secondaryWindow);
    myManager.createSplitter(SwingConstants.VERTICAL, secondaryWindow);
    myManager.closeFile(file, primaryWindow);
    assertEquals(2, myManager.getWindows().length);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) EditorWindow(com.intellij.openapi.fileEditor.impl.EditorWindow)

Example 14 with EditorWindow

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

the class QuickEditHandler method closeEditor.

private void closeEditor() {
    boolean unsplit = false;
    if (mySplittedWindow != null && !mySplittedWindow.isDisposed()) {
        final EditorWithProviderComposite[] editors = mySplittedWindow.getEditors();
        if (editors.length == 1 && Comparing.equal(editors[0].getFile(), myNewVirtualFile)) {
            unsplit = true;
        }
    }
    FileEditorManager.getInstance(myProject).closeFile(myNewVirtualFile);
    if (unsplit) {
        for (EditorWindow editorWindow : mySplittedWindow.findSiblings()) {
            editorWindow.unsplit(true);
        }
    }
}
Also used : EditorWithProviderComposite(com.intellij.openapi.fileEditor.impl.EditorWithProviderComposite) EditorWindow(com.intellij.openapi.fileEditor.impl.EditorWindow)

Example 15 with EditorWindow

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

the class CustomEditorTabColorProvider method getEditorTabColor.

@Nullable
@Override
public Color getEditorTabColor(@NotNull Project project, @NotNull VirtualFile virtualFile) {
    final FileEditorManagerEx fileEditorManagerEx = FileEditorManagerEx.getInstanceEx(project);
    FileColorManager fileColorManager = FileColorManager.getInstance(project);
    HighlighterSettingsConfig highlighterSettingsConfig = HighlighterSettingsConfig.getInstance();
    if (highlighterSettingsConfig.isBackgroundColorUsed()) {
        EditorWindow activeWindow = fileEditorManagerEx.getCurrentWindow();
        if (activeWindow != null) {
            final EditorWithProviderComposite selectedEditor = activeWindow.getSelectedEditor();
            if (selectedEditor != null && selectedEditor.getFile() != null && selectedEditor.getFile().equals(virtualFile)) {
                return highlighterSettingsConfig.getBackgroundColor();
            }
        }
    }
    return fileColorManager.getFileColor(virtualFile);
}
Also used : EditorWithProviderComposite(com.intellij.openapi.fileEditor.impl.EditorWithProviderComposite) FileColorManager(com.intellij.ui.FileColorManager) FileEditorManagerEx(com.intellij.openapi.fileEditor.ex.FileEditorManagerEx) EditorWindow(com.intellij.openapi.fileEditor.impl.EditorWindow) Nullable(org.jetbrains.annotations.Nullable)

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