Search in sources :

Example 1 with DockContainer

use of com.intellij.ui.docking.DockContainer in project intellij-community by JetBrains.

the class FileEditorManagerImpl method getAllSplitters.

@NotNull
public Set<EditorsSplitters> getAllSplitters() {
    Set<EditorsSplitters> all = new LinkedHashSet<>();
    all.add(getMainSplitters());
    Set<DockContainer> dockContainers = myDockManager.getContainers();
    for (DockContainer each : dockContainers) {
        if (each instanceof DockableEditorTabbedContainer) {
            all.add(((DockableEditorTabbedContainer) each).getSplitters());
        }
    }
    return Collections.unmodifiableSet(all);
}
Also used : DockContainer(com.intellij.ui.docking.DockContainer) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with DockContainer

use of com.intellij.ui.docking.DockContainer in project intellij-community by JetBrains.

the class FileEditorManagerImpl method getActiveSplittersAsync.

@NotNull
private AsyncResult<EditorsSplitters> getActiveSplittersAsync() {
    final AsyncResult<EditorsSplitters> result = new AsyncResult<>();
    final IdeFocusManager fm = IdeFocusManager.getInstance(myProject);
    fm.doWhenFocusSettlesDown(() -> {
        if (myProject.isDisposed()) {
            result.setRejected();
            return;
        }
        Component focusOwner = fm.getFocusOwner();
        DockContainer container = myDockManager.getContainerFor(focusOwner);
        if (container instanceof DockableEditorTabbedContainer) {
            result.setDone(((DockableEditorTabbedContainer) container).getSplitters());
        } else {
            result.setDone(getMainSplitters());
        }
    });
    return result;
}
Also used : DockContainer(com.intellij.ui.docking.DockContainer) IdeFocusManager(com.intellij.openapi.wm.IdeFocusManager) PersistentStateComponent(com.intellij.openapi.components.PersistentStateComponent) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with DockContainer

use of com.intellij.ui.docking.DockContainer 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 DockContainer

use of com.intellij.ui.docking.DockContainer in project intellij-community by JetBrains.

the class FileEditorManagerTestCase method tearDown.

@Override
protected void tearDown() throws Exception {
    try {
        for (DockContainer container : DockManager.getInstance(getProject()).getContainers()) {
            if (!myOldDockContainers.contains(container)) {
                Disposer.dispose(container);
            }
        }
        myOldDockContainers = null;
        ((ComponentManagerImpl) getProject()).registerComponentInstance(FileEditorManager.class, myOldManager);
        myManager.closeAllFiles();
        ((FileEditorProviderManagerImpl) FileEditorProviderManager.getInstance()).clearSelectedProviders();
    } finally {
        myManager = null;
        myOldManager = null;
        super.tearDown();
    }
}
Also used : DockContainer(com.intellij.ui.docking.DockContainer) ComponentManagerImpl(com.intellij.openapi.components.impl.ComponentManagerImpl) FileEditorProviderManagerImpl(com.intellij.openapi.fileEditor.impl.FileEditorProviderManagerImpl)

Example 5 with DockContainer

use of com.intellij.ui.docking.DockContainer in project intellij-community by JetBrains.

the class FileEditorManagerImpl method getActiveSplittersSync.

private EditorsSplitters getActiveSplittersSync() {
    assertDispatchThread();
    final IdeFocusManager fm = IdeFocusManager.getInstance(myProject);
    Component focusOwner = fm.getFocusOwner();
    if (focusOwner == null) {
        focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
    }
    if (focusOwner == null) {
        focusOwner = fm.getLastFocusedFor(fm.getLastFocusedFrame());
    }
    DockContainer container = myDockManager.getContainerFor(focusOwner);
    if (container == null) {
        focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
        container = myDockManager.getContainerFor(focusOwner);
    }
    if (container instanceof DockableEditorTabbedContainer) {
        return ((DockableEditorTabbedContainer) container).getSplitters();
    }
    return getMainSplitters();
}
Also used : DockContainer(com.intellij.ui.docking.DockContainer) IdeFocusManager(com.intellij.openapi.wm.IdeFocusManager) PersistentStateComponent(com.intellij.openapi.components.PersistentStateComponent)

Aggregations

DockContainer (com.intellij.ui.docking.DockContainer)7 PersistentStateComponent (com.intellij.openapi.components.PersistentStateComponent)2 DockableEditorTabbedContainer (com.intellij.openapi.fileEditor.impl.DockableEditorTabbedContainer)2 IdeFocusManager (com.intellij.openapi.wm.IdeFocusManager)2 NotNull (org.jetbrains.annotations.NotNull)2 ComponentManagerImpl (com.intellij.openapi.components.impl.ComponentManagerImpl)1 EditorWithProviderComposite (com.intellij.openapi.fileEditor.impl.EditorWithProviderComposite)1 EditorsSplitters (com.intellij.openapi.fileEditor.impl.EditorsSplitters)1 FileEditorProviderManagerImpl (com.intellij.openapi.fileEditor.impl.FileEditorProviderManagerImpl)1 Nullable (org.jetbrains.annotations.Nullable)1