/** Adds _listener to all {@link Tab} instances. */ private void addTabsListeners() { if (_tabs != null) { for (Iterator<Component> it = _tabs.getChildren().iterator(); it.hasNext();) { final Tab tab = (Tab) it.next(); tab.addEventListener(Events.ON_SELECT, _listener); } } }
/** Removes _listener from all {@link Tab} instances. */ private void removeTabsListeners() { if (_tabs != null) { for (Iterator<Component> it = _tabs.getChildren().iterator(); it.hasNext();) { final Tab tab = (Tab) it.next(); tab.removeEventListener(Events.ON_SELECT, _listener); } } }
/** * Returns the index of this panel, or -1 if it doesn't belong to any tabs. */ public int getIndex() { final Tabs tabs = (Tabs) getParent(); if (tabs == null) return -1; int j = 0; for (Iterator<Component> it = tabs.getChildren().iterator();; ++j) if (it.next() == this) return j; }
/** Returns the tab associated with this tab panel. */ public Tab getLinkedTab() { final int j = getIndex(); if (j >= 0) { final Tabbox tabbox = getTabbox(); if (tabbox != null) { final Tabs tabs = tabbox.getTabs(); if (tabs != null && tabs.getChildren().size() > j) return (Tab) tabs.getChildren().get(j); } } return null; }
public Object coerceToUi(Object val, Component comp) { //load if (val != null) { //iterate to find the selected radio via the value for (Iterator it = ((Tabbox) comp).getTabs().getChildren().iterator(); it.hasNext();) { final Component child = (Component) it.next(); if (child instanceof Tab) { if (val.equals(((Tab) child).getLabel())) { return child; } } } } return null; }
private void afterUnmarshal(int cnt) { for (Iterator<Component> it = getChildren().iterator(); it.hasNext();) { final Object child = it.next(); if (child instanceof Tabs) { _tabs = (Tabs) child; for (Iterator<Component> e = _tabs.getChildren().iterator(); e.hasNext();) { final Tab tab = (Tab) e.next(); if (tab.isSelected()) { _seltab = tab; break; } } if (--cnt == 0) break; } else if (child instanceof Toolbar) { _toolbar = (Toolbar) child; if (--cnt == 0) break; } else if (child instanceof Tabpanels) { _tabpanels = (Tabpanels) child; if (--cnt == 0) break; } } addTabsListeners(); }
/** * Sets the selected index. */ public void setSelectedIndex(int j) { final Tabs tabs = getTabs(); if (tabs == null) throw new IllegalStateException("No tab at all"); if (j >= 0) setSelectedTab((Tab) tabs.getChildren().get(j)); else setSelectedTab((Tab) tabs.getFirstChild()); // keep the first one selected. }
public boolean insertBefore(Component child, Component refChild) { if (child instanceof Tabs) { if (super.insertBefore(child, refChild)) { _tabs = (Tabs) child; for (Iterator<Component> it = _tabs.getChildren().iterator(); it.hasNext();) { final Tab tab = (Tab) it.next(); if (tab.isSelected()) { _seltab = tab; break; } } addTabsListeners(); return true; } } else if (child instanceof Tabpanels) { if (super.insertBefore(child, refChild)) { _tabpanels = (Tabpanels) child; return true; } } else if (child instanceof Toolbar) { if (super.insertBefore(child, refChild)) { _toolbar = (Toolbar) child; return true; } } else { return super.insertBefore(child, refChild); //impossible but make it more extensible } return false; }
for (Iterator<Component> it = tabs.getChildren().iterator(); it.hasNext();) { final Component child = it.next(); if (child instanceof Tab) {
public boolean insertBefore(Component child, Component refChild) { boolean sel = getChildren().isEmpty(), desel = false; final Tab newtab = (Tab) child; if (!sel && newtab.isSelected()) { newtab.setSelectedDirectly(true); if (desel) for (Iterator<Component> it = getChildren().iterator(); it.hasNext();) { final Tab tab = (Tab) it.next(); if (tab != newtab && tab.isSelected()) {