use of elemental2.dom.CustomEvent in project gwtproject by treblereel.
the class ClickLinkTest method testClickLink.
/* Tests against issue #572: Double unescaping of history tokens. */
@Test(timeout = 5000)
public Promise<Void> testClickLink() {
return new Promise<>((resolve, reject) -> {
HTMLAnchorElement anchorElement = Js.cast(DomGlobal.document.createElement("a"));
anchorElement.href = "#href1";
DomGlobal.document.body.appendChild(anchorElement);
CustomEvent<String> clickEvent = new CustomEvent<>("click");
// NativeEvent clickEvent =
// DomGlobal.document.create.createEvent(0, 0, 0, 0, 0, false, false,
// false, false);
//
timer = new Timer() {
@Override
public void run() {
anchorElement.dispatchEvent(clickEvent);
}
};
try {
History.newItem("something_as_base");
addHistoryListenerImpl(event -> {
assertEquals("href1", event.getValue());
resolve.onInvoke((Void) null);
});
timer.schedule(1000);
} finally {
DomGlobal.document.body.removeChild(anchorElement);
}
});
}
use of elemental2.dom.CustomEvent in project deephaven-core by deephaven.
the class FigureSubscription method subscribe.
private Promise<TableSubscription> subscribe(final Promise<JsTable> tablePromise) {
assert currentData == null;
return tablePromise.then(table -> {
if (subscription == null) {
// do we need this?
table.close();
// noinspection unchecked
return (Promise<TableSubscription>) (Promise) Promise.reject("Already closed");
}
TableSubscription sub = table.subscribe(table.getColumns());
// TODO, technically we can probably unsubscribe to the table at this point, since we're listening to the
// subscription itself
this.currentData = new ChartData(table);
sub.addEventListener(TableSubscription.EVENT_UPDATED, e -> {
// refire with specifics for the columns that we're watching here, after updating data arrays
SubscriptionTableData.UpdateEventData subscriptionUpdateData = (SubscriptionTableData.UpdateEventData) ((CustomEvent) e).detail;
currentData.update(subscriptionUpdateData);
CustomEventInit event = CustomEventInit.create();
event.setDetail(new DataUpdateEvent(includedSeries.toArray(new JsSeries[0]), currentData, subscriptionUpdateData));
figure.fireEvent(JsFigure.EVENT_UPDATED, event);
if (!firstEventFired) {
firstEventFired = true;
if (downsampleAxisRange != null) {
CustomEventInit successInit = CustomEventInit.create();
successInit.setDetail(includedSeries.toArray());
figure.fireEvent(JsFigure.EVENT_DOWNSAMPLEFINISHED, successInit);
}
}
});
return Promise.resolve(sub);
});
}
Aggregations