com.intellij.ui.tabs.TabInfo Java Examples
The following examples show how to use
com.intellij.ui.tabs.TabInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DockableEditorTabbedContainer.java From consulo with Apache License 2.0 | 6 votes |
@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(TargetAWT.from(presentation.getIcon())); myCurrentOverImg = myCurrentOver.startDropOver(myCurrentOverInfo, point); } if (myCurrentOver != null) { myCurrentOver.processDropOver(myCurrentOverInfo, point); } return myCurrentOverImg; }
Example #2
Source File: RunnerContentUi.java From consulo with Apache License 2.0 | 6 votes |
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); } }
Example #3
Source File: RunnerContentUi.java From consulo with Apache License 2.0 | 6 votes |
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); } }
Example #4
Source File: RunnerContentUi.java From consulo with Apache License 2.0 | 6 votes |
private void updateTabsUI(final boolean validateNow) { boolean hasToolbarContent = rebuildToolbar(); Set<String> usedNames = new HashSet<>(); List<TabInfo> tabs = myTabs.getTabs(); for (TabInfo each : tabs) { hasToolbarContent |= updateTabUI(each, usedNames); } int tabsCount = tabs.size() + myChildren.stream().mapToInt(child -> child.myTabs.getTabCount()).sum(); myTabs.getPresentation().setHideTabs(!hasToolbarContent && tabsCount <= 1 && myOriginal == null); myTabs.updateTabActions(validateNow); if (validateNow) { myTabs.sortTabs(myTabsComparator); } }
Example #5
Source File: ScrollableSingleRowLayout.java From consulo with Apache License 2.0 | 6 votes |
@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); } }
Example #6
Source File: GraphConsoleView.java From jetbrains-plugin-graph-database-support with Apache License 2.0 | 6 votes |
private void createNewQueryPlanTab(String originalQuery, GraphQueryResult result, int tabId) { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout(0, 3)); QueryPlanPanel qpPanel = new QueryPlanPanel(originalQuery, result); qpPanel.initialize(panel); TabInfo tabInfo = new TabInfo(panel); DefaultActionGroup tabActions = new DefaultActionGroup(new QueryPlanPanel.CloseTab() { @Override public void actionPerformed(AnActionEvent e) { super.actionPerformed(e); consoleTabs.removeTab(tabInfo); } }); tabInfo.setTabLabelActions(tabActions, ActionPlaces.EDITOR_TAB); String planType = result.isProfilePlan() ? PROFILE_PLAN_TITLE : EXPLAIN_PLAN_TITLE; consoleTabs.addTab(tabInfo.setText(String.format("%1s %2d - %3s", planType, tabId, LocalDateTime.now().format(QUERY_PLAN_TIME_FORMAT)))); }
Example #7
Source File: GraphConsoleView.java From jetbrains-plugin-graph-database-support with Apache License 2.0 | 6 votes |
private void createUIComponents() { graphCanvas = new JPanel(new GridLayout(0, 1)); consoleTabsPane = new JBTabsPaneImpl(null, SwingConstants.TOP, this); consoleTabs = (JBTabsImpl) consoleTabsPane.getTabs(); consoleTabs.addTabMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { if (UIUtil.isCloseClick(e, MouseEvent.MOUSE_RELEASED)) { final TabInfo info = consoleTabs.findInfo(e); if (info != null) { String tabTitle = info.getText(); if (tabTitle.startsWith(PROFILE_PLAN_TITLE) || tabTitle.startsWith(EXPLAIN_PLAN_TITLE)) { IdeEventQueue.getInstance().blockNextEvents(e); consoleTabs.removeTab(info); } } } } }); }
Example #8
Source File: ScrollableSingleRowLayout.java From consulo with Apache License 2.0 | 6 votes |
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; } }
Example #9
Source File: SingleRowLayout.java From consulo with Apache License 2.0 | 6 votes |
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(); } } }
Example #10
Source File: RunnerContentUi.java From consulo with Apache License 2.0 | 6 votes |
@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)); }
Example #11
Source File: RunnerContentUi.java From consulo with Apache License 2.0 | 5 votes |
private static void moveFollowingTabs(int index, final JBRunnerTabs tabs) { for (TabInfo info : tabs.getTabs()) { TabImpl tab = getTabFor(info); if (tab != null) { int tabIndex = tab.getIndex(); if (tabIndex >= index) { tab.setIndex(tabIndex + 1); } } } }
Example #12
Source File: ActionPanel.java From consulo with Apache License 2.0 | 5 votes |
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); }
Example #13
Source File: RunnerContentUi.java From consulo with Apache License 2.0 | 5 votes |
@Override @Nullable public Grid findGridFor(@Nonnull Content content) { TabImpl tab = (TabImpl)getStateFor(content).getTab(); for (TabInfo each : myTabs.getTabs()) { TabImpl t = getTabFor(each); if (t != null && t.equals(tab)) return getGridFor(each); } return null; }
Example #14
Source File: GraphConsoleView.java From jetbrains-plugin-graph-database-support with Apache License 2.0 | 5 votes |
private void selectTab(String name) { for (TabInfo tab : consoleTabs.getTabs()) { if (name.equals(tab.getText())) { consoleTabs.select(tab, true); return; } } throw new IllegalArgumentException("No tab found with name: " + name); }
Example #15
Source File: ScrollableSingleRowLayout.java From consulo with Apache License 2.0 | 5 votes |
@Nullable @Override protected TabLabel findLastVisibleLabel(SingleRowPassInfo data) { int i = data.toLayout.size()-1; while(i > 0) { final TabInfo info = data.toLayout.get(i); final TabLabel label = myTabs.myInfo2Label.get(info); if (!label.getBounds().isEmpty()) { return label; } i--; } return null; }
Example #16
Source File: SingleRowPassInfo.java From consulo with Apache License 2.0 | 5 votes |
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(); }
Example #17
Source File: RunnerContentUi.java From consulo with Apache License 2.0 | 5 votes |
@Override public Image processDropOver(@Nonnull 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(TargetAWT.from(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; }
Example #18
Source File: TableLayout.java From consulo with Apache License 2.0 | 5 votes |
public boolean isLastRow(TabInfo info) { if (info == null) return false; List<TableRow> rows = myLastTableLayout.table; if (rows.size() > 0) { for (TabInfo tabInfo : rows.get(rows.size() - 1).myColumns) { if (tabInfo == info) return true; } } return false; }
Example #19
Source File: FlutterView.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void addInspectorPanel(String displayName, JBRunnerTabs tabs, PerAppState state, InspectorService.FlutterTreeType treeType, FlutterApp app, InspectorService inspectorService, @NotNull ToolWindow toolWindow, DefaultActionGroup toolbarGroup, boolean selectedTab, boolean useSummaryTree) { final InspectorPanel inspectorPanel = new InspectorPanel( this, app, inspectorService, app::isSessionActive, treeType, useSummaryTree, // TODO(jacobr): support the summary tree view for the RenderObject // tree instead of forcing the legacy view for the RenderObject tree. treeType != InspectorService.FlutterTreeType.widget || !inspectorService.isDetailsSummaryViewSupported(), shouldAutoHorizontalScroll, highlightNodesShownInBothTrees ); final TabInfo tabInfo = new TabInfo(inspectorPanel) .append(displayName, SimpleTextAttributes.REGULAR_ATTRIBUTES); tabs.addTab(tabInfo); state.inspectorPanels.add(inspectorPanel); if (selectedTab) { tabs.select(tabInfo, false); } }
Example #20
Source File: IntelliJEditorTabsUI.java From consulo with Apache License 2.0 | 5 votes |
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); } }
Example #21
Source File: SingleRowLayout.java From consulo with Apache License 2.0 | 5 votes |
protected void prepareLayoutPassInfo(SingleRowPassInfo data, TabInfo selected) { data.insets = myTabs.getLayoutInsets(); data.insets.left += JBUI.scale(myTabs.getFirstTabOffset()); final JBTabsImpl.Toolbar selectedToolbar = myTabs.myInfo2Toolbar.get(selected); data.hToolbar = selectedToolbar != null && myTabs.myHorizontalSide && !selectedToolbar.isEmpty() ? selectedToolbar : null; data.vToolbar = selectedToolbar != null && !myTabs.myHorizontalSide && !selectedToolbar.isEmpty() ? selectedToolbar : null; data.toFitLength = getStrategy().getToFitLength(data); if (myTabs.isGhostsAlwaysVisible()) { data.toFitLength -= myTabs.getGhostTabLength() * 2 + (myTabs.getInterTabSpaceLength() * 2); } }
Example #22
Source File: SingleRowLayout.java From consulo with Apache License 2.0 | 5 votes |
protected void updateMoreIconVisibility(SingleRowPassInfo data) { int counter = 0; for (TabInfo tabInfo : data.myVisibleInfos) { if (isTabHidden(tabInfo)) counter++; } myMoreIcon.updateCounter(counter); }
Example #23
Source File: JBRunnerTabs.java From consulo with Apache License 2.0 | 5 votes |
@Override public void processDropOver(TabInfo over, RelativePoint relativePoint) { final Point point = relativePoint.getPoint(getComponent()); myShowDropLocation = shouldAddToGlobal(point); super.processDropOver(over, relativePoint); for (Map.Entry<TabInfo, TabLabel> entry : myInfo2Label.entrySet()) { final TabLabel label = entry.getValue(); if (label.getBounds().contains(point) && myDropInfo != entry.getKey()) { select(entry.getKey(), false); break; } } }
Example #24
Source File: SingleRowLayout.java From consulo with Apache License 2.0 | 5 votes |
protected void calculateRequiredLength(SingleRowPassInfo data) { for (TabInfo eachInfo : data.myVisibleInfos) { data.requiredLength += getRequiredLength(eachInfo); if (myTabs.getTabsPosition() == JBTabsPosition.left || myTabs.getTabsPosition() == JBTabsPosition.right) { data.requiredLength -= 1; } data.toLayout.add(eachInfo); } }
Example #25
Source File: GridCellImpl.java From consulo with Apache License 2.0 | 5 votes |
public void closeOrMinimize(MouseEvent e) { TabInfo tabInfo = myTabs.findInfo(e); if (tabInfo == null) return; Content content = getContentFor(tabInfo); if (CloseViewAction.isEnabled(new Content[]{content})) { CloseViewAction.perform(myContext, content); } else if (MinimizeViewAction.isEnabled(myContext, getContents(), ViewContext.CELL_TOOLBAR_PLACE)) { minimize(content); } }
Example #26
Source File: RunnerContentUi.java From consulo with Apache License 2.0 | 5 votes |
@Override public void dragOutFinished(MouseEvent event, TabInfo source) { final Component component = event.getComponent(); final IdeFrame window = UIUtil.getParentOfType(IdeFrame.class, component); mySession.process(event); mySession = null; }
Example #27
Source File: GridCellImpl.java From consulo with Apache License 2.0 | 5 votes |
public void processAlert(final Content content, final boolean activate) { if (myMinimizedContents.contains(content)) return; TabInfo tab = getTabFor(content); if (tab == null) return; if (myTabs.getSelectedInfo() != tab) { if (activate) { tab.fireAlert(); } else { tab.stopAlerting(); } } }
Example #28
Source File: GridCellImpl.java From consulo with Apache License 2.0 | 5 votes |
@Nullable private static TabInfo updatePresentation(TabInfo info, Content content) { if (info == null) { return null; } return info. setIcon(content.getIcon()). setText(content.getDisplayName()). setTooltipText(content.getDescription()). setActionsContextComponent(content.getActionsContextComponent()). setActions(content.getActions(), content.getPlace()); }
Example #29
Source File: GridCellImpl.java From consulo with Apache License 2.0 | 5 votes |
private TabInfo createTabInfoFor(Content content) { 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; }
Example #30
Source File: IntelliJEditorTabsUI.java From consulo with Apache License 2.0 | 5 votes |
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); }