Example usage for org.apache.wicket.markup.html WebMarkupContainer visitChildren

List of usage examples for org.apache.wicket.markup.html WebMarkupContainer visitChildren

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html WebMarkupContainer visitChildren.

Prototype

public final <R> R visitChildren(final IVisitor<Component, R> visitor) 

Source Link

Document

Traverses all child components in this container, calling the visitor's visit method at each one.

Usage

From source file:com.evolveum.midpoint.web.component.assignment.AssignmentEditorPanel.java

License:Apache License

private void addAjaxOnUpdateBehavior(WebMarkupContainer container) {
    container.visitChildren(new IVisitor<Component, Object>() {
        @Override//from  w w  w . java2  s . c  o  m
        public void component(Component component, IVisit<Object> objectIVisit) {
            if (component instanceof InputPanel) {
                addAjaxOnBlurUpdateBehaviorToComponent(((InputPanel) component).getBaseFormComponent());
            } else if (component instanceof FormComponent) {
                addAjaxOnBlurUpdateBehaviorToComponent(component);
            }
        }
    });
}

From source file:com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn.java

License:Apache License

public static CheckBoxPanel findCheckBoxColumnHeader(DataTable table) {
    WebMarkupContainer topToolbars = table.getTopToolbars();
    ComponentHierarchyIterator iterator = topToolbars.visitChildren(TableHeadersToolbar.class);
    if (!iterator.hasNext()) {
        return null;
    }/*from w  w w .  j  a v  a 2  s.  com*/

    TableHeadersToolbar toolbar = (TableHeadersToolbar) iterator.next();
    // simple attempt to find checkbox which is header for our column
    // todo: this search will fail if there are more checkbox header columns (which is not supported now,
    // because Selectable.F_SELECTED is hardcoded all over the place...
    iterator = toolbar.visitChildren(CheckBoxPanel.class);
    while (iterator.hasNext()) {
        Component c = iterator.next();
        if (!c.getOutputMarkupId()) {
            continue;
        }

        return (CheckBoxPanel) c;
    }

    return null;
}

From source file:org.geoserver.web.netcdf.GHRSSTExtensionPanel.java

License:Open Source License

public GHRSSTExtensionPanel(String id, IModel<?> model, NetCDFPanel parent) {
    super(id, model);
    this.parent = parent;

    PropertyModel<MetadataMap> metadataModel = new PropertyModel<>(model, "metadata");
    enabled = new CheckBox("enabled",
            new MetadataMapModel<>(metadataModel, GHRSSTEncoder.SETTINGS_KEY, Boolean.class));
    add(enabled);//  w w w . ja va 2  s.co m

    WebMarkupContainer settings = new WebMarkupContainer("settings");
    settings.setOutputMarkupId(true);
    add(settings);
    this.rdac = getAutocompleter("rdac",
            new MetadataMapModel<>(metadataModel, GHRSSTEncoder.SETTINGS_RDAC_KEY, String.class), RDACS);
    rdac.setRequired(true);
    settings.add(rdac);
    this.processingLevel = getAutocompleter("processingLevel",
            new MetadataMapModel<>(metadataModel, GHRSSTEncoder.SETTINGS_PROCESSING_LEVEL_KEY, String.class),
            PROCESSING_LEVELS);
    processingLevel.setRequired(true);
    settings.add(processingLevel);
    this.sstType = getAutocompleter("sstType",
            new MetadataMapModel<>(metadataModel, GHRSSTEncoder.SETTINGS_SST_TYPE, String.class), SST_TYPES);
    sstType.setRequired(true);
    settings.add(sstType);
    this.productString = getAutocompleter("productString",
            new MetadataMapModel<>(metadataModel, GHRSSTEncoder.SETTINGS_PRODUCT_STRING, String.class),
            PRODUCT_STRINGS);
    productString.setRequired(true);
    settings.add(productString);

    // enable/disable on open 
    settings.visitChildren((component, visit) -> {
        component.setEnabled(Boolean.TRUE.equals(enabled.getModelObject()));
    });

    enabled.add(new AjaxEventBehavior("change") {
        @Override
        protected void onEvent(AjaxRequestTarget target) {
            enabled.processInput();
            boolean enableSettings = Boolean.TRUE.equals(enabled.getModelObject());
            settings.visitChildren((component, visit) -> {
                component.setEnabled(enableSettings);
            });
            target.add(settings);
        }
    });
}

From source file:org.obiba.onyx.quartz.test.ComponentTesterUtils.java

License:Open Source License

/**
 * Find the first child of given class, and with model equals to the given model.
 * @param parent//from w  w  w. j  av a  2  s .co  m
 * @param clazz
 * @param model
 * @return
 */
public static Component findChild(WebMarkupContainer parent, final Class clazz, final IModel model) {
    if (parent == null) {
        throw new IllegalArgumentException("parent cannot be null.");
    }

    return (Component) parent.visitChildren(new Component.IVisitor() {

        public Object component(Component component) {
            if (clazz.isAssignableFrom(component.getClass()) && component.getDefaultModel().equals(model)) {
                log.debug("child.path: {}", component.getPath());
                return component;
            }
            return CONTINUE_TRAVERSAL;
        }

    });

}

From source file:org.obiba.onyx.quartz.test.ComponentTesterUtils.java

License:Open Source License

/**
 * Find the first child of given class, and with model object equals to the given localizable.
 * @param parent/*from  w w  w  .ja v  a 2 s  .co m*/
 * @param clazz
 * @param localizable
 * @return
 */
public static Component findChild(WebMarkupContainer parent, final Class clazz,
        final IQuestionnaireElement localizable) {
    if (parent == null) {
        throw new IllegalArgumentException("parent cannot be null.");
    }

    return (Component) parent.visitChildren(new Component.IVisitor() {

        public Object component(Component component) {
            if (clazz.isAssignableFrom(component.getClass())) {
                if (component.getDefaultModelObject() != null
                        && localizable.getClass().isAssignableFrom(component.getDefaultModelObject().getClass())
                        && localizable.getName().equals(
                                ((IQuestionnaireElement) component.getDefaultModelObject()).getName())) {
                    log.debug("child.{}.path: {}", localizable.getName(), component.getPath());
                    return component;
                }
            }
            return CONTINUE_TRAVERSAL;
        }

    });

}

From source file:org.obiba.onyx.quartz.test.ComponentTesterUtils.java

License:Open Source License

/**
 * Get all children of the given class.//from   w w w .  j av a  2 s .  c o  m
 * @param parent
 * @param clazz
 * @return
 */
public static List<Component> findChildren(WebMarkupContainer parent, final Class clazz) {
    if (parent == null) {
        throw new IllegalArgumentException("parent cannot be null.");
    }

    final List<Component> children = new ArrayList<Component>();

    parent.visitChildren(new Component.IVisitor() {

        public Object component(Component component) {
            if (clazz.isAssignableFrom(component.getClass())) {
                log.debug("children.path: {}", component.getPath());
                children.add(component);
                return CONTINUE_TRAVERSAL;
            }
            return CONTINUE_TRAVERSAL;
        }

    });

    return children;
}