private void initUi() { myComponent = new JPanel(); myTreeTabs = new JBTabsImpl(null, null, this); final Splitter splitter = new Splitter(true); final JBTabsImpl bottom = new JBTabsImpl(null, null, this); final AllocationPanel allocations = new AllocationPanel(myTreeTabs); bottom.addTab(new TabInfo(allocations).setText("Allocation")).setActions(allocations.getActions(), ActionPlaces.UNKNOWN); splitter.setFirstComponent(myTreeTabs); splitter.setSecondComponent(bottom); myComponent.setLayout(new BorderLayout()); myComponent.add(splitter, BorderLayout.CENTER); JLabel countLabel = new JLabel("Total disposable count: " + Disposer.getTree().size()); myComponent.add(countLabel, BorderLayout.SOUTH); addTree(new DisposerTree(this), "All", false); addTree(new DisposerTree(this), "Watch", true); }
@Override public void dragOutStarted(MouseEvent mouseEvent, TabInfo info) { final TabInfo previousSelection = info.getPreviousSelection(); final Image img = JBTabsImpl.getComponentImage(info); info.setHidden(true); if (previousSelection != null) { myTabs.select(previousSelection, true); } myFile = (TerminalSessionVirtualFileImpl)info.getObject(); Presentation presentation = new Presentation(info.getText()); presentation.setIcon(info.getIcon()); mySession = getDockManager() .createDragSession(mouseEvent, new EditorTabbedContainer.DockableEditor(myProject, img, myFile, presentation, info.getComponent().getPreferredSize(), false)); }
@Override public void dragOutStarted(MouseEvent mouseEvent, TabInfo info) { final JComponent component = info.getComponent(); final Content[] data = CONTENT_KEY.getData((DataProvider)component); final List<Content> contents = Arrays.asList(data); storeDefaultIndices(data); final Dimension size = info.getComponent().getSize(); final Image image = JBTabsImpl.getComponentImage(info); if (component instanceof Grid) { info.setHidden(true); } Presentation presentation = new Presentation(info.getText()); presentation.setIcon(info.getIcon()); mySession = getDockManager().createDragSession(mouseEvent, new DockableGrid(image, presentation, size, contents, 0)); }
@Override public void dragOutStarted(MouseEvent mouseEvent, TabInfo info) { final TabInfo previousSelection = info.getPreviousSelection(); final Image img = JBTabsImpl.getComponentImage(info); info.setHidden(true); if(previousSelection != null) { myTabs.select(previousSelection, true); } myFile = (TerminalSessionVirtualFileImpl) info.getObject(); Presentation presentation = new Presentation(info.getText()); presentation.setIcon(info.getIcon()); mySession = getDockManager().createDragSession(mouseEvent, new EditorTabbedContainer.DockableEditor (myProject, img, myFile, presentation, info.getComponent().getPreferredSize(), false)); }
protected void addHeaderSize(JBTabsImpl tabs, Dimension size, final int tabsCount) { Dimension header = computeHeaderPreferredSize(tabs, tabsCount); final boolean horizontal = tabs.getTabsPosition() == JBTabsPosition.top || tabs.getTabsPosition() == JBTabsPosition.bottom; if (horizontal) { size.height += header.height; size.width = Math.max(size.width, header.width); } else { size.height += Math.max(size.height, header.height); size.width += header.width; } final Insets insets = tabs.getLayoutInsets(); size.width += insets.left + insets.right + 1; size.height += insets.top + insets.bottom + 1; }
private void initUi() { myComponent = new JPanel(); myTreeTabs = new JBEditorTabs(null, ActionManager.getInstance(), null, this); final Splitter splitter = new Splitter(true); final JBTabsImpl bottom = new JBEditorTabs(null, ActionManager.getInstance(), null, this); final AllocationPanel allocations = new AllocationPanel(myTreeTabs); bottom.addTab(new TabInfo(allocations).setText("Allocation")).setActions(allocations.getActions(), ActionPlaces.UNKNOWN); splitter.setFirstComponent(myTreeTabs); splitter.setSecondComponent(bottom); myComponent.setLayout(new BorderLayout()); myComponent.add(splitter, BorderLayout.CENTER); JLabel countLabel = new JLabel("Total disposable count: " + Disposer.getTree().size()); myComponent.add(countLabel, BorderLayout.SOUTH); addTree(new DisposerTree(this), "All", false); addTree(new DisposerTree(this), "Watch", true); }
public Rectangle getMoreRect(final SingleRowPassInfo data) { int x; if (myTabs.isEditorTabs()) { x = data.layoutSize.width - data.moreRectAxisSize - 1; } else { x = data.position + (data.lastGhostVisible ? data.lastGhost.width : 0); } return new Rectangle(x, data.insets.top + JBTabsImpl.getSelectionTabVShift(), data.moreRectAxisSize - 1, myTabs.myHeaderFitSize.height - 1); }
public SingleRowPassInfo(SingleRowLayout layout, List<TabInfo> visibleInfos) { super(visibleInfos); JBTabsImpl tabs = layout.myTabs; layoutSize = tabs.getSize(); contentCount = tabs.getTabCount(); toLayout = new ArrayList<TabInfo>(); toDrop = new ArrayList<TabInfo>(); moreRectAxisSize = layout.getStrategy().getMoreRectAxisSize(); scrollOffset = layout.getScrollOffset(); }
@Override public void dragOutStarted(MouseEvent mouseEvent, TabInfo info) { final TabInfo previousSelection = info.getPreviousSelection(); final Image img = JBTabsImpl.getComponentImage(info); info.setHidden(true); if (previousSelection != null) { myTabs.select(previousSelection, true); } myFile = (VirtualFile)info.getObject(); Presentation presentation = new Presentation(info.getText()); presentation.setIcon(info.getIcon()); mySession = getDockManager().createDragSession(mouseEvent, createDockableEditor(myProject, img, myFile, presentation, myWindow)); }
@Override public void paintBorder(@NotNull Component c, @NotNull Graphics g, int x, int y, int width, int height) { if (UIUtil.isUnderAquaLookAndFeel()) { g.setColor(JBTabsImpl.MAC_AQUA_BG_COLOR); final Insets insets = getBorderInsets(c); if (insets.top > 0) { g.fillRect(x, y, width, height + insets.top); } } }
@Override public void add(@NotNull DockableContent content, RelativePoint dropTarget) { EditorWindow window = null; if (myCurrentOver != null) { final DataProvider provider = myCurrentOver.getDataProvider(); if (provider != null) { window = EditorWindow.DATA_KEY.getData(provider); } } final EditorTabbedContainer.DockableEditor dockableEditor = (EditorTabbedContainer.DockableEditor)content; VirtualFile file = dockableEditor.getFile(); if (window == null || window.isDisposed()) { window = mySplitters.getOrCreateCurrentWindow(file); } if (myCurrentOver != null) { int index = ((JBTabsImpl)myCurrentOver).getDropInfoIndex(); file.putUserData(EditorWindow.INITIAL_INDEX_KEY, index); } ((FileEditorManagerImpl)FileEditorManagerEx.getInstanceEx(myProject)).openFileImpl2(window, file, true); window.setFilePinned(file, dockableEditor.isPinned()); }
@Override public void actionPerformed(AnActionEvent e) { JBTabsImpl tabs = e.getData(JBTabsImpl.NAVIGATION_ACTIONS_KEY); if (tabs != null) { tabs.showMorePopup(null); } }
private static boolean isTabListAvailable(AnActionEvent e) { JBTabsImpl tabs = e.getData(JBTabsImpl.NAVIGATION_ACTIONS_KEY); if (tabs == null || !tabs.isEditorTabs()) { return false; } return tabs.canShowMorePopup(); }
@Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { if (UIUtil.isUnderAquaLookAndFeel()) { g.setColor(JBTabsImpl.MAC_AQUA_BG_COLOR); final Insets insets = getBorderInsets(c); if (insets.top > 0) { g.fillRect(x, y, width, height + insets.top); } } }
public JBTabsPaneImpl(@Nullable Project project, int tabPlacement, @NotNull Disposable parent) { myTabs = new JBTabsImpl(project, ActionManager.getInstance(), project == null ? null : IdeFocusManager.getInstance(project), parent); myTabs.addListener(new TabsListener.Adapter() { @Override public void selectionChanged(TabInfo oldSelection, TabInfo newSelection) { fireChanged(new ChangeEvent(myTabs)); } }).getPresentation().setPaintBorder(1, 1, 1, 1).setTabSidePaintBorder(2).setPaintFocus(false).setGhostsAlwaysVisible(true); setTabPlacement(tabPlacement); }
public SingleRowPassInfo(SingleRowLayout layout, List<TabInfo> visibleInfos) { super(visibleInfos); JBTabsImpl tabs = layout.myTabs; layoutSize = tabs.getSize(); contentCount = tabs.getTabCount(); toLayout = new ArrayList<>(); toDrop = new ArrayList<>(); moreRectAxisSize = layout.getStrategy().getMoreRectAxisSize(); scrollOffset = layout.getScrollOffset(); }
@Override public void installUI(JComponent c) { super.installUI(c); JBTabsImpl tabs = (JBTabsImpl)c; tabs.setBackground(getBackground()); tabs.setForeground(getForeground()); }
protected Dimension computeSize(JBTabsImpl tabs, Function<JComponent, Dimension> transform, int tabCount) { Dimension size = new Dimension(); for (TabInfo each : tabs.getVisibleInfos()) { final JComponent c = each.getComponent(); if (c != null) { final Dimension eachSize = transform.fun(c); size.width = Math.max(eachSize.width, size.width); size.height = Math.max(eachSize.height, size.height); } } addHeaderSize(tabs, size, tabCount); return size; }
protected Dimension computeHeaderPreferredSize(JBTabsImpl tabs, int tabsCount) { final Iterator<TabInfo> infos = tabs.myInfo2Label.keySet().iterator(); Dimension size = new Dimension(); int currentTab = 0; final boolean horizontal = tabs.getTabsPosition() == JBTabsPosition.top || tabs.getTabsPosition() == JBTabsPosition.bottom; while (infos.hasNext()) { final boolean canGrow = currentTab < tabsCount; TabInfo eachInfo = infos.next(); final TabLabel eachLabel = tabs.myInfo2Label.get(eachInfo); final Dimension eachPrefSize = eachLabel.getPreferredSize(); if (horizontal) { if (canGrow) { size.width += eachPrefSize.width; } size.height = Math.max(size.height, eachPrefSize.height); } else { size.width = Math.max(size.width, eachPrefSize.width); if (canGrow) { size.height += eachPrefSize.height; } } currentTab++; } if (horizontal) { size.height += tabs.getTabsBorder().getTabBorderSize(); } else { size.width += tabs.getTabsBorder().getTabBorderSize(); } return size; }
protected void doPaintInactive(JBTabsImpl t, Graphics2D g2d, boolean leftGhostExists, TabLabel label, Rectangle effectiveBounds, boolean rightGhostExists, int row, int column) { Insets insets = t.getTabsBorder().getEffectiveBorder(); int _x = effectiveBounds.x + insets.left; int _y = effectiveBounds.y + insets.top; int _width = effectiveBounds.width - insets.left - insets.right + (t.getTabsPosition() == JBTabsPosition.right ? 1 : 0); int _height = effectiveBounds.height - insets.top - insets.bottom; if ((!t.isSingleRow() /* for multiline */) || (t.isSingleRow() && t.isHorizontalTabs())) { if (t.isSingleRow() && t.getPosition() == JBTabsPosition.bottom) { _y += t.getActiveTabUnderlineHeight(); } else { if (t.isSingleRow()) { _height -= t.getActiveTabUnderlineHeight(); } else { TabInfo info = label.getInfo(); if (((TableLayout)t.getEffectiveLayout()).isLastRow(info)) { _height -= t.getActiveTabUnderlineHeight(); } } } } final boolean vertical = t.getTabsPosition() == JBTabsPosition.left || t.getTabsPosition() == JBTabsPosition.right; final Color tabColor = label.getInfo().getTabColor(); doPaintInactive(g2d, effectiveBounds, _x, _y, _width, _height, tabColor, row, column, vertical); }
protected void doPaintAdditionalBackgroundIfFirstOffsetSet(JBTabsImpl tabs, Graphics2D g2d, Rectangle clip) { if (tabs.getTabsPosition() == JBTabsPosition.top && tabs.isSingleRow() && tabs.getFirstTabOffset() > 0) { int maxOffset = 0; int maxLength = 0; for (int i = tabs.getVisibleInfos().size() - 1; i >= 0; i--) { TabInfo visibleInfo = tabs.getVisibleInfos().get(i); TabLabel tabLabel = tabs.myInfo2Label.get(visibleInfo); Rectangle r = tabLabel.getBounds(); if (r.width == 0 || r.height == 0) continue; maxOffset = r.x + r.width; maxLength = r.height; break; } maxOffset++; g2d.setPaint(UIUtil.getPanelBackground()); if (tabs.getFirstTabOffset() > 0) { g2d.fillRect(clip.x, clip.y, clip.x + JBUI.scale(tabs.getFirstTabOffset() - 1), clip.y + maxLength - tabs.getActiveTabUnderlineHeight()); } g2d.fillRect(clip.x + maxOffset, clip.y, clip.width - maxOffset, clip.y + maxLength - tabs.getActiveTabUnderlineHeight()); g2d.setPaint(new JBColor(Gray._181, UIUtil.getPanelBackground())); g2d.drawLine(clip.x + maxOffset, clip.y + maxLength - tabs.getActiveTabUnderlineHeight(), clip.x + clip.width, clip.y + maxLength - tabs.getActiveTabUnderlineHeight()); g2d.setPaint(UIUtil.getPanelBackground()); g2d.drawLine(clip.x, clip.y + maxLength, clip.width, clip.y + maxLength); } }
public void paintChildren(JBTabsImpl tabs, Graphics g) { final GraphicsConfig config = new GraphicsConfig(g); config.setAntialiasing(true); paintSelectionAndBorder(tabs, (Graphics2D)g); config.restore(); final TabLabel selected = tabs.getSelectedLabel(); if (selected != null) { selected.paintImage(g); } tabs.getSingleRowLayoutInternal().myMoreIcon.paintIcon(tabs, g); }
protected ShapeInfo _computeSelectedLabelShape(JBTabsImpl tabs) { final ShapeInfo shape = new ShapeInfo(); shape.path = tabs.getEffectiveLayout().createShapeTransform(tabs.getSize()); shape.insets = shape.path.transformInsets(tabs.getLayoutInsets()); shape.labelPath = shape.path.createTransform(tabs.getSelectedLabel().getBounds()); shape.labelBottomY = shape.labelPath.getMaxY() - shape.labelPath.deltaY(tabs.getActiveTabUnderlineHeight() - 1); shape.labelTopY = shape.labelPath.getY() + (tabs.getPosition() == JBTabsPosition.top || tabs.getPosition() == JBTabsPosition.bottom ? shape.labelPath.deltaY(1) : 0); shape.labelLeftX = shape.labelPath.getX() + (tabs.getPosition() == JBTabsPosition.top || tabs.getPosition() == JBTabsPosition.bottom ? 0 : shape.labelPath.deltaX(1)); shape.labelRightX = shape.labelPath.getMaxX() - shape.labelPath.deltaX(1); int leftX = shape.insets.left + (tabs.getPosition() == JBTabsPosition.top || tabs.getPosition() == JBTabsPosition.bottom ? 0 : shape.labelPath.deltaX(1)); shape.path.moveTo(leftX, shape.labelBottomY); shape.path.lineTo(shape.labelLeftX, shape.labelBottomY); shape.path.lineTo(shape.labelLeftX, shape.labelTopY); shape.path.lineTo(shape.labelRightX, shape.labelTopY); shape.path.lineTo(shape.labelRightX, shape.labelBottomY); int lastX = shape.path.getWidth() - shape.path.deltaX(shape.insets.right); shape.path.lineTo(lastX, shape.labelBottomY); shape.path.lineTo(lastX, shape.labelBottomY + shape.labelPath.deltaY(tabs.getActiveTabUnderlineHeight() - 1)); shape.path.lineTo(leftX, shape.labelBottomY + shape.labelPath.deltaY(tabs.getActiveTabUnderlineHeight() - 1)); shape.path.closePath(); shape.fillPath = shape.path.copy(); return shape; }
@Override public void paintBorder(@Nonnull Component c, @Nonnull Graphics g, int x, int y, int width, int height) { if (UIUtil.isUnderAquaLookAndFeel()) { g.setColor(JBTabsImpl.MAC_AQUA_BG_COLOR); final Insets insets = getBorderInsets(c); if (insets.top > 0) { g.fillRect(x, y, width, height + insets.top); } } }
@Override public void add(@Nonnull DockableContent content, RelativePoint dropTarget) { EditorWindow window = null; if (myCurrentOver != null) { final DataProvider provider = myCurrentOver.getDataProvider(); if (provider != null) { window = provider.getDataUnchecked(EditorWindow.DATA_KEY); } } final EditorTabbedContainer.DockableEditor dockableEditor = (EditorTabbedContainer.DockableEditor)content; VirtualFile file = dockableEditor.getFile(); if (window == null || window.isDisposed()) { window = mySplitters.getOrCreateCurrentWindow(file); } if (myCurrentOver != null) { int index = ((JBTabsImpl)myCurrentOver).getDropInfoIndex(); file.putUserData(DesktopEditorWindow.INITIAL_INDEX_KEY, index); } ((FileEditorManagerImpl)FileEditorManagerEx.getInstanceEx(myProject)).openFileImpl2(window, file, true); window.setFilePinned(file, dockableEditor.isPinned()); }
public CompressibleSingleRowLayout(JBTabsImpl tabs) { super(tabs); }
public ScrollableSingleRowLayout(final JBTabsImpl tabs) { super(tabs); }
public Rectangle getMoreRect(final SingleRowPassInfo data) { return new Rectangle(data.insets.left + JBTabsImpl.getSelectionTabVShift(), myTabs.getHeight() - data.insets.bottom - data.moreRectAxisSize - 1, myTabs.myHeaderFitSize.width - 1, data.moreRectAxisSize - 1); }