Search in sources :

Example 1 with DockManager

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

the class EditorsContextTest method testDockableContainer.

public void testDockableContainer() throws Exception {
    VirtualFile file = getFile("/foo.txt");
    myManager.openFile(file, false);
    DockManager dockManager = DockManager.getInstance(getProject());
    assertEquals(1, dockManager.getContainers().size());
    myManager.initDockableContentFactory();
    myManager.openFileInNewWindow(file);
    assertEquals(2, dockManager.getContainers().size());
    Element context = new Element("context");
    WorkingContextManager contextManager = WorkingContextManager.getInstance(getProject());
    contextManager.saveContext(context);
    assertEquals(2, context.getChild("editors").getChildren().size());
    assertEquals(2, EditorFactory.getInstance().getAllEditors().length);
    contextManager.clearContext();
    assertEquals(1, dockManager.getContainers().size());
    assertEquals(0, EditorFactory.getInstance().getAllEditors().length);
//contextManager.loadContext(context);
//assertEquals(2, dockManager.getContainers().size());
//Editor[] editors = EditorFactory.getInstance().getAllEditors();
//assertEquals(2, editors.length);
//
//contextManager.clearContext();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) DockManager(com.intellij.ui.docking.DockManager) Element(org.jdom.Element)

Example 2 with DockManager

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

the class RunnerContentUi method initUi.

public void initUi() {
    if (myTabs != null)
        return;
    myTabs = (JBRunnerTabs) new JBRunnerTabs(myProject, myActionManager, myFocusManager, this).setDataProvider(new DataProvider() {

        @Override
        public Object getData(@NonNls final String dataId) {
            if (ViewContext.CONTENT_KEY.is(dataId)) {
                TabInfo info = myTabs.getTargetInfo();
                if (info != null) {
                    return getGridFor(info).getData(dataId);
                }
            } else if (ViewContext.CONTEXT_KEY.is(dataId)) {
                return RunnerContentUi.this;
            }
            return null;
        }
    }).setTabLabelActionsAutoHide(false).setInnerInsets(JBUI.emptyInsets()).setToDrawBorderIfTabsHidden(false).setTabDraggingEnabled(isMoveToGridActionEnabled()).setUiDecorator(null).getJBTabs();
    rebuildTabPopup();
    myTabs.getPresentation().setPaintBorder(0, 0, 0, 0).setPaintFocus(false).setRequestFocusOnLastFocusedComponent(true);
    myTabs.getComponent().setBackground(myToolbar.getBackground());
    myTabs.getComponent().setBorder(new EmptyBorder(0, 1, 0, 0));
    final NonOpaquePanel wrappper = new MyComponent(new BorderLayout(0, 0));
    wrappper.add(myToolbar, BorderLayout.WEST);
    wrappper.add(myTabs.getComponent(), BorderLayout.CENTER);
    wrappper.setBorder(new EmptyBorder(-1, 0, 0, 0));
    myComponent = wrappper;
    myTabs.addListener(new TabsListener.Adapter() {

        @Override
        public void beforeSelectionChanged(TabInfo oldSelection, TabInfo newSelection) {
            if (oldSelection != null && !isStateBeingRestored()) {
                final GridImpl grid = getGridFor(oldSelection);
                if (grid != null && getTabFor(grid) != null) {
                    grid.saveUiState();
                }
            }
        }

        @Override
        public void tabsMoved() {
            saveUiState();
        }

        @Override
        public void selectionChanged(final TabInfo oldSelection, final TabInfo newSelection) {
            if (!myTabs.getComponent().isShowing())
                return;
            if (newSelection != null) {
                newSelection.stopAlerting();
                getGridFor(newSelection).processAddToUi(false);
            }
            if (oldSelection != null) {
                getGridFor(oldSelection).processRemoveFromUi();
            }
        }
    });
    myTabs.addTabMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(@NotNull MouseEvent e) {
            if (UIUtil.isCloseClick(e)) {
                final TabInfo tabInfo = myTabs.findInfo(e);
                final GridImpl grid = tabInfo == null ? null : getGridFor(tabInfo);
                final Content[] contents = grid != null ? CONTENT_KEY.getData(grid) : null;
                if (contents == null)
                    return;
                // see GridCellImpl.closeOrMinimize as well
                if (CloseViewAction.isEnabled(contents)) {
                    CloseViewAction.perform(RunnerContentUi.this, contents[0]);
                } else if (MinimizeViewAction.isEnabled(RunnerContentUi.this, contents, ViewContext.TAB_TOOLBAR_PLACE)) {
                    grid.getCellFor(contents[0]).minimize(contents[0]);
                }
            }
        }
    });
    if (myOriginal != null) {
        final ContentManager manager = ContentFactory.SERVICE.getInstance().createContentManager(this, false, myProject);
        Disposer.register((Disposable) myRunnerUi, manager);
        manager.getComponent();
    } else {
        final DockManager dockManager = DockManager.getInstance(myProject);
        if (dockManager != null) {
            //default project
            dockManager.register(this);
        }
    }
}
Also used : MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) NonOpaquePanel(com.intellij.ui.components.panels.NonOpaquePanel) TabsListener(com.intellij.ui.tabs.TabsListener) DockManager(com.intellij.ui.docking.DockManager) TabInfo(com.intellij.ui.tabs.TabInfo) EmptyBorder(javax.swing.border.EmptyBorder)

Example 3 with DockManager

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

the class FileEditorManagerTestCase method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    DockManager dockManager = DockManager.getInstance(getProject());
    myOldDockContainers = dockManager.getContainers();
    myManager = new FileEditorManagerImpl(getProject(), dockManager);
    myOldManager = ((ComponentManagerImpl) getProject()).registerComponentInstance(FileEditorManager.class, myManager);
    ((FileEditorProviderManagerImpl) FileEditorProviderManager.getInstance()).clearSelectedProviders();
}
Also used : FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) DockManager(com.intellij.ui.docking.DockManager) FileEditorManagerImpl(com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl) FileEditorProviderManagerImpl(com.intellij.openapi.fileEditor.impl.FileEditorProviderManagerImpl)

Aggregations

DockManager (com.intellij.ui.docking.DockManager)3 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)1 FileEditorManagerImpl (com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl)1 FileEditorProviderManagerImpl (com.intellij.openapi.fileEditor.impl.FileEditorProviderManagerImpl)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 NonOpaquePanel (com.intellij.ui.components.panels.NonOpaquePanel)1 TabInfo (com.intellij.ui.tabs.TabInfo)1 TabsListener (com.intellij.ui.tabs.TabsListener)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 EmptyBorder (javax.swing.border.EmptyBorder)1 Element (org.jdom.Element)1