public void placeFeedback(FeedbackLayer feedbackLayer, ComponentDragObject dragObject) { final String tooltipText = UIDesignerBundle.message("insert.feedback.add.tab", getDisplayName(), myInsertIndex); if (myInsertIndex < getTabbedPane().getTabCount()) { feedbackLayer.putFeedback(getDelegee(), myFeedbackRect, VertInsertFeedbackPainter.INSTANCE, tooltipText); } else { Rectangle rcFeedback; final JTabbedPane tabbedPane = getTabbedPane(); final TabbedPaneUI ui = tabbedPane.getUI(); if (tabbedPane.getTabCount() > 0) { Rectangle rc = ui.getTabBounds(tabbedPane, tabbedPane.getTabCount()-1); rcFeedback = new Rectangle(rc.x+rc.width, rc.y, 50, rc.height); } else { // approximate rcFeedback = new Rectangle(0, 0, 50, tabbedPane.getFontMetrics(tabbedPane.getFont()).getHeight() + 8); } feedbackLayer.putFeedback(getDelegee(), rcFeedback, tooltipText); } }
private void maybeShowKeyStoreTabPopup(MouseEvent evt) { if (evt.isPopupTrigger()) { int tabCount = jkstpKeyStores.getTabCount(); TabbedPaneUI tpu = jkstpKeyStores.getUI(); for (int i = 0; i < tabCount; i++) { Rectangle rect = tpu.getTabBounds(jkstpKeyStores, i); int x = evt.getX(); int y = evt.getY(); if (x < rect.x || x > rect.x + rect.width || y < rect.y || y > rect.y + rect.height) { continue; } jpmKeyStoreTab.show(evt.getComponent(), evt.getX(), evt.getY()); break; } } }
public TabManager(final JTabbedPane tabbedPane, final int tabBarWidth, final int tabLayoutPolicy) { this.tabbedPane = tabbedPane; this.tabbedPane.setTabLayoutPolicy(tabLayoutPolicy); this.TAB_BAR_WIDTH = tabBarWidth; final TabbedPaneUI tabUI = this.tabbedPane.getUI(); if (tabUI instanceof MetalTabbedPaneUI) { this.tabbedPane.setUI(new CustomMetalTabbedPaneUI(this)); } else if (tabUI instanceof SynthTabbedPaneUI) { this.tabbedPane.setUI(new CustomSynthTabbedPaneUI(this)); } else if (tabUI instanceof MotifTabbedPaneUI) { this.tabbedPane.setUI(new CustomMotifTabbedPaneUI(this)); } else if (tabUI instanceof WindowsTabbedPaneUI) { this.tabbedPane.setUI(new CustomWindowsTabbedPaneUI(this)); } else { this.tabbedPane.setUI(new CustomBasicTabbedPaneUI(this)); } }
/** Called when the seqeunce of mouse events should lead to actual * showing of the popup menu. */ @Override protected void showPopup(java.awt.event.MouseEvent mouseEvent) { TabbedPaneUI tabUI = mergeTabbedPane.getUI(); int clickTab = tabUI.tabForCoordinate(mergeTabbedPane, mouseEvent.getX(), mouseEvent.getY()); MergePanel panel = getSelectedMergePanel(); if (panel == null) { return; } if (clickTab != -1) { //Click is on valid tab, not on empty area in tab showPopupMenu(createPopupMenu(panel), mouseEvent.getPoint(), mergeTabbedPane); } }
/** * Invokes the <code>tabForCoordinate</code> method on each UI handled by this object. * * @return the value obtained from the first UI, which is * the UI obtained from the default <code>LookAndFeel</code> */ public int tabForCoordinate(JTabbedPane a, int b, int c) { int returnValue = ((TabbedPaneUI) (uis.elementAt(0))).tabForCoordinate(a,b,c); for (int i = 1; i < uis.size(); i++) { ((TabbedPaneUI) (uis.elementAt(i))).tabForCoordinate(a,b,c); } return returnValue; }
/** * Invokes the <code>getTabBounds</code> method on each UI handled by this object. * * @return the value obtained from the first UI, which is * the UI obtained from the default <code>LookAndFeel</code> */ public Rectangle getTabBounds(JTabbedPane a, int b) { Rectangle returnValue = ((TabbedPaneUI) (uis.elementAt(0))).getTabBounds(a,b); for (int i = 1; i < uis.size(); i++) { ((TabbedPaneUI) (uis.elementAt(i))).getTabBounds(a,b); } return returnValue; }
/** * Invokes the <code>getTabRunCount</code> method on each UI handled by this object. * * @return the value obtained from the first UI, which is * the UI obtained from the default <code>LookAndFeel</code> */ public int getTabRunCount(JTabbedPane a) { int returnValue = ((TabbedPaneUI) (uis.elementAt(0))).getTabRunCount(a); for (int i = 1; i < uis.size(); i++) { ((TabbedPaneUI) (uis.elementAt(i))).getTabRunCount(a); } return returnValue; }
/** * Maps {@code JTabbedPane.getUI()} through queue */ public TabbedPaneUI getUI() { return (runMapping(new MapAction<TabbedPaneUI>("getUI") { @Override public TabbedPaneUI map() { return ((JTabbedPane) getSource()).getUI(); } })); }
/** * Maps {@code JTabbedPane.setUI(TabbedPaneUI)} through queue */ public void setUI(final TabbedPaneUI tabbedPaneUI) { runMapping(new MapVoidAction("setUI") { @Override public void map() { ((JTabbedPane) getSource()).setUI(tabbedPaneUI); } }); }
private void closeTabAt(int x, int y) { TabbedPaneUI ui = getUI(); int index = ui.tabForCoordinate(this, x, y); if (index < 0 || !myManager.canCloseContents()) { return; } final Content content = myManager.getContent(index); if (content != null && content.isCloseable()) { myManager.removeContent(content, true); } }
protected void processMouseEvent(MouseEvent e) { if (e.isPopupTrigger()) { // Popup doesn't activate clicked tab. showPopup(e.getX(), e.getY()); return; } if (!e.isShiftDown() && (MouseEvent.BUTTON1_MASK & e.getModifiers()) > 0) { // RightClick without Shift modifiers just select tab if (MouseEvent.MOUSE_RELEASED == e.getID()) { TabbedPaneUI ui = getUI(); int index = ui.tabForCoordinate(this, e.getX(), e.getY()); if (index != -1) { setSelectedIndex(index); } hideMenu(); } } else if (e.isShiftDown() && (MouseEvent.BUTTON1_MASK & e.getModifiers()) > 0) { // Shift+LeftClick closes the tab if (MouseEvent.MOUSE_RELEASED == e.getID()) { closeTabAt(e.getX(), e.getY()); hideMenu(); } } else if ((MouseEvent.BUTTON2_MASK & e.getModifiers()) > 0) { // MouseWheelClick closes the tab if (MouseEvent.MOUSE_RELEASED == e.getID()) { closeTabAt(e.getX(), e.getY()); hideMenu(); } } else if ((MouseEvent.BUTTON3_MASK & e.getModifiers()) > 0 && SystemInfo.isWindows) { // Right mouse button doesn't activate tab } else { super.processMouseEvent(e); } }
/** * @return content at the specified location. <code>x</code> and <code>y</code> are in * tabbed pane coordinate system. The method returns <code>null</code> if there is no contnt at the * specified location. */ private Content getContentAt(int x, int y) { TabbedPaneUI ui = getUI(); int index = ui.tabForCoordinate(this, x, y); if (index < 0) { return null; } return myManager.getContent(index); }
@Override public void setUI(final TabbedPaneUI ui){ super.setUI(ui); if(ui instanceof BasicTabbedPaneUI){ myScrollableTabSupport=new ScrollableTabSupport((BasicTabbedPaneUI)ui); }else{ myScrollableTabSupport=null; } }
protected final int getTabIndexAt(final int x,final int y){ final TabbedPaneUI ui=getUI(); for (int i = 0; i < getTabCount(); i++) { final Rectangle bounds = ui.getTabBounds(this, i); if (bounds.contains(x, y)) { return i; } } return -1; }
/** * @return inplace property for editing of the title of the clicked tab */ public Property getInplaceProperty(final int x, final int y) { final JTabbedPane tabbedPane = getTabbedPane(); final TabbedPaneUI ui = tabbedPane.getUI(); LOG.assertTrue(ui != null); final int index = ui.tabForCoordinate(tabbedPane, x, y); return index != -1 ? new MyTitleProperty(null, index) : null; }
public Rectangle getInplaceEditorBounds(final Property property, final int x, final int y) { final JTabbedPane tabbedPane = getTabbedPane(); final TabbedPaneUI ui = tabbedPane.getUI(); LOG.assertTrue(ui != null); final int index = ui.tabForCoordinate(tabbedPane, x, y); LOG.assertTrue(index != -1); return ui.getTabBounds(tabbedPane, index); }
@Override @NotNull public ComponentDropLocation getDropLocation(RadContainer container, @Nullable final Point location) { final JTabbedPane tabbedPane = getTabbedPane(); final TabbedPaneUI ui = tabbedPane.getUI(); if (location != null && tabbedPane.getTabCount() > 0) { for(int i=0; i<tabbedPane.getTabCount(); i++) { Rectangle rc = ui.getTabBounds(tabbedPane, i); if (location.x < rc.getCenterX()) { return new InsertTabDropLocation(i, new Rectangle(rc.x-4, rc.y, 8, rc.height)); } } } return new InsertTabDropLocation(tabbedPane.getTabCount(), null); }
/** * Create the left side panel of the client. * * @return A component containing the components left of the game screen */ private JComponent createLeftPanel() { minimap = new MapPanelController(client); positionChangeListener.add(minimap); final StatsPanelController stats = StatsPanelController.get(); final BuddyPanelController buddies = BuddyPanelController.get(); ScrolledViewport buddyScroll = new ScrolledViewport((JComponent) buddies.getComponent()); buddyScroll.setScrollingSpeed(SCROLLING_SPEED); final JComponent buddyPane = buddyScroll.getComponent(); buddyPane.setBorder(null); final JComponent leftColumn = SBoxLayout.createContainer(SBoxLayout.VERTICAL); leftColumn.add(minimap.getComponent(), SLayout.EXPAND_X); leftColumn.add(stats.getComponent(), SLayout.EXPAND_X); // Add a background for the tabs. The column itself has none. JPanel tabBackground = new JPanel(); tabBackground.setBorder(null); tabBackground.setLayout(new SBoxLayout(SBoxLayout.VERTICAL)); JTabbedPane tabs = new JTabbedPane(JTabbedPane.BOTTOM); // Adjust the Tab Width, if we can. The default is pretty if there's // space, but in the column there are no pixels to waste. TabbedPaneUI ui = tabs.getUI(); if (ui instanceof StyledTabbedPaneUI) { ((StyledTabbedPaneUI) ui).setTabLabelMargins(1); } tabs.setFocusable(false); tabs.add("Friends", buddyPane); tabs.add("Group", GroupPanelController.get().getComponent()); tabBackground.add(tabs, SBoxLayout.constraint(SLayout.EXPAND_X, SLayout.EXPAND_Y)); leftColumn.add(tabBackground, SBoxLayout.constraint(SLayout.EXPAND_X, SLayout.EXPAND_Y)); return leftColumn; }