/** * Returns the selected index. */ public int getSelectedIndex() { return _seltab != null ? _seltab.getIndex() : -1; }
/** * Returns the panel associated with this tab. */ public Tabpanel getLinkedPanel() { final int j = getIndex(); if (j >= 0) { final Tabbox tabbox = getTabbox(); if (tabbox != null) { final Tabpanels tabpanels = tabbox.getTabpanels(); if (tabpanels != null && tabpanels.getChildren().size() > j) return (Tabpanel) tabpanels.getChildren().get(j); } } return null; }
/** Sets the selected tab. */ /* packge */void selectTabDirectly(Tab tab, boolean byClient) { if (tab == null) throw new IllegalArgumentException("null tab"); if (tab.getTabbox() != this) throw new UiException("Not my child: " + tab); if (tab != _seltab) { if (_seltab != null) _seltab.setSelectedDirectly(false); try { // avoid recursive invoking if (getAttribute(TabboxEngine.ATTR_CHANGING_SELECTION) == null) { setAttribute(TabboxEngine.ATTR_CHANGING_SELECTION, Boolean.TRUE); _seltab = tab; _seltab.setSelectedDirectly(true); if (byClient && _model != null) { Selectable<Object> sm = getSelectableModel(); if (!sm.isSelected(_model.getElementAt(_seltab.getIndex()))) { sm.clearSelection(); sm.addToSelection(_model.getElementAt(_seltab.getIndex())); } } } } finally { removeAttribute(TabboxEngine.ATTR_CHANGING_SELECTION); } if (!byClient) smartUpdate("selectedTab", _seltab); } }