@Override public void scroll(int units) { myScrollOffset += units; if (myLastSingRowLayout != null) { int offset = -myScrollOffset; for (TabInfo info : myLastSingRowLayout.myVisibleInfos) { final int length = getRequiredLength(info); if (info == myTabs.getSelectedInfo()) { if (offset < 0) { myScrollOffset+=offset; } else { final int maxLength = myLastSingRowLayout.toFitLength - getStrategy().getMoreRectAxisSize(); if (offset + length > maxLength) { myScrollOffset+=offset + length - maxLength; } } break; } offset += length; } clampScrollOffsetToBounds(myLastSingRowLayout); } }
private void doScrollSelectionInView(SingleRowPassInfo passInfo) { int offset = -myScrollOffset; for (TabInfo info : passInfo.myVisibleInfos) { final int length = getRequiredLength(info); if (info == myTabs.getSelectedInfo()) { if (offset < 0) { scroll(offset); } else { final int maxLength = passInfo.toFitLength - getStrategy().getMoreRectAxisSize(); if (offset + length > maxLength) { scroll(offset + length - maxLength); } } break; } offset += length; } }
protected boolean checkLayoutLabels(SingleRowPassInfo data) { boolean layoutLabels = true; if (!myTabs.myForcedRelayout && myLastSingRowLayout != null && myLastSingRowLayout.contentCount == myTabs.getTabCount() && myLastSingRowLayout.layoutSize.equals(myTabs.getSize()) && myLastSingRowLayout.scrollOffset == getScrollOffset()) { for (TabInfo each : data.myVisibleInfos) { final TabLabel eachLabel = myTabs.myInfo2Label.get(each); if (!eachLabel.isValid()) { layoutLabels = true; break; } if (myTabs.getSelectedInfo() == each) { if (eachLabel.getBounds().width != 0) { layoutLabels = false; } } } } return layoutLabels; }
private void processDrop(final SingleRowPassInfo data, final TabInfo info, boolean isFirstSide) { data.requiredLength -= getStrategy().getLengthIncrement(myTabs.myInfo2Label.get(info).getPreferredSize()); data.toDrop.add(info); data.toLayout.remove(info); if (data.toDrop.size() == 1) { data.toFitLength -= data.moreRectAxisSize; } if (!data.firstGhostVisible && isFirstSide) { data.firstGhostVisible = !myTabs.isEditorTabs(); if (!myTabs.isGhostsAlwaysVisible() && !myTabs.isEditorTabs()) { data.toFitLength -= myTabs.getGhostTabLength(); } } else if (!data.lastGhostVisible && !isFirstSide) { data.lastGhostVisible = !myTabs.isEditorTabs(); if (!myTabs.isGhostsAlwaysVisible() && !myTabs.isEditorTabs()) { data.toFitLength -= myTabs.getGhostTabLength(); } } }
@Override public Image processDropOver(@NotNull DockableContent content, RelativePoint point) { JBTabs current = getTabsAt(content, point); if (myCurrentOver != null && myCurrentOver != current) { resetDropOver(content); } if (myCurrentOver == null && current != null) { myCurrentOver = current; Presentation presentation = content.getPresentation(); myCurrentOverInfo = new TabInfo(new JLabel("")).setText(presentation.getText()).setIcon(presentation.getIcon()); myCurrentOverImg = myCurrentOver.startDropOver(myCurrentOverInfo, point); } if (myCurrentOver != null) { myCurrentOver.processDropOver(myCurrentOverInfo, point); } return myCurrentOverImg; }
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); }
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); } }
private void updateTabsUI(final boolean validateNow) { boolean hasToolbarContent = rebuildToolbar(); Set<String> usedNames = new HashSet<String>(); List<TabInfo> tabs = myTabs.getTabs(); for (TabInfo each : tabs) { hasToolbarContent |= updateTabUI(each, usedNames); } int tabsCount = tabs.size(); for (RunnerContentUi child : myChildren) { tabsCount += child.myTabs.getTabCount(); } myTabs.getPresentation().setHideTabs(!hasToolbarContent && tabsCount <= 1 && myOriginal == null); myTabs.updateTabActions(validateNow); if (validateNow) { myTabs.sortTabs(myTabsComparator); } }
private ActionCallback restoreLastUiState() { if (isStateBeingRestored()) return ActionCallback.REJECTED; try { setStateIsBeingRestored(true, this); List<TabInfo> tabs = new ArrayList<TabInfo>(); tabs.addAll(myTabs.getTabs()); final ActionCallback result = new ActionCallback(tabs.size()); for (TabInfo each : tabs) { getGridFor(each).restoreLastUiState().notifyWhenDone(result); } return result; } finally { setStateIsBeingRestored(false, this); } }
@Override public ActionCallback select(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(new Runnable() { @Override public void run() { grid.select(content, requestFocus).notifyWhenDone(result); } }); return result; }
@Override public void dragOutStarted(MouseEvent mouseEvent, TabInfo info) { JComponent component = info.getComponent(); Content[] data = CONTENT_KEY.getData((DataProvider)component); assert data != null; 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, Arrays.asList(data), 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)); }
private void processDrop(final SingleRowPassInfo data, final TabInfo info, boolean isFirstSide) { data.requiredLength -= getStrategy().getLengthIncrement(myTabs.myInfo2Label.get(info).getPreferredSize()); data.toDrop.add(info); data.toLayout.remove(info); if (data.toDrop.size() == 1) { data.toFitLength -= data.moreRectAxisSize; } if (!data.firstGhostVisible && isFirstSide) { data.firstGhostVisible = !myTabs.isEditorTabs(); if (!myTabs.isGhostsAlwaysVisible() && !myTabs.isEditorTabs()) { data.toFitLength -= JBTabsImpl.getGhostTabLength(); } } else if (!data.lastGhostVisible && !isFirstSide) { data.lastGhostVisible = !myTabs.isEditorTabs(); if (!myTabs.isGhostsAlwaysVisible() && !myTabs.isEditorTabs()) { data.toFitLength -= JBTabsImpl.getGhostTabLength(); } } }
private TabInfo createTabInfoFor(Content content) { final JComponent c = content.getComponent(); final TabInfo tabInfo = updatePresentation(new TabInfo(new ProviderWrapper(content, myContext)), content) .setObject(content) .setPreferredFocusableComponent(content.getPreferredFocusableComponent()) .setActionsContextComponent(content.getActionsContextComponent()); myContents.remove(content); myContents.put(content, tabInfo); ActionGroup group = (ActionGroup)myContext.getActionManager().getAction(RunnerContentUi.VIEW_TOOLBAR); tabInfo.setTabLabelActions(group, ViewContext.CELL_TOOLBAR_PLACE); tabInfo.setDragOutDelegate(((RunnerContentUi)myContext).myDragOutDelegate); return tabInfo; }
private ActionCallback restoreLastUiState() { if (isStateBeingRestored()) return new ActionCallback.Rejected(); try { setStateIsBeingRestored(true, this); List<TabInfo> tabs = new ArrayList<TabInfo>(); tabs.addAll(myTabs.getTabs()); final ActionCallback result = new ActionCallback(tabs.size()); for (TabInfo each : tabs) { getGridFor(each).restoreLastUiState().notifyWhenDone(result); } return result; } finally { setStateIsBeingRestored(false, this); } }
@Override public ActionCallback select(final Content content, final boolean requestFocus) { final GridImpl grid = (GridImpl)findGridFor(content); if (grid == null) return new ActionCallback.Done(); final TabInfo info = myTabs.findInfo(grid); if (info == null) return new ActionCallback.Done(); final ActionCallback result = new ActionCallback(); myTabs.select(info, false).doWhenDone(new Runnable() { @Override public void run() { grid.select(content, requestFocus).notifyWhenDone(result); } }); return result; }
@Override public void validate(final Content content, final ActiveRunnable toRestore) { final TabInfo current = myTabs.getSelectedInfo(); myTabs.getPresentation().setPaintBlocked(true, true); select(content, false).doWhenDone(new Runnable() { @Override public void run() { myTabs.getComponent().validate(); toRestore.run().doWhenDone(new Runnable() { @Override public void run() { myTabs.select(current, true); myTabs.getPresentation().setPaintBlocked(false, true); } }); } }); }
@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 scroll(int units) { myScrollOffset += units; if (myLastSingRowLayout == null) return; int offset = -myScrollOffset; for (TabInfo info : myLastSingRowLayout.myVisibleInfos) { final int length = getRequiredLength(info); if (info == myTabs.getSelectedInfo()) { int maxLength = myLastSingRowLayout.toFitLength - getStrategy().getMoreRectAxisSize(); if (offset < 0 && length < maxLength) { myScrollOffset += offset; } else if (offset + length > maxLength) { myScrollOffset += offset + length - maxLength; } break; } offset += length; } clampScrollOffsetToBounds(myLastSingRowLayout); }
private ActionCallback restoreLastUiState() { if (isStateBeingRestored()) return ActionCallback.REJECTED; try { setStateIsBeingRestored(true, this); List<TabInfo> tabs = new ArrayList<>(); tabs.addAll(myTabs.getTabs()); final ActionCallback result = new ActionCallback(tabs.size()); for (TabInfo each : tabs) { getGridFor(each).restoreLastUiState().notifyWhenDone(result); } return result; } finally { setStateIsBeingRestored(false, this); } }
@Override public void dragOutStarted(MouseEvent mouseEvent, TabInfo info) { JComponent component = info.getComponent(); Content[] data = (Content[])((DataProvider)component).getData(CONTENT_KEY); assert data != null; 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, Arrays.asList(data), 0)); }
@Override public Image processDropOver(@Nonnull DockableContent content, RelativePoint point) { JBTabs current = getTabsAt(content, point); if (myCurrentOver != null && myCurrentOver != current) { resetDropOver(content); } if (myCurrentOver == null && current != null) { myCurrentOver = current; Presentation presentation = content.getPresentation(); myCurrentOverInfo = new TabInfo(new JLabel("")).setText(presentation.getText()).setIcon(presentation.getIcon()); myCurrentOverImg = myCurrentOver.startDropOver(myCurrentOverInfo, point); } if (myCurrentOver != null) { myCurrentOver.processDropOver(myCurrentOverInfo, point); } return myCurrentOverImg; }
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); }
private TabInfo createClosableTab(StudyTestContentPanel contentPanel, Task currentTask) { TabInfo closableTab = new TabInfo(contentPanel); final DefaultActionGroup tabActions = new DefaultActionGroup(); tabActions.add(new CloseTab(closableTab, currentTask)); closableTab.setTabLabelActions(tabActions, ActionPlaces.EDITOR_TAB); return closableTab; }
@Override public IDebuggerTabs addTab(JComponent component, String name) { TabInfo tabInfo = new TabInfo(component).setText(name); mTabs.addTab(tabInfo); setSelectComponent(tabInfo); return this; }
public ActionPanel(JBTabsImpl tabs, TabInfo tabInfo, Pass<MouseEvent> pass) { myTabs = tabs; ActionGroup group = tabInfo.getTabLabelActions() != null ? tabInfo.getTabLabelActions() : new DefaultActionGroup(); AnAction[] children = group.getChildren(null); final NonOpaquePanel wrapper = new NonOpaquePanel(new BorderLayout()); wrapper.add(Box.createHorizontalStrut(2), BorderLayout.WEST); NonOpaquePanel inner = new NonOpaquePanel(); inner.setLayout(new BoxLayout(inner, BoxLayout.X_AXIS)); wrapper.add(inner, BorderLayout.CENTER); for (AnAction each : children) { ActionButton eachButton = new ActionButton(myTabs, tabInfo, each, tabInfo.getTabActionPlace(), pass, tabs.getTabActionsMouseDeadzone()) { @Override protected void repaintComponent(final Component c) { TabLabel tabLabel = (TabLabel) SwingUtilities.getAncestorOfClass(TabLabel.class, c); if (tabLabel != null) { Point point = SwingUtilities.convertPoint(c, new Point(0, 0), tabLabel); Dimension d = c.getSize(); tabLabel.repaint(point.x, point.y, d.width, d.height); } else { super.repaintComponent(c); } } }; myButtons.add(eachButton); InplaceButton component = eachButton.getComponent(); inner.add(component); } add(wrapper); }