org.netbeans.swing.tabcontrol.TabbedContainer Java Examples
The following examples show how to use
org.netbeans.swing.tabcontrol.TabbedContainer.
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: ButtonFactory.java From netbeans with Apache License 2.0 | 6 votes |
/** * Creates button to maximize currently selected document in the given tab displayer. * @param controller Tab displayer's controller. * @return Button to maximize selected document tab. */ public static JButton createMaximizeButton( final Controller controller ) { final JButton btn = new JButton(); Icon icon = UIManager.getIcon("nb.multitabs.button.maximize.icon"); if (icon == null) { icon = ImageUtilities.loadImageIcon( "org/netbeans/core/multitabs/resources/maximize.png", true ); //NOI18N } btn.setIcon( icon ); btn.setToolTipText( NbBundle.getMessage(ButtonFactory.class, "Hint_MaximizeRestore") ); btn.addActionListener( new ActionListener() { @Override public void actionPerformed( ActionEvent e ) { controller.postActionEvent( new TabActionEvent( btn, TabbedContainer.COMMAND_MAXIMIZE, -1 ) ); } }); btn.setFocusable( false ); return btn; }
Example #2
Source File: AbstractViewTabDisplayerUI.java From netbeans with Apache License 2.0 | 6 votes |
/** Registers shortcut for enable/ disable auto-hide functionality */ @Override public void registerShortcuts(JComponent comp) { comp.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT). put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, InputEvent.CTRL_DOWN_MASK), PIN_ACTION); comp.getActionMap().put(PIN_ACTION, pinAction); //TODO make shortcut configurable comp.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT). put(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD0, InputEvent.CTRL_DOWN_MASK), TRANSPARENCY_ACTION); comp.getActionMap().put(TRANSPARENCY_ACTION, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { shouldPerformAction(TabbedContainer.COMMAND_TOGGLE_TRANSPARENCY, getSelectionModel().getSelectedIndex(), null); } }); }
Example #3
Source File: DefaultTabbedContainerUI.java From netbeans with Apache License 2.0 | 6 votes |
public void hierarchyChanged(HierarchyEvent e) { if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) { boolean showing = container.isShowing(); if (showing != bug4924561knownShowing) { if (container.isShowing()) { initDisplayer(); attachModelAndSelectionListeners(); ensureSelectedComponentIsShowing(); if (container.getType() == TabbedContainer.TYPE_SLIDING) { updateOrientation(); } } else { detachModelAndSelectionListeners(); if (container.getType() == TabbedContainer.TYPE_SLIDING) { updateOrientation(); } } } bug4924561knownShowing = showing; } }
Example #4
Source File: DefaultTabbedContainerUI.java From netbeans with Apache License 2.0 | 6 votes |
/** * Fills contentDisplayer container with components retrieved from model. */ protected void initDisplayer() { if (container.getContentPolicy() == TabbedContainer.CONTENT_POLICY_ADD_ALL) { List tabs = container.getModel().getTabs(); Component curC = null; for (Iterator iter = tabs.iterator(); iter.hasNext();) { curC = toComp ((TabData) iter.next()); // string parameter is needed for StackLayout to kick in correctly contentDisplayer.add(curC, ""); } } else { int i = tabDisplayer.getSelectionModel().getSelectedIndex(); if (i != -1) { TabData td = container.getModel().getTab(i); contentDisplayer.add(toComp(td), ""); } } updateActiveState(); }
Example #5
Source File: TopComponentOperator.java From netbeans with Apache License 2.0 | 6 votes |
/** Makes top component active and pushes given menu on its tab. * @param popupPath menu path separated by '|' (e.g. "CVS|Refresh") */ public void pushMenuOnTab(String popupPath) { if (isOpened()) { this.makeComponentVisible(); TabbedContainer ta = findTabbedAdapter(); int index = ta.indexOf((TopComponent) getSource()); Rectangle r = new Rectangle(); ta.getTabRect(index, r); Point p = new Point(r.x + (r.width / 2), r.y + (r.height / 2)); Component tabsComp = ta.getComponentAt(p); new JPopupMenuOperator(JPopupMenuOperator.callPopup(tabsComp, p.x, p.y)).pushMenu(popupPath); } else { // try to find enclosing MultiviewTopComponent TopComponentOperator parent = findParentTopComponent(); if (parent != null) { parent.pushMenuOnTab(popupPath); } } }
Example #6
Source File: DefaultTabbedContainerUI.java From netbeans with Apache License 2.0 | 5 votes |
/** Sets the active state of the displayer to match that of the container */ private void updateActiveState() { //#45630 - more of a hack than a fix. //apparently uninstallUI() was called before the the ContainerPropertyChangeListener instance was removed in //ContainerHierarchyListener's hierarchyChanged method. // for such case the property change should be a noop. TabDisplayer displ = tabDisplayer; TabbedContainer cont = container; if (displ != null && cont != null) { displ.setActive(cont.isActive()); } }
Example #7
Source File: WorkspaceTopComponent.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
private void initComponents() { setLayout(new BorderLayout()); DefaultTabDataModel tabDataModel = new DefaultTabDataModel(); tabbedContainer = new TabbedContainer(tabDataModel, TabbedContainer.TYPE_EDITOR, WinsysInfoForTabbedContainer.getDefault(new MyWinsysInfoForTabbedContainer())); tabbedContainer.setVisible(false); desktopPane = new JDesktopPane(); add(tabbedContainer, BorderLayout.NORTH); add(desktopPane, BorderLayout.CENTER); }
Example #8
Source File: DefaultTabbedContainerUI.java From netbeans with Apache License 2.0 | 5 votes |
public void indicesAdded(ComplexListDataEvent e) { Component curC = null; if (container.getContentPolicy() == TabbedContainer.CONTENT_POLICY_ADD_ALL) { int[] indices = e.getIndices(); for (int i = 0; i < indices.length; i++) { curC = toComp(container.getModel().getTab(indices[i])); contentDisplayer.add(curC, ""); } } }
Example #9
Source File: DefaultTabbedContainerUI.java From netbeans with Apache License 2.0 | 5 votes |
public void intervalAdded(ListDataEvent e) { if (container.getContentPolicy() == TabbedContainer.CONTENT_POLICY_ADD_ALL) { Component curC = null; for (int i = e.getIndex0(); i <= e.getIndex1(); i++) { curC = toComp(container.getModel().getTab(i)); contentDisplayer.add(curC, ""); } } }
Example #10
Source File: DefaultTabbedContainerUI.java From netbeans with Apache License 2.0 | 5 votes |
/** * DefaultTabDataModel will always call this method with an instance of * ComplexListDataEvent. */ public void contentsChanged(ListDataEvent e) { //Only need to reread components on setTab (does winsys even use it?) if (e instanceof ComplexListDataEvent) { ComplexListDataEvent clde = (ComplexListDataEvent) e; int index = clde.getIndex0(); if (clde.isUserObjectChanged() && index != -1) { Component comp = contentDisplayer.getComponent( index); Component nue = toComp(tabDisplayer.getModel().getTab(index)); contentDisplayer.remove(comp); boolean add = container.getContentPolicy() == TabbedContainer.CONTENT_POLICY_ADD_ALL || index == container.getSelectionModel().getSelectedIndex(); if (add) { contentDisplayer.add(nue, index); } } if (clde.isTextChanged()) { maybeMakeSelectedTabVisible(clde); } } }
Example #11
Source File: TopComponentOperator.java From netbeans with Apache License 2.0 | 5 votes |
/** Returns TabbedAdapter component from parents hierarchy. * Used also in EditorWindowOperator. */ public TabbedContainer findTabbedAdapter() { Container parent = getSource().getParent(); while (parent != null) { if (parent instanceof TabbedContainer) { // NOI18N return (TabbedContainer) parent; } else { parent = parent.getParent(); } } return null; }
Example #12
Source File: DesktopImpl.java From netbeans with Apache License 2.0 | 5 votes |
private Component findTabbed( Component comp ) { while( comp.getParent() != null ) { if( comp.getParent() instanceof TabbedContainer ) { return comp.getParent(); } comp = comp.getParent(); } return null; }
Example #13
Source File: TabbedContainerBridgeImpl.java From netbeans with Apache License 2.0 | 5 votes |
public void setSelectedItem(JComponent jc, Object selection) { TabbedContainer cont = (TabbedContainer) jc; TabDataModel mdl = cont.getModel(); int max = mdl.size(); for (int i=0; i < max; i++) { TabData td = mdl.getTab(i); if (td.getUserObject() == selection) { cont.getSelectionModel().setSelectedIndex(i); break; } } }
Example #14
Source File: TabbedContainerBridgeImpl.java From netbeans with Apache License 2.0 | 5 votes |
public Object[] getItems(JComponent jc) { TabbedContainer cont = (TabbedContainer) jc; List l = cont.getModel().getTabs(); Object[] items = new Object[l.size()]; for (int i=0; i < items.length; i++) { items[i] = ((TabData) l.get(i)).getUserObject(); } return items; }
Example #15
Source File: TabbedSlideAdapter.java From netbeans with Apache License 2.0 | 5 votes |
@Override public Image createImageOfTab(int tabIndex) { TabData dt = slideBar.getModel().getTab(tabIndex); if (dt.getComponent() instanceof TopComponent) { DefaultTabDataModel tempModel = new DefaultTabDataModel( new TabData[] { dt } ); TabbedContainer temp = new TabbedContainer( tempModel, TabbedContainer.TYPE_VIEW ); temp.setSize( 300,300 ); return temp.createImageOfTab(0); } return null; }
Example #16
Source File: Controller.java From netbeans with Apache License 2.0 | 5 votes |
private void maybeShowPopup( MouseEvent e ) { if( !e.isPopupTrigger() ) return; Point p = e.getPoint(); p = SwingUtilities.convertPoint( e.getComponent(), p, displayer ); TabData tab = displayer.getTabAt( p ); if( null == tab ) return; final int tabIndex = tabModel.indexOf( tab ); //popup menu TabActionEvent tae = new TabActionEvent( this, TabbedContainer.COMMAND_POPUP_REQUEST, tabIndex, e ); postActionEvent( tae ); }
Example #17
Source File: DocumentSwitcherTable.java From netbeans with Apache License 2.0 | 5 votes |
boolean onMouseEvent( MouseEvent e ) { Point p = e.getPoint(); p = SwingUtilities.convertPoint((Component) e.getSource(), p, this); int selRow = getSelectedRow(); int selCol = getSelectedColumn(); if( selRow < 0 || selCol < 0 ) return false; Rectangle rect = getCellRect( selRow, selCol, false ); if( rect.contains( p ) ) { Dimension size = btnClose.getPreferredSize(); int x = rect.x+rect.width-size.width; int y = rect.y + (rect.height-size.height)/2; Rectangle btnRect = new Rectangle( x, y, size.width, size.height); boolean inButton = btnRect.contains( p ); boolean mustRepaint = inCloseButtonRect != inButton; inCloseButtonRect = inButton; if( inButton ) { if( e.getID() == MouseEvent.MOUSE_PRESSED ) { Item item = ( Item ) getModel().getValueAt( selRow, selCol ); TabData tab = item.getTabData(); int tabIndex = controller.getTabModel().indexOf( tab ); if( tabIndex >= 0 ) { TabActionEvent tae = new TabActionEvent( this, TabbedContainer.COMMAND_CLOSE, tabIndex ); controller.postActionEvent( tae ); return true; } } } if( mustRepaint && lastRow == selRow && lastCol == selCol ) repaint( btnRect ); lastCol = selCol; lastRow = selRow; return inButton; } return false; }
Example #18
Source File: CloseButtonHandler.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void mouseClicked( MouseEvent e ) { if( e.getSource() instanceof TabTable ) { TabTable table = ( TabTable ) e.getSource(); if( !table.isShowing() ) return; Point p = e.getPoint(); int row = table.rowAtPoint( p ); int col = table.columnAtPoint( p ); if( row >= 0 && col >= 0 ) { if( table.isCloseButtonHighlighted( row, col ) ) { TabData tab = table.getTabAt( p ); if( null != tab ) { int tabIndex = displayer.getModel().indexOf( tab ); if( tabIndex >= 0 && e.getButton() == MouseEvent.BUTTON1 ) { TabActionEvent tae = null; if( (e.getModifiersEx()& MouseEvent.SHIFT_DOWN_MASK) > 0 ) { tae = new TabActionEvent( displayer, TabbedContainer.COMMAND_CLOSE_ALL, tabIndex ); } else if( (e.getModifiersEx()& MouseEvent.ALT_DOWN_MASK) > 0 ) { tae = new TabActionEvent( displayer, TabbedContainer.COMMAND_CLOSE_ALL_BUT_THIS, tabIndex ); } else { tae = new TabActionEvent( displayer, TabbedContainer.COMMAND_CLOSE, tabIndex ); } if( null != tae ) controller.postActionEvent( tae ); } } } } } }
Example #19
Source File: TabbedContainerBridgeImpl.java From netbeans with Apache License 2.0 | 5 votes |
public Object getSelectedItem(JComponent jc) { Object result = null; TabbedContainer cont = (TabbedContainer) jc; int i = cont.getSelectionModel().getSelectedIndex(); if (i != -1) { result = cont.getModel().getTab(i).getUserObject(); } return result; }
Example #20
Source File: TabbedContainerBridgeImpl.java From netbeans with Apache License 2.0 | 5 votes |
public String getCurrentSelectedTabName(JComponent jc) { TabbedContainer cont = (TabbedContainer) jc; int sel = cont.getSelectionModel().getSelectedIndex(); if (sel != -1) { TabData td = cont.getModel().getTab(sel); return td.getText(); } return null; }
Example #21
Source File: TabbedContainerBridgeImpl.java From netbeans with Apache License 2.0 | 5 votes |
public boolean setSelectionByName(JComponent jc, String tabname) { TabbedContainer cont = (TabbedContainer) jc; TabDataModel mdl = cont.getModel(); int max = mdl.size(); for (int i=0; i < max; i++) { TabData td = mdl.getTab(i); if (tabname.equals(td.getText())) { cont.getSelectionModel().setSelectedIndex(i); return true; } } return false; }
Example #22
Source File: DefaultTabbedContainerUI.java From netbeans with Apache License 2.0 | 4 votes |
public void componentResized (ComponentEvent e) { if (container.getType() == TabbedContainer.TYPE_SLIDING) { updateOrientation(); } }
Example #23
Source File: TabbedAdapter.java From netbeans with Apache License 2.0 | 4 votes |
@Override public void userToggledTransparency(int tabIndex) { postActionEvent(new TabActionEvent(this, TabbedContainer.COMMAND_TOGGLE_TRANSPARENCY, tabIndex)); }
Example #24
Source File: TabbedAdapter.java From netbeans with Apache License 2.0 | 4 votes |
/********** implementation of SlideController *****************/ @Override public void userToggledAutoHide(int tabIndex, boolean enabled) { postActionEvent(new TabActionEvent(this, TabbedContainer.COMMAND_ENABLE_AUTO_HIDE, tabIndex)); }
Example #25
Source File: JTabbedPaneAdapter.java From netbeans with Apache License 2.0 | 4 votes |
@Override public void userToggledTransparency( int tabIndex ) { postActionEvent(new TabActionEvent(this, TabbedContainer.COMMAND_TOGGLE_TRANSPARENCY, tabIndex)); }
Example #26
Source File: JTabbedPaneAdapter.java From netbeans with Apache License 2.0 | 4 votes |
@Override public void userToggledAutoHide( int tabIndex, boolean enabled ) { postActionEvent(new TabActionEvent(this, TabbedContainer.COMMAND_ENABLE_AUTO_HIDE, tabIndex)); }
Example #27
Source File: TabbedContainerBridgeImpl.java From netbeans with Apache License 2.0 | 4 votes |
public void attachSelectionListener(JComponent jc, ChangeListener listener) { TabbedContainer cont = (TabbedContainer) jc; cont.getSelectionModel().addChangeListener(listener); }
Example #28
Source File: DefaultTabbedContainerUI.java From netbeans with Apache License 2.0 | 4 votes |
public void componentMoved (ComponentEvent e) { if (container.getType() == TabbedContainer.TYPE_SLIDING) { updateOrientation(); } }
Example #29
Source File: DefaultTabbedContainerUI.java From netbeans with Apache License 2.0 | 4 votes |
/** Checks the position of the tabbed container relative to its parent * window, and potentially updates its orientation client property. * * @see TabDisplayer#PROP_ORIENTATION */ protected final void updateOrientation() { if (!container.isDisplayable()) { return; } if (Boolean.FALSE.equals(container.getClientProperty (TabbedContainer.PROP_MANAGE_TAB_POSITION))) { //The client has specified that it does not want automatic management //of the displayer orientation return; } Object currOrientation = tabDisplayer.getClientProperty(TabDisplayer.PROP_ORIENTATION); Container window = container.getTopLevelAncestor(); Rectangle containerBounds = container.getBounds(); containerBounds = SwingUtilities.convertRectangle(container, containerBounds, window); boolean longestIsVertical = containerBounds.width < containerBounds.height; int distanceToLeft = containerBounds.x; int distanceToTop = containerBounds.y; int distanceToRight = window.getWidth() - (containerBounds.x + containerBounds.width); int distanceToBottom = window.getHeight() - (containerBounds.y + containerBounds.height); Object orientation; if (!longestIsVertical) { if (distanceToBottom > distanceToTop) { orientation = TabDisplayer.ORIENTATION_NORTH; } else { orientation = TabDisplayer.ORIENTATION_SOUTH; } } else { if (distanceToLeft > distanceToRight) { orientation = TabDisplayer.ORIENTATION_EAST; } else { orientation = TabDisplayer.ORIENTATION_WEST; } } if (currOrientation != orientation) { tabDisplayer.putClientProperty( TabDisplayer.PROP_ORIENTATION, orientation); container.validate(); } }
Example #30
Source File: DefaultTabbedContainerUI.java From netbeans with Apache License 2.0 | 4 votes |
public void propertyChange(PropertyChangeEvent evt) { if (TabbedContainer.PROP_ACTIVE.equals(evt.getPropertyName())) { updateActiveState(); } }