public ComponentAgent getFirstChild() { return asAgent(comp.getFirstChild()); }
private void removeChildren(Component firstChild) { for (Component next = firstChild; next != null;) { // recursively remove all children, depth first if (next.getFirstChild() != null) { removeChildren(next.getFirstChild()); } Component tmp = next.getNextSibling(); ((HtmlShadowElement) next).removeFromParent(); next = tmp; } }
/** * Moves this entry to the beginning of the stream. * * @param dropRoot Parent */ public void moveToTop(Component dropRoot) { if (dropRoot != null) { dropRoot.insertBefore(this, dropRoot.getFirstChild()); Clients.scrollIntoView(this); } }
/** * Renders an alert in its container. * * @param parent Parent component that will host the container. * @param child Child component that is the root component of the alert. * @return The created container. */ public static AlertContainer render(Component parent, Component child) { AlertContainer container = new AlertContainer(child); parent.insertBefore(container, parent.getFirstChild()); return container; }
/** * Converts the children of the give component into a string-typed content, or null if no * children at all. * * @exception UiException * if some of the children is not ZHTML tags (i.e., not {@link AbstractTag}). * @since 5.0.7 */ public static String childrenToContent(Component comp) { Component c; if ((c = comp.getFirstChild()) != null) { final StringBuffer sb = new StringBuffer(); for (; c != null; c = c.getNextSibling()) childrenToContent(comp, c, sb); comp.getChildren().clear(); return sb.toString(); } return null; }
private static void init(Map<String, Component> fellows, Component comp) { if (!(comp instanceof NonFellow)) { final String compId = comp.getId(); if (!AbstractComponent.isAutoId(compId)) fellows.put(compId, comp); } if (!(comp instanceof IdSpace)) for (Component child = comp.getFirstChild(); child != null; child = child.getNextSibling()) init(fellows, child); //recursive }
protected void loadComponent0(Component comp, boolean loadinit) { loadComponentProperties0(comp, loadinit); final Map<String, List<Binding>> compBindings = _bindings.get(comp); if (_activating || compBindings == null || !compBindings.keySet().contains(CHILDREN_ATTR)) { for (Component kid = comp.getFirstChild(); kid != null; kid = kid.getNextSibling()) { loadComponent0(kid, loadinit); //recursive } // Bug ZK-3046, we handle it in ShadowElementsCtrl.filterOutShadows() when invoked by BindChildRenderer.java if (comp instanceof ComponentCtrl) { for (ShadowElement se : ((ComponentCtrl) comp).getShadowRoots()) { loadComponent0((Component) se, loadinit); //recursive } } } }
private static void checkIdSpacesDown(Component comp, IdSpace owner) { final String compId = comp.getId(); if (!(comp instanceof NonFellow) && !isAutoId(compId) && (owner instanceof Component ? ((AbstractComponent) owner)._auxinf.spaceInfo.fellows.containsKey(compId) : owner.hasFellow(compId))) throw new UiException("Not unique in the ID space of " + owner + ": " + compId); if (!(comp instanceof IdSpace)) for (AbstractComponent ac = (AbstractComponent) comp.getFirstChild(); ac != null; ac = ac._next) checkIdSpacesDown(ac, owner); //recursive }
/** * Removes a menu item from the panel's menu bar. * * @param menuitem Menu item to remove. * @see org.carewebframework.ui.infopanel.model.IInfoPanel#unregisterMenuItem(Menuitem) */ @Override public void unregisterMenuItem(Menuitem menuitem) { Component parent = menuitem.getParent(); menuitem.detach(); if (parent != null) { MenuUtil.pruneMenus(parent); menuPanel.setVisible(parent.getFirstChild() != null); } if (log.isDebugEnabled()) { log.debug("Unregistered menu item: " + menuitem); } }
private static void addToIdSpacesDown(Component comp, IdSpace owner) { if (!(comp instanceof NonFellow) && !isAutoId(comp.getId())) addFellow(comp, owner); if (!(comp instanceof IdSpace)) for (AbstractComponent ac = (AbstractComponent) comp.getFirstChild(); ac != null; ac = ac._next) addToIdSpacesDown(ac, owner); //recursive ((AbstractComponent) comp).notifyIdSpaceChanged(owner); }
private static void removeFromIdSpacesDown(Component comp, IdSpace owner) { if (!(comp instanceof NonFellow) && !isAutoId(comp.getId())) removeFellow(comp, owner); if (!(comp instanceof IdSpace)) for (AbstractComponent ac = (AbstractComponent) comp.getFirstChild(); ac != null; ac = ac._next) removeFromIdSpacesDown(ac, owner); //recursive ((AbstractComponent) comp).notifyIdSpaceChanged(null); }
private static String getIdFromChild(Component comp, String uuid) { for (Component child = comp.getFirstChild(); child != null; child = child.getNextSibling()) { if (child instanceof StubComponent) { String id = ((StubComponent) child).getId(uuid); //recursive if (id != null) return id; } else { if (uuid.equals(child.getUuid())) return id0(child.getId()); String id = getIdFromChild(child, uuid); if (id != null) return id; } } return null; }
private ComponentMatchCtx buildNextCtx() { if (_allIds) return null; // TODO: how to skip tree branches if (_currCtx.getComponent().getFirstChild() != null) return buildFirstChildCtx(_currCtx); while (_currCtx.getComponent().getNextSibling() == null) { _currCtx = _currCtx.getParent(); if(_currCtx == null || _currCtx.getComponent() == (_posOffset > 0 ? _offsetRoot : _root)) return null; // reached root } return buildNextSiblingCtx(_currCtx); }
/** Sets what buttons are allowed. */ public void setButtons(Messagebox.Button[] buttons, String[] btnLabels) { _buttons = buttons; final Component parent = getFellowIfAny("buttons"); if (parent != null && parent.getFirstChild() == null) { //Backward compatible to ZK 5 //We check if any child since user's old template might create them final String sclass = (String) parent.getAttribute("button.sclass"); for (int j = 0; j < _buttons.length; ++j) { final Button mbtn = new Button(); mbtn.setButton(_buttons[j], btnLabels != null && j < btnLabels.length ? btnLabels[j] : null); mbtn.setSclass(sclass); mbtn.setAutodisable("self"); parent.appendChild(mbtn); } } }
private void test(Component root, String eventName, int eventData, int expectedSize) { String labelText = eventName + "." + eventData; EventManager.getInstance().fireLocalEvent(eventName, labelText); assertEquals(expectedSize, root.getChildren().size()); Label label = (Label) root.getChildren().get(expectedSize - 1).getFirstChild(); assertEquals(labelText, label.getValue()); } }
parent.insertBefore(this, parent.getFirstChild()); break;
/** * Create a new status pane and associated label. * * @param pane Name of pane (becomes the id of the label). * @return The newly created label. */ private Label createLabel(String pane) { boolean first = root.getFirstChild() == null; if (!first) { root.appendChild(new Splitter()); } Cell cell = new Cell(); if (first) { cell.setHflex("1"); } else { cell.setAlign("center"); } cell.setVflex("1"); cell.setSclass("cwf-header-cell"); root.appendChild(cell); Label lbl = new Label(); lbl.setId(pane); cell.appendChild(lbl); return lbl; } }
private ComponentMatchCtx buildNextCtx() { if (_allIds) return null; // TODO: how to skip tree branches // traverse shadow element tree only when selecting shadow elements if (_lookingForShadow && _currCtx.isShadowHost()) { return buildFirstShadowChildCtx(_currCtx); } // traverse non shadow component tree if (_currCtx.getComponent().getFirstChild() != null) { return buildFirstChildCtx(_currCtx); } while (_currCtx.getComponent().getNextSibling() == null) { if (_lookingForShadow) { ShadowElement se = getNextShadowRootSibling(); if (se != null) { return buildNextShadowSiblingCtx(_currCtx, se); } } _currCtx = _currCtx.getParent(); if (_currCtx == null || _currCtx.getComponent() == (_posOffset > 0 ? _offsetRoot : _root)) return null; // reached root } return buildNextSiblingCtx(_currCtx); }
private ComponentMatchCtx buildFirstChildCtx(ComponentMatchCtx parent) { ComponentMatchCtx ctx = new ComponentMatchCtx(parent.getComponent().getFirstChild(), parent); if (_posOffset == 0) matchLevel0(ctx); for (Selector selector : _selectorList) { int i = selector.getSelectorIndex(); int posStart = _posOffset > 0 ? _posOffset - 1 : 0; for (int j = posStart; j < selector.size() - 1; j++) { switch (selector.getCombinator(j)) { case DESCENDANT: if (parent.isQualified(i, j) && checkIdSpace(selector, j + 1, ctx)) ctx.setQualified(i, j); // no break case CHILD: if (parent.isQualified(i, j) && match(selector, ctx, j + 1)) ctx.setQualified(i, j + 1); break; } } } //System.out.println(ctx); // TODO: debugger return ctx; }
private ComponentMatchCtx buildFirstChildCtx(ComponentMatchCtx parent) { ComponentMatchCtx ctx = new ComponentMatchCtx( parent.getComponent().getFirstChild(), parent); if (_posOffset == 0) matchLevel0(ctx); for (Selector selector : _selectorList) { int i = selector.getSelectorIndex(); int posStart = _posOffset > 0 ? _posOffset - 1 : 0; for (int j = posStart; j < selector.size() - 1; j++) { switch (selector.getCombinator(j)) { case DESCENDANT: if (parent.isQualified(i, j) && checkIdSpace(selector, j+1, ctx)) ctx.setQualified(i, j); // no break case CHILD: if (parent.isQualified(i, j) && match(selector, ctx, j+1)) ctx.setQualified(i, j+1); break; } } } //System.out.println(ctx); // TODO: debugger return ctx; }