use of elemental2.dom.CustomEventInit in project deephaven-core by deephaven.
the class IdeSession method mergeTables.
public Promise<JsTable> mergeTables(JsTable[] tables) {
return connection.mergeTables(tables, this).then(table -> {
final CustomEventInit event = CustomEventInit.create();
event.setDetail(table);
fireEvent(EVENT_TABLE_OPENED, event);
return Promise.resolve(table);
});
}
use of elemental2.dom.CustomEventInit in project deephaven-core by deephaven.
the class IdeSession method runCode.
public CancellablePromise<JsCommandResult> runCode(String code) {
LazyPromise<JsCommandResult> promise = new LazyPromise<>();
ExecuteCommandRequest request = new ExecuteCommandRequest();
request.setConsoleId(this.result);
request.setCode(code);
Promise<ExecuteCommandResponse> runCodePromise = Callbacks.grpcUnaryPromise(c -> {
connection.consoleServiceClient().executeCommand(request, connection.metadata(), c::apply);
});
runCodePromise.then(response -> {
JsVariableChanges changes = JsVariableChanges.from(response.getChanges());
promise.succeed(new JsCommandResult(changes, response.getErrorMessage()));
return null;
}, err -> {
promise.fail(err);
return null;
});
CancellablePromise<JsCommandResult> result = promise.asPromise(() -> {
// connection.consoleServiceClient().cancelCommand(cancelRequest, connection.metadata());
throw new UnsupportedOperationException("cancelCommand");
});
CommandInfo commandInfo = new CommandInfo(code, result);
final CustomEventInit event = CustomEventInit.create();
event.setDetail(commandInfo);
fireEvent(IdeSession.EVENT_COMMANDSTARTED, event);
return result;
}
use of elemental2.dom.CustomEventInit in project deephaven-core by deephaven.
the class IdeSession method ensureStream.
private BiDiStream<AutoCompleteRequest, AutoCompleteResponse> ensureStream() {
autocompleteStreamCloseTimeout.schedule(AUTOCOMPLETE_STREAM_TIMEOUT);
if (currentStream != null) {
return currentStream;
}
currentStream = streamFactory.get();
currentStream.onData(res -> {
LazyPromise<JsArray<io.deephaven.web.shared.ide.lsp.CompletionItem>> pendingPromise = pendingAutocompleteCalls.remove(res.getCompletionItems().getRequestId());
if (pendingPromise == null) {
return;
}
if (res.getCompletionItems().getSuccess()) {
pendingPromise.succeed(cleanupItems(res.getCompletionItems().getItemsList()));
} else {
pendingPromise.fail("Error occurred handling autocomplete on the server, probably request is out of date");
}
});
currentStream.onStatus(status -> {
if (!status.isOk()) {
CustomEventInit init = CustomEventInit.create();
init.setDetail(status.getDetails());
fireEvent(EVENT_REQUEST_FAILED, init);
pendingAutocompleteCalls.values().forEach(p -> {
p.fail("Connection error" + status.getDetails());
});
pendingAutocompleteCalls.clear();
}
});
currentStream.onEnd(status -> {
currentStream = null;
autocompleteStreamCloseTimeout.cancel();
pendingAutocompleteCalls.clear();
});
return currentStream;
}
use of elemental2.dom.CustomEventInit in project deephaven-core by deephaven.
the class IdeSession method newTable.
public Promise<JsTable> newTable(String[] columnNames, String[] types, String[][] data, String userTimeZone) {
return connection.newTable(columnNames, types, data, userTimeZone, this).then(table -> {
final CustomEventInit event = CustomEventInit.create();
event.setDetail(table);
fireEvent(EVENT_TABLE_OPENED, event);
return Promise.resolve(table);
});
}
use of elemental2.dom.CustomEventInit in project deephaven-core by deephaven.
the class IdeSession method getTable.
// TODO (deephaven-core#188): improve usage of subscriptions (w.r.t. this optional param)
public Promise<JsTable> getTable(String name, @JsOptional Boolean applyPreviewColumns) {
return getVariableDefinition(name, JsVariableChanges.TABLE).then(varDef -> {
final Promise<JsTable> table = connection.getTable(varDef, applyPreviewColumns);
final CustomEventInit event = CustomEventInit.create();
event.setDetail(table);
fireEvent(EVENT_TABLE_OPENED, event);
return table;
});
}
Aggregations