}
JSOVoidCallback voidCb = new JSOVoidCallback() {
@Override
public void callback() {
UncaughtExceptionHandler handler = GWT.getUncaughtExceptionHandler();
if (handler != null) {
fireLoadCbAndCatch(handler, url, cb);
} else {
fireLoadCb(url, cb);
}
}
/**
* Does the work of actual invoking the user's callback code.
*
* @param url the URL that was passed when the load was initiated.
* @param cb the user callback to invoke.
*/
private void fireLoadCb(String url, GeoXmlLoadCallback cb) {
// TODO: If this.jsoPeer is null at this point, the outer load() call
// may not yet have executed this.setJsoPeer(). Would adding a test
// and subsequent DeferredCommand solve this?
Throwable caught = null;
GeoXmlOverlay overlay = null;
try {
if (GeoXmlOverlayImpl.impl.loadedCorrectly(storedJso)) {
overlay = new GeoXmlOverlay(storedJso);
}
} catch (Throwable e) {
caught = e;
}
if (caught == null && overlay != null) {
cb.onSuccess(url, overlay);
} else {
cb.onFailure(url, caught);
}
}
/**
* Wraps firing the callback so that an exception handler can be called.
*
* @param handler the uncaught exception handler to call
* @param url the url made in the load request
* @param cb callback to use on success/failure.
*/
private void fireLoadCbAndCatch(UncaughtExceptionHandler handler,
String url, GeoXmlLoadCallback cb) {
try {
fireLoadCb(url, cb);
} catch (Throwable e) {
handler.onUncaughtException(e);
}
}
};
JavaScriptObject outerJsoPeer = GeoXmlOverlayImpl.impl.constructGeoXmlOverlay(