private static void findTag(Class<? extends Component> tag, List<Component> result, MarkupContainer c) { Iterator<Component> it = c.iterator(); while (it.hasNext()) { findInComponent(tag, result, it.next()); } }
public static Optional<String> findId(MarkupContainer container, String leafName) { Iterator<Component> it = container.iterator(); while (it.hasNext()) { Optional<String> found = findInComponent(leafName, it.next()); if (found.isPresent()) { return found; } } return Optional.empty(); }
private void findNext() { next = null; if (cells != null && cells.hasNext()) { next = (Item)cells.next(); } else { while (rows.hasNext()) { MarkupContainer row = (MarkupContainer)rows.next(); cells = ((MarkupContainer)row.iterator().next()).iterator(); if (cells.hasNext()) { next = (Item)cells.next(); break; } } } }
private NamespacePanel findNamespacePanel(MarkupContainer c) { Component child; for (Iterator<? extends Component> it = ((MarkupContainer) c).iterator(); it.hasNext(); ) { child = it.next(); if (child instanceof NamespacePanel) { return (NamespacePanel) child; } else if (child instanceof MarkupContainer) { NamespacePanel panel = findNamespacePanel((MarkupContainer) child); if (panel != null) { return panel; } } } return null; }
private void findNext() { next = null; if (cells != null && cells.hasNext()) { next = cells.next(); } else { while (rows.hasNext()) { MarkupContainer row = rows.next(); final Iterator<? extends Component> rawCells; rawCells = ((MarkupContainer) row.iterator().next()).iterator(); cells = Generics.iterator(rawCells); if (cells.hasNext()) { next = cells.next(); break; } } } }
@SuppressWarnings("unchecked") private NamespacePanel findNamespacePanel(MarkupContainer c) { Component child; for (Iterator<? extends Component> it = ((MarkupContainer) c).iterator(); it.hasNext();) { child = it.next(); if (child instanceof NamespacePanel) { return (NamespacePanel) child; } else if (child instanceof MarkupContainer) { NamespacePanel panel = findNamespacePanel((MarkupContainer) child); if (panel != null) { return panel; } } } return null; }
private void findNext() { next = null; if (cells != null && cells.hasNext()) { next = cells.next(); } else { while (rows.hasNext()) { MarkupContainer row = rows.next(); final Iterator<? extends Component> rawCells; rawCells = ((MarkupContainer)row.iterator().next()).iterator(); cells = Generics.iterator(rawCells); if (cells.hasNext()) { next = cells.next(); break; } } } }
private void findNext() { next = null; if (cells != null && cells.hasNext()) { next = cells.next(); } else { while (rows.hasNext()) { MarkupContainer row = rows.next(); final Iterator<? extends Component> rawCells; rawCells = ((MarkupContainer)row.iterator().next()).iterator(); cells = Generics.iterator(rawCells); if (cells.hasNext()) { next = cells.next(); break; } } } }
class AutoHidingBehavior extends AbstractBehavior { @Override public void bind(Component component) { if (! (component instanceof MarkupContainer) ) { throw new IllegalArgumentException("This behavior can only be used with markup containers"); } } @Override public void onConfigure(Component component) { MarkupContainer container = (MarkupContainer) component; boolean hasVisibleChildren = false; for (Iterator<? extends Component> iter = container.iterator(); iter.hasNext(); ) { if ( iter.next().isVisible() ) { hasVisibleChildren = true; break; } } container.setVisible(hasVisibleChildren); } }
private void findNext() { next = null; if (cells != null && cells.hasNext()) { next = cells.next(); } else { while (rows.hasNext()) { MarkupContainer row = rows.next(); final Iterator<? extends Component> rawCells; rawCells = ((MarkupContainer)row.iterator().next()).iterator(); cells = Generics.iterator(rawCells); if (cells.hasNext()) { next = cells.next(); break; } } } }
/** Walks down the containment hierarchy depth first and prints each component found */ private void walkHierarchy(Component c, int level) { printComponent(c, level); if (c instanceof MarkupContainer) { MarkupContainer mc = (MarkupContainer) c; for (Iterator<?> it = mc.iterator(); it.hasNext(); ) { walkHierarchy((Component) it.next(), level + 1); } } }
/** * Walks down the containment hierarchy depth first and prints each component found */ private void walkHierarchy(Component c, int level) { printComponent(c, level); if (c instanceof MarkupContainer) { MarkupContainer mc = (MarkupContainer) c; for (Iterator it = mc.iterator(); it.hasNext();) { walkHierarchy((Component) it.next(), level + 1); } } }
@SuppressWarnings("unchecked") private List<TextField<BigDecimal>> findFields(Form form) { List<TextField<BigDecimal>> fields = Lists.newArrayList(); MarkupContainer container = (MarkupContainer) form.get("shares"); for (Iterator<? extends Component> it = container.iterator(); it.hasNext();) { MarkupContainer c = (MarkupContainer) it.next(); fields.add((TextField<BigDecimal>) c.get("share")); } return fields; }
void onAfterRenderChildren() { // Loop through child components final Iterator iter = iterator(); while (iter.hasNext()) { // Get next child final Component child = (Component)iter.next(); // Call end request on the child child.afterRender(); } super.onAfterRenderChildren(); }
/** * Returns existing tag components on page. * * @return */ private Set<String> getExistingComponents() { Set<String> result = new HashSet<String>(); Iterator<? extends Component> i = ((MarkupContainer) component).iterator(); while (i.hasNext()) { Component c = i.next(); if (c.getId().startsWith(COMPONENT_PREFIX)) { result.add(c.getId()); } } return result; }
/** * * @see org.apache.wicket.Component#onAfterRenderChildren() */ @Override protected void onAfterRenderChildren() { // Loop through child components final Iterator<? extends Component> iter = iterator(); while (iter.hasNext()) { // Get next child final Component child = iter.next(); // Call end request on the child child.afterRender(); } super.onAfterRenderChildren(); }
/** * Searches for the controlling child component looking also * through transparent components. * * @param container * the current container * @return the controlling child component, null if no one is found */ private Component resolveChild(MarkupContainer container) { Component childController = container.get(childId); Iterator<Component> children = container.iterator(); while (children.hasNext() && childController == null) { Component transparentChild = children.next(); if(transparentChild instanceof TransparentWebMarkupContainer) { childController = resolveChild((MarkupContainer)transparentChild); } } return childController; }
/** * Searches for the controlling child component looking also * through transparent components. * * @param container * the current container * @return the controlling child component, null if no one is found */ private Component resolveChild(MarkupContainer container) { Component childController = container.get(childId); Iterator<Component> children = container.iterator(); while (children.hasNext() && childController == null) { Component transparentChild = children.next(); if(transparentChild instanceof TransparentWebMarkupContainer) { childController = resolveChild((MarkupContainer)transparentChild); } } return childController; }
/** * TODO Post 1.2 General: Maybe we should re-think how Borders are implemented, because there * are just too many exceptions in the code base because of borders. This time it is to solve * the problem tested in BoxBorderTestPage_3 where the Form is defined in the box border and the * FormComponents are in the "body". Thus, the formComponents are not children of the form. They * are rather children of the border, as the Form itself. * * @param visitor * The {@link Component}.{@link IVisitor} used to visit the children. */ private void visitChildrenInContainingBorder(final FormComponent.IVisitor visitor) { if (getParent() instanceof Border) { MarkupContainer border = getParent(); Iterator<? extends Component> iter = border.iterator(); while (iter.hasNext()) { Component child = iter.next(); if (child instanceof FormComponent) { visitor.formComponent((FormComponent<?>)child); } } } }
/** * TODO Post 1.2 General: Maybe we should re-think how Borders are implemented, because there * are just too many exceptions in the code base because of borders. This time it is to solve * the problem tested in BoxBorderTestPage_3 where the Form is defined in the box border and the * FormComponents are in the "body". Thus, the formComponents are not children of the form. They * are rather children of the border, as the Form itself. * * @param visitor * The {@link Component}.{@link IVisitor} used to visit the children. */ private void visitChildrenInContainingBorder(final FormComponent.IVisitor visitor) { if (getParent() instanceof Border) { MarkupContainer border = getParent(); Iterator iter = border.iterator(); while (iter.hasNext()) { Component child = (Component)iter.next(); if (child instanceof FormComponent) { visitor.formComponent((FormComponent)child); } } } }