/** * Adds a <i>component</i> with the specified tab title. * Cover method for insertTab(). * * @param title the title to be displayed in this tab * @param component The component to be displayed when this tab is clicked. * @see #insertTab * @see #removeTabAt */ public SComponent add(String title, SComponent component) { addTab(title, component); return component; }
/** * Creates a tabbed pane. * * @return the created tabbed pane. */ protected STabbedPane createSTabbedPane() { STabbedPane tabbedPane = new STabbedPane(); tabbedPane.setPreferredSize(SDimension.FULLAREA); tabbedPane.setVerticalAlignment(SConstants.TOP_ALIGN); tabbedPane.setHorizontalAlignment(SConstants.LEFT_ALIGN); return tabbedPane; }
@Override public void actionPerformed(ActionEvent e) { if (tab.getSelectedIndex() > 0 && "previous".equals(e.getActionCommand())) { int index = tab.getSelectedIndex() - 1; if (tab.isEnabledAt(index)) tab.setSelectedIndex(index); } else if (tab.getSelectedIndex() < tab.getTabCount() - 1 && "next".equals(e.getActionCommand())) { int index = tab.getSelectedIndex() + 1; if (tab.isEnabledAt(index)) tab.setSelectedIndex(index); } tab.requestFocus(); } }
/** * Sets the selected component for this tabbedpane. This * will automatically set the selectedIndex to the index * corresponding to the specified component. * * @see #getSelectedComponent */ public void setSelectedComponent(SComponent c) { int index = indexOfComponent(c); if (index != -1) { setSelectedIndex(index); } else { throw new IllegalArgumentException("component not found in tabbed pane"); } }
protected static void writeTabs(Device device, STabbedPane tabbedPane) throws IOException { final Browser browser = tabbedPane.getSession().getUserAgent(); String selectedTabStyle = tabbedPane.getStyle(STabbedPane.SELECTOR_SELECTED_TAB); String unselectedTabStyle = tabbedPane.getStyle(STabbedPane.SELECTOR_UNSELECTED_TAB); String disabledTabStyle = tabbedPane.getStyle(STabbedPane.SELECTOR_DISABLED_TAB); StringBuilder selectedTabInline = Utils.inlineStyles(tabbedPane.getDynamicStyle(STabbedPane.SELECTOR_SELECTED_TAB)); StringBuilder unselectedTabInline = Utils.inlineStyles(tabbedPane.getDynamicStyle(STabbedPane.SELECTOR_UNSELECTED_TAB)); StringBuilder disabledTabInline = Utils.inlineStyles(tabbedPane.getDynamicStyle(STabbedPane.SELECTOR_DISABLED_TAB)); for (int i = 0; i < tabbedPane.getTabCount(); i++) { final SIcon icon = tabbedPane.getIconAt(i); final String tooltip = tabbedPane.getToolTipText(); final String title = nbspWorkaround ? Utils.nonBreakingSpaces(tabbedPane.getTitleAt(i)) : tabbedPane.getTitleAt(i); final boolean enabledTab = tabbedPane.isEnabledAt(i); final String eventValue = String.valueOf(i); Utils.printButtonStart(device, tabbedPane, eventValue, enabledTab, tabbedPane.getShowAsFormComponent()); if (i == tabbedPane.getSelectedIndex() && tabbedPane.isFocusOwner()) { Utils.optAttribute(device, "foc", tabbedPane.getName()); cssClassName.append(placements.get(tabbedPane.getTabPlacement())); if (i == tabbedPane.getSelectedIndex()) { cssClassName.append(" STabbedPane_Tab_selected"); } else if (!enabledTab) { if (i == tabbedPane.getSelectedIndex()) { Utils.optAttribute(device, "style", selectedTabInline); } else if (!enabledTab) {
int newTabCount = getTabCount() - 1; int selected = getSelectedIndex(); removePageAt(index); if (newTabCount > 0 && selected != -1) { if (selected >= (newTabCount)) { while (newTabCount > decrement && !isEnabledAt(newTabCount - decrement)) { decrement++; if (isEnabledAt(newTabCount - decrement)) { setSelectedIndex(newTabCount - decrement); } else { setSelectedIndex(-1); while ((newTabCount - 1 > newTab) && !isEnabledAt(newTab)) { newTab++; if (isEnabledAt(newTab)) { setSelectedIndex(newTab); getSelectedComponent().setVisible(true); } else { setSelectedIndex(-1); return; while (newTab > 0 && !isEnabledAt(newTab)) { newTab--;
STabbedPane tabbedPane = new STabbedPane(); tabbedPane.addTab("Simple", null, simpleBorders, null); tabbedPane.addTab("Titled", null, titledBorders, null); tabbedPane.setSelectedIndex(0); String toolTip = "<html>Blue Wavy Line border art crew:<br> Bill Pauley<br> Cris St. Aubyn<br> Ben Wronsky<br> Nathan Walrath<br> Tommy Adams, special consultant</html>"; tabbedPane.setToolTipTextAt(1, toolTip);
setSelectedIndex(0); } else if (index <= getSelectedIndex()) { setSelectedIndex(getSelectedIndex() + 1); reload();
viewComponent, viewDescriptor); viewComponent.addChangeListener(new ChangeListener() { viewComponent.addTab(tabText, childIcon, tabView, childViewDescriptor.getI18nDescription(actionHandler, locale) + TOOLTIP_ELLIPSIS); } else { viewComponent.addTab(tabText, childIcon, tabView);
/** * {@inheritDoc} */ @Override protected void selectChildViewIndex(SComponent viewComponent, int index) { if (viewComponent instanceof STabbedPane) { ((STabbedPane) viewComponent).setSelectedIndex(index); } }
/** * Sets the component at <i>index</i> to <i>component</i> which must not be null. * An internal exception is raised if there is no tab at that index. * * @param index the tab index where the title should be set * @param component the component for the tab * @see #getComponentAt */ public void setComponentAt(int index, SComponent component) { contents.remove(index); SComponent oldVal = ((Page) pages.get(index)).component; ((Page) pages.get(index)).component = component; contents.add(component, component.getName(), index); component.setVisible(getSelectedIndex() == index); reload(); propertyChangeSupport.firePropertyChange("componentAt", oldVal, ((Page) pages.get(index)).component); }
/** * Returns the currently selected component for this tabbedpane. * Returns null if there is no currently selected tab. * * @return the component corresponding to the selected tab * @see #setSelectedComponent */ public SComponent getSelectedComponent() { int index = getSelectedIndex(); if (index == -1) { return null; } return ((Page) pages.get(index)).component; }
/** * Sets selection and fire changeevents, if user changed * tab selection. */ @Override public void fireFinalEvents() { super.fireFinalEvents(); if (lleChangedIndex > -1) setSelectedIndex(lleChangedIndex); lleChangedIndex = -1; }
/** * Sets the component at <i>index</i> to <i>component</i>. * An internal exception is raised if there is no tab at that index. * * @param index the tab index where this component is being placed * @param component the component for the tab * @see #getComponent(int) */ public void setComponent(int index, SComponent component) { Page page = (Page) pages.get(index); SComponent oldVal = page.component; if (component != page.component) { if (page.component != null) { contents.remove(page.component); } page.component = component; contents.addComponent(page.component, page.component.getName()); if (getSelectedIndex() == index) card.show(component); reload(); propertyChangeSupport.firePropertyChange("component", oldVal, page.component); } }
public void stateChanged(ChangeEvent e) { STabbedPane source = (STabbedPane) e.getSource(); view.setCurrentViewIndex(source.getSelectedIndex()); } });
/** * Creates a tabbed pane. * * @return the created tabbed pane. */ protected STabbedPane createSTabbedPane() { STabbedPane tabbedPane = new STabbedPane(); tabbedPane.setPreferredSize(SDimension.FULLAREA); tabbedPane.setVerticalAlignment(SConstants.TOP_ALIGN); tabbedPane.setHorizontalAlignment(SConstants.LEFT_ALIGN); return tabbedPane; }
private ICompositeView<SComponent> createTabView( ITabViewDescriptor viewDescriptor, IActionHandler actionHandler, Locale locale) { STabbedPane viewComponent = createSTabbedPane(); BasicCompositeView<SComponent> view = constructCompositeView(viewComponent, viewDescriptor); List<IView<SComponent>> childrenViews = new ArrayList<IView<SComponent>>(); for (IViewDescriptor childViewDescriptor : viewDescriptor .getChildViewDescriptors()) { IView<SComponent> childView = createView(childViewDescriptor, actionHandler, locale); SIcon childIcon = iconFactory.getIcon(childViewDescriptor .getIconImageURL(), IIconFactory.SMALL_ICON_SIZE); SComponent tabView = childView.getPeer(); if (childViewDescriptor.getDescription() != null) { viewComponent.addTab(childViewDescriptor.getI18nName( getTranslationProvider(), locale), childIcon, tabView, childViewDescriptor.getI18nDescription(getTranslationProvider(), locale) + TOOLTIP_ELLIPSIS); } else { viewComponent.addTab(childViewDescriptor.getI18nName( getTranslationProvider(), locale), childIcon, tabView); } childrenViews.add(childView); } view.setChildren(childrenViews); return view; }
/** * Sets the selected index for this tabbedpane. * * @see #getSelectedIndex * @see SingleSelectionModel#setSelectedIndex */ public void setSelectedIndex(int index) { int oldVal = model.getSelectedIndex(); model.setSelectedIndex(index); propertyChangeSupport.firePropertyChange("selectedIndex", oldVal, this.getSelectedIndex()); }