Example usage for org.apache.wicket Component getBehaviors

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

Introduction

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

Prototype

public final List<? extends Behavior> getBehaviors() 

Source Link

Document

Gets the currently coupled Behavior s as a unmodifiable list.

Usage

From source file:org.cast.cwm.data.component.AjaxDeletePersistedObjectDialogTest.java

License:Open Source License

public void cancelLinkHasProperBehavior() {
    tester.startComponentInPage(getResponseDeletingDialog());
    tester.assertComponent("dialog:dialogBorder:contentContainer:dialogBorder_body:cancelLink",
            WebMarkupContainer.class);
    Component cancel = tester.getComponentFromLastRenderedPage(
            "dialog:dialogBorder:contentContainer:dialogBorder_body:cancelLink");
    List<? extends Behavior> behaviors = cancel.getBehaviors();
    assertEquals("Should only have one behavior", 1, behaviors.size());
    // TODO - the Behavior should be replaced by an AttributeModifier for easier testing.
}

From source file:org.dcm4chee.web.common.markup.BaseForm.java

License:LGPL

public boolean componentHasNoTooltip(Component c) {
    for (IBehavior b : c.getBehaviors()) {
        if (b instanceof TooltipBehaviour)
            return false;
    }/*  www  .j a va 2 s  . co m*/
    return true;
}

From source file:org.dcm4chee.web.common.secure.ExtendedSwarmStrategy.java

License:LGPL

private boolean containsBehavior(org.apache.wicket.Component component, Class<SecurityBehavior> clazz) {

    List<IBehavior> behaviors = component.getBehaviors();
    for (IBehavior object : behaviors) {
        if (object.getClass().isAssignableFrom(clazz))
            return true;
    }/*from ww  w . java2s . c  o m*/
    return false;
}

From source file:org.dcm4chee.wizard.common.component.ExtendedForm.java

License:LGPL

public boolean componentHasNoTooltip(Component component) {
    for (Behavior behavior : component.getBehaviors())
        if (behavior instanceof TooltipBehavior)
            return false;
    return true;// ww  w . j av a  2 s  .c  om
}

From source file:org.dcm4chee.wizard.common.login.secure.ExtendedSwarmStrategy.java

License:LGPL

private boolean containsBehavior(org.apache.wicket.Component component, Class<SecurityBehavior> clazz) {

    List<? extends Behavior> behaviors = component.getBehaviors();
    for (Behavior object : behaviors) {
        if (object.getClass().isAssignableFrom(clazz))
            return true;
    }//  w ww. j  a  va2 s.c  o  m
    return false;
}

From source file:org.devproof.portal.core.module.common.model.PortalFeedbackMessagesModel.java

License:Apache License

private boolean hasValidationDisplayBehaviour(Component reporter) {
    if (reporter != null) {
        for (IBehavior behavior : reporter.getBehaviors()) {
            if (behavior instanceof ValidationDisplayBehaviour) {
                return true;
            }/* w  ww.ja  v  a  2 s.c  om*/
        }
    }
    return false;
}

From source file:org.hippoecm.frontend.behaviors.ContextMenuBehavior.java

License:Apache License

private List<IContextMenu> getMenus(final boolean visibleOnly) {
    final List<IContextMenu> menus = new LinkedList<>();
    ((MarkupContainer) getComponent()).visitChildren(new IVisitor<Component, Void>() {

        public void component(Component component, IVisit<Void> visit) {
            if (component instanceof IContextMenu) {
                if (!visibleOnly || component.isVisible()) {
                    menus.add((IContextMenu) component);
                }//from  www . j  a  v  a 2  s . c om
                visit.dontGoDeeper();
            } else if (component instanceof IContextMenuManager) {
                visit.dontGoDeeper();
            } else {
                for (Behavior behavior : component.getBehaviors()) {
                    if (behavior instanceof IContextMenu) {
                        if (!visibleOnly || component.isVisible()) {
                            menus.add((IContextMenu) behavior);
                        }
                        visit.dontGoDeeper();
                    } else if (behavior instanceof IContextMenuManager) {
                        visit.dontGoDeeper();
                    }
                }
            }
        }

    });
    return menus;
}

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

License:Apache License

@Override
protected void onRenderHead(final IHeaderResponse response) {
    if (isRendered()) {
        return;// www  .ja  va 2s .co m
    }

    final String markupId = getComponent().getMarkupId(true);

    updateAjaxSettings();

    settings.setMarkupId(markupId);

    IWireframe parentWireframe = getParentWireframe();
    if (parentWireframe != null) {
        settings.setParentId(parentWireframe.getYuiId());
    }

    //Visit child components in order to find components that contain a {@link UnitBehavior}. If another wireframe
    //or unit is encountered, stop going deeper.
    MarkupContainer cont = (MarkupContainer) getComponent();
    cont.visitChildren(new IVisitor<Component, Void>() {
        public void component(Component component, IVisit<Void> visit) {
            for (Object behavior : component.getBehaviors()) {
                if (behavior instanceof IWireframe) {
                    visit.dontGoDeeper();
                } else if (behavior instanceof UnitBehavior) {
                    String position = ((UnitBehavior) behavior).getPosition();
                    UnitSettings unit = settings.getUnit(position);
                    if (unit != null) {
                        YuiId body = unit.getBody();
                        if (body != null) {
                            body.setParentId(null);
                            body.setId(component.getMarkupId());
                        }
                    } else {
                        throw new RuntimeException("Invalid UnitBehavior position " + position);
                    }
                    visit.dontGoDeeper();
                }
            }
        }
    });

    rendered = true;

    response.render(getHeaderItem());
}

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;
            }//from w  w  w. j  a  v a2  s .  co m
        }
        parent = parent.getParent();
    }
    return null;
}

From source file:org.odlabs.wiquery.core.commons.WiQueryPluginVisitor.java

License:Open Source License

public Object component(Component component) {
    if (component.getBehaviors().contains(this.wiQueryPlugin)) {
        return Boolean.TRUE;
    }//from   w w w. ja v a  2  s.c o m
    if (component.equals(this.wiQueryPlugin)) {
        return Boolean.TRUE;
    }
    return IVisitor.CONTINUE_TRAVERSAL;
}