Example usage for org.apache.wicket MarkupContainer iterator

List of usage examples for org.apache.wicket MarkupContainer iterator

Introduction

In this page you can find the example usage for org.apache.wicket MarkupContainer iterator.

Prototype

@Override
public Iterator<Component> iterator() 

Source Link

Document

Gives an iterator that allow you to iterate through the children of this markup container in the order the children were added.

Usage

From source file:com.googlecode.londonwicket.ComponentExpression.java

License:Apache License

private static List<Component> getAllChildren(MarkupContainer parent) {
    List<Component> children = new ArrayList<Component>();
    Iterator<? extends Component> iter = parent.iterator();
    while (iter.hasNext()) {
        children.add(iter.next());/* w w  w. jav  a2  s  . c om*/
    }
    return children;
}

From source file:com.servoy.j2db.server.headlessclient.WebForm.java

License:Open Source License

private Component getDefaultFirstComponent(MarkupContainer currentContainer) {
    Iterator<?> it = currentContainer.iterator();
    while (it.hasNext()) {
        Object o = it.next();/*  www. ja  v a  2  s. co m*/
        if (o instanceof MarkupContainer) {
            Component c = getDefaultFirstComponent((MarkupContainer) o);
            if (c != null)
                return c;
        } else if (o instanceof Component && o instanceof IFieldComponent) {
            return (Component) o;
        }
    }
    return null;
}

From source file:de.alpharogroup.wicket.component.search.ComponentExpression.java

License:Apache License

/**
 * Search for all child {@link org.apache.wicket.Component}s from the given parent.
 * /* w  w  w . ja  va  2 s.  c o m*/
 * @param parent
 *            The parent
 * @return all child {@link org.apache.wicket.Component}s from the given parent.
 */
private static List<Component> getAllChildren(MarkupContainer parent) {
    List<Component> children = new ArrayList<Component>();
    Iterator<? extends Component> iter = parent.iterator();
    while (iter.hasNext()) {
        children.add(iter.next());
    }
    return children;
}

From source file:fiftyfive.wicket.css.IterationCssBehavior.java

License:Apache License

/**
 * Assume that the component has an immediate parent of {@link ListView}, {@link Loop}, or
 * {@link RepeatingView} and use what we know about those implementations to infer the
 * size of the list that is being iterated. Note that in the case of pagination, this is the
 * size of the visible items (i.e the current page), not the total size that includes other
 * pages./* ww w. ja  va2 s .  co m*/
 * 
 * @throws UnsupportedOperationException if the parent component is not one of the three
 *                                       supported types
 */
protected int getSize(Component component) {
    MarkupContainer parent = component.getParent();

    if (parent instanceof ListView) {
        return ((ListView) parent).getViewSize();
    }
    if (parent instanceof Loop) {
        return ((Loop) parent).getIterations();
    }
    if (parent instanceof RepeatingView) {
        // TODO: more efficent way?
        int size = 0;
        Iterator iter = parent.iterator();
        while (iter.hasNext()) {
            iter.next();
            size++;
        }
        return size;
    }

    throw new IllegalStateException(String.format(
            "Don't know how to find the size of the repeater that contains component " + "%s (%s). "
                    + "Only list.ListItem, list.LoopItem and repeater.Item are supported. "
                    + "Perhaps you attached IterationCssBehavior to the wrong component?",
            component.getPath(), component.getClass()));
}

From source file:jdave.wicket.ComponentSpecification.java

License:Apache License

/**
 * Specify that given container contains given model objects.
 * <p>/*from  w w  w  .j av a 2  s . c om*/
 * This is most often used with <code>RefreshingViews</code> and
 * <code>ListViews</code>.
 * 
 * <pre>
 * &lt;blockquote&gt;&lt;code&gt;
 * ListView list = new ListView(&quot;stooges&quot;, Arrays.asList(&quot;Larry&quot;, &quot;Moe&quot;, &quot;Curly&quot;)) { ... };
 * specify(list, containsInOrder(&quot;Larry&quot;, &quot;Moe&quot;, &quot;Curly&quot;);
 * &lt;code&gt;&lt;/blockquote&gt;
 * </pre>
 * 
 * @param actual the container of Wicket components
 * @param containment any containment, see:
 *            http://www.jdave.org/documentation.html#containments
 */
public <T> void specify(final MarkupContainer actual, final IContainment<T> containment) {
    super.specify(modelObjects(actual.iterator()), containment);
}

From source file:org.eknet.wicket.commons.components.navlist.ListItemWrapper.java

License:Apache License

private boolean isChildVisible(Component component) {
    if (component instanceof MarkupContainer) {
        MarkupContainer container = (MarkupContainer) component;
        Iterator<Component> iter = container.iterator();
        if (iter.hasNext()) {
            Component child = iter.next();
            return child.isVisible() && child.isActionAuthorized(Component.RENDER);
        }//from w w w . j  a v  a 2  s . co  m
    }
    return true;
}

From source file:org.geoserver.security.web.AbstractListPageTest.java

License:Open Source License

protected Component getFromList(String columnPath, Object columnValue, Property<T> property) {
    MarkupContainer listView = (MarkupContainer) tester.getLastRenderedPage().get(ITEMS_PATH);

    @SuppressWarnings("unchecked")
    Iterator<MarkupContainer> it = (Iterator<MarkupContainer>) listView.iterator();

    while (it.hasNext()) {
        MarkupContainer m = it.next();//from  w w  w .  j  av a2  s . co  m
        Component c = m.get(columnPath);
        @SuppressWarnings("unchecked")
        T modelObject = (T) c.getDefaultModelObject();
        if (columnValue.equals(property.getPropertyValue(modelObject)))
            return c;
    }
    return null;
}

From source file:org.geoserver.security.web.AbstractTabbedListPageTest.java

License:Open Source License

protected Component getFromList(String columnPath, Object columnValue, Property<T> property) {

    MarkupContainer listView = (MarkupContainer) tester.getLastRenderedPage().get(getItemsPath());

    @SuppressWarnings("unchecked")
    Iterator<MarkupContainer> it = (Iterator<MarkupContainer>) listView.iterator();

    while (it.hasNext()) {
        MarkupContainer m = it.next();/*from w w  w.  j a va  2 s  . c o  m*/
        Component c = m.get(columnPath);
        @SuppressWarnings("unchecked")
        T modelObject = (T) c.getDefaultModelObject();
        if (columnValue.equals(property.getPropertyValue(modelObject)))
            return c;
    }
    return null;
}

From source file:org.geoserver.web.wicket.WicketHierarchyPrinter.java

License:Open Source License

/**
 * Walks down the containment hierarchy depth first and prints each component found
 *//*from ww  w . j  a va2  s.c om*/
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);
        }
    }
}