Search in sources :

Example 26 with TabInfo

use of com.intellij.ui.tabs.TabInfo in project intellij-community by JetBrains.

the class RunnerContentUi method doSaveUiState.

private void doSaveUiState() {
    if (isStateBeingRestored())
        return;
    for (TabInfo each : myTabs.getTabs()) {
        GridImpl eachGrid = getGridFor(each);
        eachGrid.saveUiState();
    }
    for (RunnerContentUi child : myChildren) {
        child.doSaveUiState();
    }
}
Also used : TabInfo(com.intellij.ui.tabs.TabInfo)

Example 27 with TabInfo

use of com.intellij.ui.tabs.TabInfo 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 28 with TabInfo

use of com.intellij.ui.tabs.TabInfo in project intellij-community by JetBrains.

the class RunnerContentUi method select.

@Override
public ActionCallback select(@NotNull final Content content, final boolean requestFocus) {
    final GridImpl grid = (GridImpl) findGridFor(content);
    if (grid == null)
        return ActionCallback.DONE;
    final TabInfo info = myTabs.findInfo(grid);
    if (info == null)
        return ActionCallback.DONE;
    final ActionCallback result = new ActionCallback();
    myTabs.select(info, false).doWhenDone(() -> grid.select(content, requestFocus).notifyWhenDone(result));
    return result;
}
Also used : TabInfo(com.intellij.ui.tabs.TabInfo)

Example 29 with TabInfo

use of com.intellij.ui.tabs.TabInfo in project intellij-community by JetBrains.

the class RunnerContentUi method processDropOver.

@Override
public Image processDropOver(@NotNull DockableContent dockable, RelativePoint dropTarget) {
    JBTabs current = getTabsAt(dockable, dropTarget);
    if (myCurrentOver != null && myCurrentOver != current) {
        resetDropOver(dockable);
    }
    if (myCurrentOver == null && current != null) {
        myCurrentOver = current;
        Presentation presentation = dockable.getPresentation();
        myCurrentOverInfo = new TabInfo(new JLabel("")).setText(presentation.getText()).setIcon(presentation.getIcon());
        myCurrentOverImg = myCurrentOver.startDropOver(myCurrentOverInfo, dropTarget);
    }
    if (myCurrentOver != null) {
        myCurrentOver.processDropOver(myCurrentOverInfo, dropTarget);
    }
    if (myCurrentPainter == null) {
        myCurrentPainter = new MyDropAreaPainter();
        IdeGlassPaneUtil.find(myComponent).addPainter(myComponent, myCurrentPainter, this);
    }
    myCurrentPainter.processDropOver(this, dockable, dropTarget);
    return myCurrentOverImg;
}
Also used : JBTabs(com.intellij.ui.tabs.JBTabs) TabInfo(com.intellij.ui.tabs.TabInfo)

Example 30 with TabInfo

use of com.intellij.ui.tabs.TabInfo in project intellij-community by JetBrains.

the class RunnerContentUi method processBounce.

public void processBounce(Content content, final boolean activate) {
    final GridImpl grid = getGridFor(content, false);
    if (grid == null)
        return;
    final GridCellImpl cell = grid.findCell(content);
    if (cell == null)
        return;
    final TabInfo tab = myTabs.findInfo(grid);
    if (tab == null)
        return;
    if (getSelectedGrid() != grid) {
        tab.setAlertIcon(content.getAlertIcon());
        if (activate) {
            tab.fireAlert();
        } else {
            tab.stopAlerting();
        }
    } else {
        grid.processAlert(content, activate);
    }
}
Also used : TabInfo(com.intellij.ui.tabs.TabInfo)

Aggregations

TabInfo (com.intellij.ui.tabs.TabInfo)41 TabLabel (com.intellij.ui.tabs.impl.TabLabel)6 RelativePoint (com.intellij.ui.awt.RelativePoint)4 JBTabsImpl (com.intellij.ui.tabs.impl.JBTabsImpl)4 Content (com.intellij.ui.content.Content)3 JBTabs (com.intellij.ui.tabs.JBTabs)3 TabsListener (com.intellij.ui.tabs.TabsListener)3 NonOpaquePanel (com.intellij.ui.components.panels.NonOpaquePanel)2 ContentManager (com.intellij.ui.content.ContentManager)2 PyDebugProcess (com.jetbrains.python.debugger.PyDebugProcess)2 ArrayList (java.util.ArrayList)2 EmptyBorder (javax.swing.border.EmptyBorder)2 Nullable (org.jetbrains.annotations.Nullable)2 BuckSettingsProvider (com.facebook.buck.intellij.ideabuck.config.BuckSettingsProvider)1 RunnerLayoutUi (com.intellij.execution.ui.RunnerLayoutUi)1 ActionGroup (com.intellij.openapi.actionSystem.ActionGroup)1 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)1 Presentation (com.intellij.openapi.actionSystem.Presentation)1 Editor (com.intellij.openapi.editor.Editor)1 FileDocumentManager (com.intellij.openapi.fileEditor.FileDocumentManager)1