void () { if (myTabs != null) return; myTabs = new JBRunnerTabs(myProject, this); myTabs.getComponent().setOpaque(false); myTabs.setDataProvider(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 this; } return null; }); myTabs.getPresentation() .setTabLabelActionsAutoHide(false).setInnerInsets(JBInsets.emptyInsets()) .setToDrawBorderIfTabsHidden(false).setTabDraggingEnabled(isMoveToGridActionEnabled()).setUiDecorator(null); rebuildTabPopup(); myTabs.getPresentation().setPaintFocus(false).setRequestFocusOnLastFocusedComponent(true); NonOpaquePanel wrapper = new MyComponent(); wrapper.add(myToolbar, BorderLayout.WEST); wrapper.add(myTabs.getComponent(), BorderLayout.CENTER); myComponent = wrapper; myTabs.addListener(new TabsListener() { @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.getInstance().createContentManager(this, false, myProject); Disposer.register((Disposable)myRunnerUi, manager); manager.getComponent(); } else { DockManager dockManager = myProject.isDefault() ? null : DockManager.getInstance(myProject); if (dockManager != null) { dockManager.register(this, this); } } if (UIExperiment.isNewDebuggerUIEnabled()) { MouseAdapter adapter = new MouseAdapter() { private Point myPressPoint = null; @Override public void mousePressed(MouseEvent e) { InternalDecoratorImpl topLevelDecorator = InternalDecoratorImpl.Companion.findTopLevelDecorator(myComponent); if (topLevelDecorator != null) { topLevelDecorator.activate(ToolWindowEventSource.ToolWindowHeader); } myPressPoint = e.getPoint(); } @Override public void mouseClicked(MouseEvent e) { if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2) { InternalDecoratorImpl topLevelDecorator = InternalDecoratorImpl.Companion.findTopLevelDecorator(myComponent); if (topLevelDecorator != null && !topLevelDecorator.isHeaderVisible()) { String id = topLevelDecorator.getToolWindowId(); ToolWindowManagerEx manager = ToolWindowManagerEx.getInstanceEx(myProject); ToolWindow window = manager.getToolWindow(id); if (window != null) { manager.setMaximized(window, !manager.isMaximized(window)); } } } } @Override public void mouseDragged(MouseEvent e) { InternalDecoratorImpl decorator = InternalDecoratorImpl.Companion.findTopLevelDecorator(myComponent); if (decorator == null || decorator.isHeaderVisible()) return; ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(decorator.getToolWindowId()); ToolWindowAnchor anchor = window != null ? window.getAnchor() : null; if (anchor == ToolWindowAnchor.BOTTOM && SwingUtilities.isLeftMouseButton(e) && myPressPoint != null) { ThreeComponentsSplitter splitter = ComponentUtil.getParentOfType(ThreeComponentsSplitter.class, myComponent); if (splitter != null && splitter.getOrientation() && SwingUtilities.isDescendingFrom(getComponent(), splitter.getLastComponent())) { int size = splitter.getLastSize(); int yDiff = myPressPoint.y - e.getPoint().y; splitter.setLastSize(size + yDiff); } } } @Override public void mouseReleased(MouseEvent e) { myPressPoint = null; } @Override public void mouseEntered(MouseEvent e) { InternalDecoratorImpl decorator = InternalDecoratorImpl.Companion.findTopLevelDecorator(myComponent); if (decorator == null || decorator.isHeaderVisible()) { e.getComponent().setCursor(Cursor.getDefaultCursor()); return; } e.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR)); } @Override public void mouseExited(MouseEvent e) { e.getComponent().setCursor(Cursor.getDefaultCursor()); } }; wrapper.addMouseListener(adapter); myTabs.getComponent().addMouseListener(adapter); wrapper.addMouseMotionListener(adapter); myTabs.getComponent().addMouseMotionListener(adapter); } updateRestoreLayoutActionVisibility(); }