Example usage for org.apache.wicket Component getParent

List of usage examples for org.apache.wicket Component getParent

Introduction

In this page you can find the example usage for org.apache.wicket Component getParent.

Prototype

@Override
public final MarkupContainer getParent() 

Source Link

Document

Gets any parent container, or null if there is none.

Usage

From source file:org.devgateway.eudevfin.ui.common.events.MarkersField13UpdateBehavior.java

License:Open Source License

@Override
protected void onEventExtra(Component component, IEvent<?> event) {
    if (!component.getParent().getParent().getParent().getParent().isVisibleInHierarchy())
        return;//from w w  w .j  a  v a  2 s.c o  m
    Field13ChangedEventPayload eventPayload = getEventPayload(event);
    if (pattern.matcher(eventPayload.getField13Code()).matches()) {
        component.setEnabled(false);
        component.setDefaultModelObject(null);
    }

    else
        component.setEnabled(true);
}

From source file:org.geoserver.web.GeoServerStringResourceLoader.java

License:Open Source License

/**
 * Traverse the component hierarchy up to the Page and add each component class to the list
 * (stack) returned/*from   w  w  w.ja  va  2 s  . co m*/
 * 
 * @param component
 *            The component to evaluate
 * @return The stack of classes
 */
private List getComponentStack(final Component component) {
    // Build the search stack
    final List searchStack = new ArrayList();
    searchStack.add(component.getClass());

    if (!(component instanceof Page)) {
        // Add all the component on the way to the Page
        MarkupContainer container = component.getParent();
        while (container != null) {
            searchStack.add(container.getClass());
            if (container instanceof Page) {
                break;
            }

            container = container.getParent();
        }
    }
    return searchStack;
}

From source file:org.hippoecm.frontend.plugins.cms.browse.SectionViewer.java

License:Apache License

@Override
public boolean isActive(Component component) {
    if (isActive()) {
        final IBrowserSection active = sections.getActiveSection();
        if (active != null) {
            Component focusedComponent = active.getComponent();
            while (component != this) {
                if (component == focusedComponent) {
                    return true;
                }//from  ww  w.j  a  v a 2 s.c o  m
                component = component.getParent();
            }
        } else {
            return true;
        }
    }
    return false;
}

From source file:org.hippoecm.frontend.plugins.yui.layout.WireframeBehavior.java

License:Apache License

@Override
public boolean isRendered() {
    AjaxRequestTarget target = RequestCycle.get().find(AjaxRequestTarget.class);
    if (target != null) {
        Component parent = getComponent();
        while (parent != null && !target.getComponents().contains(parent)) {
            parent = parent.getParent();
        }/*from  w  w  w . ja v  a2 s .com*/
        if (parent != null) {
            return false;
        }
    } else {
        return false;
    }
    return rendered;
}

From source file:org.hippoecm.frontend.plugins.yui.layout.WireframeUtils.java

License:Apache License

public static IWireframe getParentWireframe(Component component) {
    //If linkedWithParent, look for an ancestor Component that implements IWireframeService and retrieve it's id
    Component parent = component.getParent();
    while (parent != null) {
        for (Object parentBehavior : parent.getBehaviors()) {
            if (parentBehavior instanceof IWireframe) {
                return (IWireframe) parentBehavior;
            }//w w  w  . ja v  a  2 s  . c o  m
        }
        parent = parent.getParent();
    }
    return null;
}

From source file:org.hippoecm.frontend.session.PluginUserSession.java

License:Apache License

public Object getMarkupId(Component component) {
    String markupId = null;/*from  w w  w . j  av a  2  s. c  om*/
    for (Component ancestor = component.getParent(); ancestor != null; ancestor = ancestor.getParent()) {
        if (ancestor instanceof IPlugin || ancestor instanceof Home) {
            markupId = ancestor.getMarkupId(true);
            break;
        }
    }
    if (markupId == null) {
        return "root";
    }
    int componentNum = 0;
    if (pluginComponentCounters.containsKey(markupId)) {
        componentNum = pluginComponentCounters.get(markupId);
    }
    ++componentNum;
    pluginComponentCounters.put(markupId, componentNum);
    return markupId + "_" + componentNum;
}

From source file:org.jaulp.wicket.base.util.ComponentFinder.java

License:Apache License

/**
 * Finds the first parent of the given childComponent from the given parentClass.
 *
 * @param childComponent/*ww  w  .  j  av  a 2s  .  c  om*/
 *            the child component
 * @param parentClass
 *            the parent class
 * @return the component
 */
public static Component findParent(Component childComponent, Class<? extends Component> parentClass) {
    Component parent = childComponent.getParent();
    while (parent != null) {
        if (parent.getClass().equals(parentClass)) {
            break;
        }
        parent = parent.getParent();
    }
    return parent;
}

From source file:org.obiba.onyx.wicket.toggle.ToggleLink.java

License:Open Source License

/**
 * Constructor./*  w  w  w  .j  a  v a  2  s .c  om*/
 * @param id
 * @param showModel
 * @param hideModel
 * @param toggle
 */
@SuppressWarnings("serial")
public ToggleLink(String id, final IModel showModel, final IModel hideModel, final Component toggle) {
    super(id);
    setOutputMarkupId(true);
    toggle.getParent().setOutputMarkupId(true);

    AjaxLink link = new AjaxLink("link") {

        @Override
        public void onClick(AjaxRequestTarget target) {
            toggle.setVisible(!toggle.isVisible());
            if (toggle.isVisible()) {
                toggleLabel.setDefaultModel(hideModel);
            } else {
                toggleLabel.setDefaultModel(showModel);
            }
            target.addComponent(toggle.getParent());
        }

    };
    add(link);

    link.add(toggleLabel = new Label("label", showModel));
    toggle.setVisible(false);
}

From source file:org.obiba.onyx.wicket.wizard.WizardForm.java

License:Open Source License

@SuppressWarnings("unchecked")
public HistoryAjaxBehavior getHistoryAjaxBehavior() {
    // Start here
    Component current = getParent();

    // Walk up containment hierarchy
    while (current != null) {
        // Is current an instance of this class?
        if (IHistoryAjaxBehaviorOwner.class.isInstance(current)) {
            return ((IHistoryAjaxBehaviorOwner) current).getHistoryAjaxBehavior();
        }/*from  ww  w .j  a  v  a 2 s .  com*/

        // Check parent
        current = current.getParent();
    }
    return null;
}

From source file:org.onehippo.forge.settings.management.config.brokenlinks.BrokenLinksCheckerConfigPanel.java

License:Apache License

private AjaxFormComponentUpdatingBehavior createSimpleAjaxChangeBehavior(final Component... components) {
    return new AjaxFormComponentUpdatingBehavior("onchange") {
        private static final long serialVersionUID = 1L;

        @Override//www.java  2s .  com
        protected void onUpdate(AjaxRequestTarget target) {
            if (components != null) {
                for (final Component component : components) {
                    target.add(component);
                    Component reset = component.getParent().get(component.getId() + "-reset-container");
                    if (reset != null) {
                        target.add(reset);
                    }
                }
            }
        }
    };
}