/** 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); } } }
/** * Returns the tabbox owns this component. */ public Tabbox getTabbox() { final Tabs tabs = (Tabs) getParent(); return tabs != null ? tabs.getTabbox() : null; }
/** * 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 void render(Component comp, Writer out) throws IOException { final SmartWriter wh = new SmartWriter(out); final Tabs self = (Tabs)comp; final String zcs = self.getZclass() + '-'; final String uuid = self.getUuid(); wh.write("<div id=\""+self.getUuid()+"\" ") .write("z.type=\"zul.tab2.Tabs2\"") .write(self.getOuterAttrs()).write(self.getInnerAttrs()) .writeln(">"); wh.write("<div id=\""+uuid+"!header\"") .write(" class=\""+zcs+"header\"") .writeln(">"); wh.write("<ul id=\""+uuid+"!ul\"") .write(" class=\""+zcs+"cnt\"") .write(">"); wh.writeChildren(self); wh.write("<li id=\""+uuid+"!edge\"") .write(" class=\""+zcs+"edge\"></li>"); wh.write("</ul>"); wh.write("</div>"); wh.write("<div id=\""+uuid+"!up\"> </div>"); wh.write("<div id=\""+uuid+"!down\"> </div>"); wh.write("</div>"); wh.write("<div id=\""+uuid+"!line\"") .write(" class=\""+zcs+"space\" ></div>"); } }
public boolean insertBefore(Component child, Component refChild) { boolean sel = getChildren().isEmpty(), desel = false; final Tab newtab = (Tab) child; if (!sel && newtab.isSelected()) { final Tabbox tabbox = getTabbox(); newtab.setSelectedDirectly(true); if (desel) for (Iterator<Component> it = getChildren().iterator(); it.hasNext();) { final Tab tab = (Tab) it.next(); if (tab != newtab && tab.isSelected()) {
Object oldVar = tabs.getAttribute(varnm); Object oldIter = tabs.getAttribute(itervarnm); tabs.setAttribute(varnm, data); tabs.setAttribute(itervarnm, iterStatus); tabs.removeAttribute(varnm); } else { tabs.setAttribute(varnm, oldVar); tabs.removeAttribute(itervarnm); } else { tabs.setAttribute(itervarnm, oldIter);
/** Returns the tabbox owns this component. * <p>It is the same as {@link #getParent}. */ public Tabbox getTabbox() { return (Tabbox) getParent(); }
public void render(Component comp, Writer out) throws IOException { final Tabs self = (Tabs) comp; final Tabbox tabbox = self.getTabbox(); final String zcs = self.getZclass() + '-'; final String uuid = self.getUuid(); final Toolbar tb = tabbox.getToolbar(); final boolean isAuxtb = tabbox.isTabscroll() && tb != null; wh.write("<div id=\"" + uuid + "\"").write(" z.type=\"zul.tab2.Tabs2\"").write(self.getOuterAttrs()) .write(self.getInnerAttrs()).writeln('>');
/** * 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; }
public String getWidth() { String width = super.getWidth(); Tabbox tabbox = getTabbox(); if (width == null && tabbox != null && tabbox.isVertical()) width = "50px"; return width; }
/** 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); } } }
public void onChildAdded(Component child) { super.onChildAdded(child); final Tabbox tabbox = getTabbox(); if (tabbox != null) ((Tab) child).addEventListener(Events.ON_SELECT, tabbox._listener); }
/** 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 void invalidate() { Tabbox tbox = getTabbox(); if (tbox != null && tbox.isVertical()) tbox.invalidate(); else super.invalidate(); }
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; }
public void onChildRemoved(Component child) { super.onChildRemoved(child); final Tabbox tabbox = getTabbox(); if (tabbox != null) { Tab tab = (Tab) child; tab.removeEventListener(Events.ON_SELECT, tabbox._listener); if (tabbox.getSelectedTab() == tab) { tabbox.clearSelectedTab(); } } }
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(); }
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) {