Example usage for com.google.gwt.event.shared UmbrellaException UmbrellaException

List of usage examples for com.google.gwt.event.shared UmbrellaException UmbrellaException

Introduction

In this page you can find the example usage for com.google.gwt.event.shared UmbrellaException UmbrellaException.

Prototype

public UmbrellaException(Set<Throwable> causes) 

Source Link

Usage

From source file:com.googlecode.mgwt.mvp.client.AnimatingActivityManager.java

License:Apache License

/**
 * {@inheritDoc}/*w  w  w  .j a va2s. c o m*/
 *
 * Deactivate the current activity, find the next one from our
 * ActivityMapper, and start it.
 * <p>
 * The current activity's widget will be hidden immediately, which can cause
 * flicker if the next activity provides its widget asynchronously. That can
 * be minimized by decent caching. Perenially slow activities might mitigate
 * this by providing a widget immediately, with some kind of "loading"
 * treatment.
 *
 * @see com.google.gwt.place.shared.PlaceChangeEvent.Handler#onPlaceChange(PlaceChangeEvent)
 */
public void onPlaceChange(PlaceChangeEvent event) {
    if (ignorePlaceChange) {
        //remember the place change event to be executed after the current one is done
        placeChangeStack.add(event);
        return;
    }

    Activity nextActivity = getNextActivity(event);
    Animation animation = getAnimation(event);

    Throwable caughtOnStop = null;
    Throwable caughtOnStart = null;

    if (nextActivity == null) {
        nextActivity = NULL_ACTIVITY;
    }

    if (currentActivity.equals(nextActivity)) {
        return;
    }

    if (startingNext) {
        // The place changed again before the new current activity showed
        // its
        // widget
        currentActivity.onCancel();
        currentActivity = NULL_ACTIVITY;
        startingNext = false;
    } else {

        /*
         * Kill off the activity's handlers, so it doesn't have to worry
         * about them accidentally firing as a side effect of its tear down
         */
        stopperedEventBus.removeHandlers();

        try {
            currentActivity.onStop();
        } catch (Throwable t) {
            caughtOnStop = t;
        } finally {
            /*
             * And kill them off again in case it was naughty and added new
             * ones during onstop
             */
            stopperedEventBus.removeHandlers();
        }
    }

    currentActivity = nextActivity;
    currentPlace = event.getNewPlace();

    if (animation != null) {
        currentIsFirst = !currentIsFirst;
    }

    startingNext = true;

    /*
     * Now start the thing. Wrap the actual display with a per-call instance
     * that protects the display from canceled or stopped activities, and
     * which maintains our startingNext state.
     */
    try {
        currentActivity.start(new ProtectedDisplay(currentActivity), stopperedEventBus);
    } catch (Throwable t) {
        caughtOnStart = t;
    }

    if (caughtOnStart != null || caughtOnStop != null) {
        Set<Throwable> causes = new LinkedHashSet<Throwable>();
        if (caughtOnStop != null) {
            causes.add(caughtOnStop);
        }
        if (caughtOnStart != null) {
            causes.add(caughtOnStart);
        }

        throw new UmbrellaException(causes);
    }

    // animate
    animate(animation);
}

From source file:erd.client.sun.awt.ComponentEventBus.java

License:Apache License

public <H> void doFire(Event<H> event, Object source) {
    if (event == null) {
        throw new NullPointerException("Cannot fire null event");
    }//ww w .j a  v a 2 s  . c  om
    try {
        firingDepth++;

        if (source != null) {
            setSourceOfEvent(event, source);
        }

        List<H> handlers = getDispatchList(event.getAssociatedType(), source);
        Set<Throwable> causes = null;

        ListIterator<H> it = isReverseOrder ? handlers.listIterator(handlers.size()) : handlers.listIterator();
        while (isReverseOrder ? it.hasPrevious() : it.hasNext()) {
            H handler = isReverseOrder ? it.previous() : it.next();

            try {
                dispatchEvent(event, handler);
            } catch (Throwable e) {
                if (causes == null) {
                    causes = new HashSet<Throwable>();
                }
                causes.add(e);
            }
        }

        if (causes != null) {
            throw new UmbrellaException(causes);
        }
    } finally {
        firingDepth--;
        if (firingDepth == 0) {
            handleQueuedAddsAndRemoves();
        }
    }
}

From source file:org.thechiselgroup.biomixer.client.core.util.event.PrioritizedHandlerManager.java

License:Apache License

public void fireEvent(GwtEvent<?> event) {
    assert event != null;

    Set<Throwable> causes = null;

    causes = doFire(firstPriorityHandlers, event, causes);
    causes = doFire(normalPriorityHandlers, event, causes);
    causes = doFire(lastPriorityHandlers, event, causes);

    if (causes != null) {
        throw new UmbrellaException(causes);
    }//from  w  ww  . j  a  v a  2  s.  co  m
}