Search in sources :

Example 1 with CustomEventInit

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);
    });
}
Also used : CustomEventInit(elemental2.dom.CustomEventInit)

Example 2 with CustomEventInit

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;
}
Also used : JsCommandResult(io.deephaven.web.client.api.console.JsCommandResult) LazyPromise(io.deephaven.web.client.fu.LazyPromise) CustomEventInit(elemental2.dom.CustomEventInit) JsVariableChanges(io.deephaven.web.client.api.console.JsVariableChanges)

Example 3 with CustomEventInit

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;
}
Also used : JsArray(elemental2.core.JsArray) CustomEventInit(elemental2.dom.CustomEventInit)

Example 4 with CustomEventInit

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);
    });
}
Also used : CustomEventInit(elemental2.dom.CustomEventInit)

Example 5 with CustomEventInit

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;
    });
}
Also used : CustomEventInit(elemental2.dom.CustomEventInit)

Aggregations

CustomEventInit (elemental2.dom.CustomEventInit)28 Promise (elemental2.promise.Promise)6 JsIgnore (jsinterop.annotations.JsIgnore)6 JsTable (io.deephaven.web.client.api.JsTable)4 ClientTableState (io.deephaven.web.client.state.ClientTableState)4 Map (java.util.Map)4 JsArray (elemental2.core.JsArray)3 CustomEvent (elemental2.dom.CustomEvent)3 TableMap (io.deephaven.web.client.api.TableMap)3 SubscriptionTableData (io.deephaven.web.client.api.subscription.SubscriptionTableData)3 TableSubscription (io.deephaven.web.client.api.subscription.TableSubscription)3 ViewportData (io.deephaven.web.client.api.subscription.ViewportData)3 JsLog (io.deephaven.web.client.fu.JsLog)3 HashMap (java.util.HashMap)3 JsProperty (jsinterop.annotations.JsProperty)3 JsObject (elemental2.core.JsObject)2 FigureDescriptor (io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.console_pb.FigureDescriptor)2 io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.console_pb.figuredescriptor (io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.console_pb.figuredescriptor)2 FetchObjectResponse (io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.object_pb.FetchObjectResponse)2 DateWrapper (io.deephaven.web.client.api.DateWrapper)2