Search in sources :

Example 1 with IEventSink

use of org.apache.wicket.event.IEventSink in project wicket by apache.

the class ComponentEventSender method bubble.

/**
 * Bubbles the event
 *
 * @param event
 *            event
 */
private void bubble(ComponentEvent<?> event) {
    IEventSink sink = event.getSink();
    boolean targetsComponent = sink instanceof Component;
    boolean targetsCycle = targetsComponent || sink instanceof RequestCycle;
    boolean targetsSession = targetsCycle || sink instanceof Session;
    boolean targetsApplication = targetsSession || sink instanceof Application;
    if (!targetsApplication && !targetsComponent) {
        dispatcher.dispatchEvent(sink, event, null);
        return;
    }
    if (targetsComponent) {
        Component cursor = (Component) sink;
        dispatchToComponent(dispatcher, cursor, event);
        if (event.isStop()) {
            return;
        }
        cursor.visitParents(MarkupContainer.class, new ComponentEventVisitor(event, dispatcher));
    }
    if (event.isStop()) {
        return;
    }
    if (targetsCycle) {
        dispatcher.dispatchEvent(source.getRequestCycle(), event, null);
    }
    if (event.isStop()) {
        return;
    }
    if (targetsSession) {
        dispatcher.dispatchEvent(source.getSession(), event, null);
    }
    if (event.isStop()) {
        return;
    }
    if (targetsApplication) {
        dispatcher.dispatchEvent(source.getApplication(), event, null);
    }
}
Also used : IEventSink(org.apache.wicket.event.IEventSink) RequestCycle(org.apache.wicket.request.cycle.RequestCycle)

Example 2 with IEventSink

use of org.apache.wicket.event.IEventSink in project wicket by apache.

the class ComponentEventSender method depth.

/**
 * Depth broadcast
 *
 * @param event
 *            event
 */
private void depth(final ComponentEvent<?> event) {
    IEventSink sink = event.getSink();
    boolean targetsApplication = sink instanceof Application;
    boolean targetsSession = targetsApplication || sink instanceof Session;
    boolean targetsCycle = targetsSession || sink instanceof RequestCycle;
    boolean targetsComponent = sink instanceof Component;
    if (!targetsComponent && !targetsCycle) {
        dispatcher.dispatchEvent(sink, event, null);
        return;
    }
    Component cursor = (targetsCycle) ? source.getPage() : (Component) sink;
    if (cursor instanceof MarkupContainer) {
        Visits.visitPostOrder(cursor, new ComponentEventVisitor(event, dispatcher));
    } else {
        dispatchToComponent(dispatcher, cursor, event);
    }
    if (event.isStop()) {
        return;
    }
    if (targetsCycle) {
        dispatcher.dispatchEvent(source.getRequestCycle(), event, null);
    }
    if (event.isStop()) {
        return;
    }
    if (targetsSession) {
        dispatcher.dispatchEvent(source.getSession(), event, null);
    }
    if (event.isStop()) {
        return;
    }
    if (targetsApplication) {
        dispatcher.dispatchEvent(source.getApplication(), event, null);
    }
}
Also used : IEventSink(org.apache.wicket.event.IEventSink) RequestCycle(org.apache.wicket.request.cycle.RequestCycle)

Example 3 with IEventSink

use of org.apache.wicket.event.IEventSink in project wicket by apache.

the class ComponentEventSender method breadth.

/**
 * Breadth broadcast
 *
 * @param event
 */
private void breadth(final ComponentEvent<?> event) {
    IEventSink sink = event.getSink();
    boolean targetsApplication = sink instanceof Application;
    boolean targetsSession = targetsApplication || sink instanceof Session;
    boolean targetsCycle = targetsSession || sink instanceof RequestCycle;
    boolean targetsComponent = sink instanceof Component;
    if (!targetsComponent && !targetsCycle) {
        dispatcher.dispatchEvent(sink, event, null);
        return;
    }
    if (targetsApplication) {
        dispatcher.dispatchEvent(source.getApplication(), event, null);
    }
    if (event.isStop()) {
        return;
    }
    if (targetsSession) {
        dispatcher.dispatchEvent(source.getSession(), event, null);
    }
    if (event.isStop()) {
        return;
    }
    if (targetsCycle) {
        dispatcher.dispatchEvent(source.getRequestCycle(), event, null);
    }
    if (event.isStop()) {
        return;
    }
    Component cursor = targetsCycle ? source.getPage() : (Component) sink;
    dispatchToComponent(dispatcher, cursor, event);
    if (event.isStop()) {
        return;
    }
    // reset shallow flag
    event.resetShallow();
    if (cursor instanceof MarkupContainer) {
        ((MarkupContainer) cursor).visitChildren(new ComponentEventVisitor(event, dispatcher));
    }
}
Also used : IEventSink(org.apache.wicket.event.IEventSink) RequestCycle(org.apache.wicket.request.cycle.RequestCycle)

Aggregations

IEventSink (org.apache.wicket.event.IEventSink)3 RequestCycle (org.apache.wicket.request.cycle.RequestCycle)3