Search in sources :

Example 1 with EditorWithProviderComposite

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

the class WindowGroup method getEditorWindowRectangle.

@Nullable
private static Rectangle getEditorWindowRectangle(@NotNull EditorWindow window) {
    final EditorWithProviderComposite editor = window.getSelectedEditor();
    if (editor != null) {
        final Point point = editor.getComponent().getLocationOnScreen();
        final Dimension dimension = editor.getComponent().getSize();
        return new Rectangle(point, dimension);
    }
    return null;
}
Also used : EditorWithProviderComposite(com.intellij.openapi.fileEditor.impl.EditorWithProviderComposite) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with EditorWithProviderComposite

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

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

the class StatusBarUtil method getCurrentFileEditor.

/**
   * Finds the current file editor.
   */
@Nullable
public static FileEditor getCurrentFileEditor(@NotNull Project project, @Nullable StatusBar statusBar) {
    if (statusBar == null) {
        return null;
    }
    DockContainer c = DockManager.getInstance(project).getContainerFor(statusBar.getComponent());
    EditorsSplitters splitters = null;
    if (c instanceof DockableEditorTabbedContainer) {
        splitters = ((DockableEditorTabbedContainer) c).getSplitters();
    }
    if (splitters != null && splitters.getCurrentWindow() != null) {
        EditorWithProviderComposite editor = splitters.getCurrentWindow().getSelectedEditor();
        if (editor != null) {
            return editor.getSelectedEditorWithProvider().getFirst();
        }
    }
    return null;
}
Also used : EditorWithProviderComposite(com.intellij.openapi.fileEditor.impl.EditorWithProviderComposite) DockableEditorTabbedContainer(com.intellij.openapi.fileEditor.impl.DockableEditorTabbedContainer) DockContainer(com.intellij.ui.docking.DockContainer) EditorsSplitters(com.intellij.openapi.fileEditor.impl.EditorsSplitters) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with EditorWithProviderComposite

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

the class CloseAllUnpinnedEditorsAction method isActionEnabled.

@Override
protected boolean isActionEnabled(final Project project, final AnActionEvent event) {
    final ArrayList<Pair<EditorComposite, EditorWindow>> filesToClose = getFilesToClose(event);
    if (filesToClose.isEmpty())
        return false;
    Set<EditorWindow> checked = new HashSet<>();
    boolean hasPinned = false;
    boolean hasUnpinned = false;
    for (Pair<EditorComposite, EditorWindow> pair : filesToClose) {
        final EditorWindow window = pair.second;
        if (checked.add(window)) {
            for (EditorWithProviderComposite e : window.getEditors()) {
                if (e.isPinned()) {
                    hasPinned = true;
                } else {
                    hasUnpinned = true;
                }
            }
            if (/*hasPinned && */
            hasUnpinned) {
                return true;
            }
        }
    }
    return false;
}
Also used : EditorWithProviderComposite(com.intellij.openapi.fileEditor.impl.EditorWithProviderComposite) EditorComposite(com.intellij.openapi.fileEditor.impl.EditorComposite) Pair(com.intellij.openapi.util.Pair) HashSet(com.intellij.util.containers.HashSet) EditorWindow(com.intellij.openapi.fileEditor.impl.EditorWindow)

Example 5 with EditorWithProviderComposite

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

the class FileDropHandler method findEditorWindow.

@Nullable
private EditorWindow findEditorWindow(Project project) {
    final Document document = myEditor.getDocument();
    final VirtualFile file = FileDocumentManager.getInstance().getFile(document);
    if (file != null) {
        final FileEditorManagerEx fileEditorManager = (FileEditorManagerEx) FileEditorManager.getInstance(project);
        final EditorWindow[] windows = fileEditorManager.getWindows();
        for (EditorWindow window : windows) {
            final EditorWithProviderComposite composite = window.findFileComposite(file);
            if (composite == null) {
                continue;
            }
            for (FileEditor editor : composite.getEditors()) {
                if (editor instanceof TextEditor && ((TextEditor) editor).getEditor() == myEditor) {
                    return window;
                }
            }
        }
    }
    return null;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) EditorWithProviderComposite(com.intellij.openapi.fileEditor.impl.EditorWithProviderComposite) Document(com.intellij.openapi.editor.Document) FileEditorManagerEx(com.intellij.openapi.fileEditor.ex.FileEditorManagerEx) EditorWindow(com.intellij.openapi.fileEditor.impl.EditorWindow) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

EditorWithProviderComposite (com.intellij.openapi.fileEditor.impl.EditorWithProviderComposite)6 EditorWindow (com.intellij.openapi.fileEditor.impl.EditorWindow)4 Nullable (org.jetbrains.annotations.Nullable)3 EditorsSplitters (com.intellij.openapi.fileEditor.impl.EditorsSplitters)2 HprofEditor (com.android.tools.idea.editors.hprof.HprofEditor)1 Document (com.intellij.openapi.editor.Document)1 FileEditor (com.intellij.openapi.fileEditor.FileEditor)1 FileEditorManagerEx (com.intellij.openapi.fileEditor.ex.FileEditorManagerEx)1 DockableEditorTabbedContainer (com.intellij.openapi.fileEditor.impl.DockableEditorTabbedContainer)1 EditorComposite (com.intellij.openapi.fileEditor.impl.EditorComposite)1 FileEditorManagerImpl (com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl)1 Pair (com.intellij.openapi.util.Pair)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 DockContainer (com.intellij.ui.docking.DockContainer)1 HashSet (com.intellij.util.containers.HashSet)1 ComponentLookupException (org.fest.swing.exception.ComponentLookupException)1 NotNull (org.jetbrains.annotations.NotNull)1