mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-17 01:25:36 -05:00
Inital platform relayering (#6385)
* moving test files and inital refactoring * relayer extension host code * fix imports * make insights work * relayer dashboard * relayer notebooks * moveing more code around * formatting * accept angular as browser * fix serializer * add missing files * remove declarations from extensions * fix build errors * more relayering * change urls to relative to help code relayering * remove layering to prep for merge * fix hygiene errors * fix hygiene errors * fix tests
This commit is contained in:
@@ -1,167 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import { Disposable } from 'vs/workbench/api/common/extHostTypes';
|
||||
import {
|
||||
ExtHostAccountManagementShape,
|
||||
MainThreadAccountManagementShape,
|
||||
SqlMainContext,
|
||||
} from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
import { AzureResource } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { IMainContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
|
||||
export class ExtHostAccountManagement extends ExtHostAccountManagementShape {
|
||||
private _handlePool: number = 0;
|
||||
private _proxy: MainThreadAccountManagementShape;
|
||||
private _providers: { [handle: number]: AccountProviderWithMetadata } = {};
|
||||
private _accounts: { [handle: number]: azdata.Account[] } = {};
|
||||
private readonly _onDidChangeAccounts = new Emitter<azdata.DidChangeAccountsParams>();
|
||||
|
||||
constructor(mainContext: IMainContext) {
|
||||
super();
|
||||
this._proxy = mainContext.getProxy(SqlMainContext.MainThreadAccountManagement);
|
||||
}
|
||||
|
||||
// PUBLIC METHODS //////////////////////////////////////////////////////
|
||||
// - MAIN THREAD AVAILABLE METHODS /////////////////////////////////////
|
||||
public $clear(handle: number, accountKey: azdata.AccountKey): Thenable<void> {
|
||||
return this._withProvider(handle, (provider: azdata.AccountProvider) => provider.clear(accountKey));
|
||||
}
|
||||
|
||||
public $initialize(handle: number, restoredAccounts: azdata.Account[]): Thenable<azdata.Account[]> {
|
||||
return this._withProvider(handle, (provider: azdata.AccountProvider) => provider.initialize(restoredAccounts));
|
||||
}
|
||||
|
||||
public $prompt(handle: number): Thenable<azdata.Account | azdata.PromptFailedResult> {
|
||||
return this._withProvider(handle, (provider: azdata.AccountProvider) => provider.prompt());
|
||||
}
|
||||
|
||||
public $refresh(handle: number, account: azdata.Account): Thenable<azdata.Account | azdata.PromptFailedResult> {
|
||||
return this._withProvider(handle, (provider: azdata.AccountProvider) => provider.refresh(account));
|
||||
}
|
||||
|
||||
public $autoOAuthCancelled(handle: number): Thenable<void> {
|
||||
return this._withProvider(handle, (provider: azdata.AccountProvider) => provider.autoOAuthCancelled());
|
||||
}
|
||||
|
||||
// - EXTENSION HOST AVAILABLE METHODS //////////////////////////////////
|
||||
public $beginAutoOAuthDeviceCode(providerId: string, title: string, message: string, userCode: string, uri: string): Thenable<void> {
|
||||
return this._proxy.$beginAutoOAuthDeviceCode(providerId, title, message, userCode, uri);
|
||||
}
|
||||
|
||||
public $endAutoOAuthDeviceCode(): void {
|
||||
this._proxy.$endAutoOAuthDeviceCode();
|
||||
}
|
||||
|
||||
public $accountUpdated(updatedAccount: azdata.Account): void {
|
||||
this._proxy.$accountUpdated(updatedAccount);
|
||||
}
|
||||
|
||||
public $getAllAccounts(): Thenable<azdata.Account[]> {
|
||||
if (Object.keys(this._providers).length === 0) {
|
||||
throw new Error('No account providers registered.');
|
||||
}
|
||||
|
||||
this._accounts = {};
|
||||
|
||||
const resultAccounts: azdata.Account[] = [];
|
||||
|
||||
const promises: Thenable<void>[] = [];
|
||||
|
||||
for (const providerKey in this._providers) {
|
||||
const providerHandle = parseInt(providerKey);
|
||||
|
||||
const provider = this._providers[providerHandle];
|
||||
promises.push(this._proxy.$getAccountsForProvider(provider.metadata.id).then(
|
||||
(accounts) => {
|
||||
this._accounts[providerHandle] = accounts;
|
||||
resultAccounts.push(...accounts);
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
return Promise.all(promises).then(() => resultAccounts);
|
||||
}
|
||||
|
||||
public $getSecurityToken(account: azdata.Account, resource?: azdata.AzureResource): Thenable<{}> {
|
||||
if (resource === undefined) {
|
||||
resource = AzureResource.ResourceManagement;
|
||||
}
|
||||
return this.$getAllAccounts().then(() => {
|
||||
for (const handle in this._accounts) {
|
||||
const providerHandle = parseInt(handle);
|
||||
if (this._accounts[handle].findIndex((acct) => acct.key.accountId === account.key.accountId) !== -1) {
|
||||
return this._withProvider(providerHandle, (provider: azdata.AccountProvider) => provider.getSecurityToken(account, resource));
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error(`Account ${account.key.accountId} not found.`);
|
||||
});
|
||||
}
|
||||
|
||||
public get onDidChangeAccounts(): Event<azdata.DidChangeAccountsParams> {
|
||||
return this._onDidChangeAccounts.event;
|
||||
}
|
||||
|
||||
public $accountsChanged(handle: number, accounts: azdata.Account[]): Thenable<void> {
|
||||
return Promise.resolve(this._onDidChangeAccounts.fire({ accounts: accounts }));
|
||||
}
|
||||
|
||||
public $registerAccountProvider(providerMetadata: azdata.AccountProviderMetadata, provider: azdata.AccountProvider): Disposable {
|
||||
let self = this;
|
||||
|
||||
// Look for any account providers that have the same provider ID
|
||||
let matchingProviderIndex = Object.values(this._providers).findIndex((provider: AccountProviderWithMetadata) => {
|
||||
return provider.metadata.id === providerMetadata.id;
|
||||
});
|
||||
if (matchingProviderIndex >= 0) {
|
||||
throw new Error(`Account Provider with ID '${providerMetadata.id}' has already been registered`);
|
||||
}
|
||||
|
||||
// Create the handle for the provider
|
||||
let handle: number = this._nextHandle();
|
||||
this._providers[handle] = {
|
||||
metadata: providerMetadata,
|
||||
provider: provider
|
||||
};
|
||||
|
||||
// Register the provider in the main thread via the proxy
|
||||
this._proxy.$registerAccountProvider(providerMetadata, handle);
|
||||
|
||||
// Return a disposable to cleanup the provider
|
||||
return new Disposable(() => {
|
||||
delete self._providers[handle];
|
||||
self._proxy.$unregisterAccountProvider(handle);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is for testing only, it is not exposed via the shape.
|
||||
* @return Number of providers that are currently registered
|
||||
*/
|
||||
public getProviderCount(): number {
|
||||
return Object.keys(this._providers).length;
|
||||
}
|
||||
|
||||
// PRIVATE METHODS /////////////////////////////////////////////////////
|
||||
private _nextHandle(): number {
|
||||
return this._handlePool++;
|
||||
}
|
||||
|
||||
private _withProvider<R>(handle: number, callback: (provider: azdata.AccountProvider) => Thenable<R>): Thenable<R> {
|
||||
let provider = this._providers[handle];
|
||||
if (provider === undefined) {
|
||||
return Promise.reject(new Error(`Provider ${handle} not found.`));
|
||||
}
|
||||
return callback(provider.provider);
|
||||
}
|
||||
}
|
||||
|
||||
interface AccountProviderWithMetadata {
|
||||
metadata: azdata.AccountProviderMetadata;
|
||||
provider: azdata.AccountProvider;
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IMainContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { ExtHostBackgroundTaskManagementShape, SqlMainContext, MainThreadBackgroundTaskManagementShape } from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
import * as azdata from 'azdata';
|
||||
import * as vscode from 'vscode';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
|
||||
export enum TaskStatus {
|
||||
NotStarted = 0,
|
||||
InProgress = 1,
|
||||
Succeeded = 2,
|
||||
SucceededWithWarning = 3,
|
||||
Failed = 4,
|
||||
Canceled = 5,
|
||||
Canceling = 6
|
||||
}
|
||||
|
||||
export class ExtBackgroundOperation implements azdata.BackgroundOperation {
|
||||
private readonly _proxy: MainThreadBackgroundTaskManagementShape;
|
||||
private _onCanceled = new Emitter<void>();
|
||||
|
||||
constructor(
|
||||
private _id: string,
|
||||
mainContext: IMainContext
|
||||
) {
|
||||
this._proxy = mainContext.getProxy(SqlMainContext.MainThreadBackgroundTaskManagement);
|
||||
}
|
||||
|
||||
public updateStatus(status: TaskStatus, message?: string): void {
|
||||
this._proxy.$updateTask({
|
||||
message: message,
|
||||
status: status,
|
||||
taskId: this.id
|
||||
});
|
||||
}
|
||||
|
||||
public get onCanceled(): vscode.Event<void> {
|
||||
return this._onCanceled.event;
|
||||
}
|
||||
|
||||
public cancel(): void {
|
||||
this._onCanceled.fire();
|
||||
}
|
||||
|
||||
public get id(): string {
|
||||
return this._id;
|
||||
}
|
||||
}
|
||||
|
||||
export class ExtHostBackgroundTaskManagement implements ExtHostBackgroundTaskManagementShape {
|
||||
private readonly _proxy: MainThreadBackgroundTaskManagementShape;
|
||||
private readonly _handlers = new Map<string, azdata.BackgroundOperationInfo>();
|
||||
private readonly _operations = new Map<string, ExtBackgroundOperation>();
|
||||
private readonly _mainContext: IMainContext;
|
||||
|
||||
constructor(
|
||||
mainContext: IMainContext
|
||||
) {
|
||||
this._proxy = mainContext.getProxy(SqlMainContext.MainThreadBackgroundTaskManagement);
|
||||
this._mainContext = mainContext;
|
||||
}
|
||||
|
||||
$onTaskRegistered(operationId: string): void {
|
||||
let extOperationInfo = new ExtBackgroundOperation(operationId, this._mainContext);
|
||||
this._operations.set(operationId, extOperationInfo);
|
||||
let operationInfo = this._handlers.get(operationId);
|
||||
if (operationInfo) {
|
||||
operationInfo.operation(extOperationInfo);
|
||||
}
|
||||
}
|
||||
|
||||
$onTaskCanceled(operationId: string): void {
|
||||
let operation = this._operations.get(operationId);
|
||||
if (operation) {
|
||||
operation.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
$registerTask(operationInfo: azdata.BackgroundOperationInfo): void {
|
||||
let operationId = operationInfo.operationId || `OperationId${generateUuid()}`;
|
||||
if (this._handlers.has(operationId)) {
|
||||
throw new Error(`operation '${operationId}' already exists`);
|
||||
}
|
||||
|
||||
this._handlers.set(operationId, operationInfo);
|
||||
let taskInfo: azdata.TaskInfo = {
|
||||
databaseName: undefined,
|
||||
serverName: undefined,
|
||||
description: operationInfo.description,
|
||||
isCancelable: operationInfo.isCancelable,
|
||||
name: operationInfo.displayName,
|
||||
providerName: undefined, //setting provider name will cause the task to be processed by the provider. But this task is created in the extension and needs to be handled
|
||||
//by the extension
|
||||
taskExecutionMode: 0,
|
||||
taskId: operationId,
|
||||
status: TaskStatus.NotStarted,
|
||||
connection: operationInfo.connection
|
||||
};
|
||||
this._proxy.$registerTask(taskInfo);
|
||||
}
|
||||
|
||||
$removeTask(operationId: string) {
|
||||
if (this._handlers.has(operationId)) {
|
||||
this._handlers.delete(operationId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ExtHostConnectionManagementShape, SqlMainContext, MainThreadConnectionManagementShape } from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
import { IMainContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import * as azdata from 'azdata';
|
||||
|
||||
export class ExtHostConnectionManagement extends ExtHostConnectionManagementShape {
|
||||
|
||||
private _proxy: MainThreadConnectionManagementShape;
|
||||
|
||||
constructor(
|
||||
mainContext: IMainContext
|
||||
) {
|
||||
super();
|
||||
this._proxy = mainContext.getProxy(SqlMainContext.MainThreadConnectionManagement);
|
||||
}
|
||||
|
||||
public $getCurrentConnection(): Thenable<azdata.connection.ConnectionProfile> {
|
||||
return this._proxy.$getCurrentConnectionProfile();
|
||||
}
|
||||
|
||||
public $getConnections(activeConnectionsOnly?: boolean): Thenable<azdata.connection.ConnectionProfile[]> {
|
||||
return this._proxy.$getConnections(activeConnectionsOnly);
|
||||
}
|
||||
|
||||
// "sqlops" back-compat connection APIs
|
||||
public $getActiveConnections(): Thenable<azdata.connection.Connection[]> {
|
||||
return this._proxy.$getActiveConnections();
|
||||
}
|
||||
|
||||
public $getSqlOpsCurrentConnection(): Thenable<azdata.connection.Connection> {
|
||||
return this._proxy.$getCurrentConnection();
|
||||
}
|
||||
|
||||
public $getCredentials(connectionId: string): Thenable<{ [name: string]: string }> {
|
||||
return this._proxy.$getCredentials(connectionId);
|
||||
}
|
||||
|
||||
public $getServerInfo(connectionId: string): Thenable<azdata.ServerInfo> {
|
||||
return this._proxy.$getServerInfo(connectionId);
|
||||
}
|
||||
|
||||
public $openConnectionDialog(providers?: string[], initialConnectionProfile?: azdata.IConnectionProfile, connectionCompletionOptions?: azdata.IConnectionCompletionOptions): Thenable<azdata.connection.Connection> {
|
||||
return this._proxy.$openConnectionDialog(providers, initialConnectionProfile, connectionCompletionOptions);
|
||||
}
|
||||
|
||||
public $listDatabases(connectionId: string): Thenable<string[]> {
|
||||
return this._proxy.$listDatabases(connectionId);
|
||||
}
|
||||
|
||||
public $getConnectionString(connectionId: string, includePassword: boolean): Thenable<string> {
|
||||
return this._proxy.$getConnectionString(connectionId, includePassword);
|
||||
}
|
||||
|
||||
public $getUriForConnection(connectionId: string): Thenable<string> {
|
||||
return this._proxy.$getUriForConnection(connectionId);
|
||||
}
|
||||
|
||||
public $connect(connectionProfile: azdata.IConnectionProfile, saveConnection: boolean = true, showDashboard: boolean = true): Thenable<azdata.ConnectionResult> {
|
||||
return this._proxy.$connect(connectionProfile, saveConnection, showDashboard);
|
||||
}
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IMainContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { SqlMainContext, MainThreadCredentialManagementShape, ExtHostCredentialManagementShape } from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
import * as vscode from 'vscode';
|
||||
import * as azdata from 'azdata';
|
||||
import { Disposable } from 'vs/workbench/api/common/extHostTypes';
|
||||
|
||||
class CredentialAdapter {
|
||||
public provider: azdata.CredentialProvider;
|
||||
|
||||
constructor(provider: azdata.CredentialProvider) {
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
public saveCredential(credentialId: string, password: string): Thenable<boolean> {
|
||||
return this.provider.saveCredential(credentialId, password);
|
||||
}
|
||||
|
||||
public readCredential(credentialId: string): Thenable<azdata.Credential> {
|
||||
return this.provider.readCredential(credentialId);
|
||||
}
|
||||
|
||||
public deleteCredential(credentialId: string): Thenable<boolean> {
|
||||
return this.provider.deleteCredential(credentialId);
|
||||
}
|
||||
}
|
||||
|
||||
type Adapter = CredentialAdapter;
|
||||
|
||||
export class ExtHostCredentialManagement extends ExtHostCredentialManagementShape {
|
||||
// MEMBER VARIABLES ////////////////////////////////////////////////////
|
||||
private _adapter: { [handle: number]: Adapter } = Object.create(null);
|
||||
private _handlePool: number = 0;
|
||||
private _proxy: MainThreadCredentialManagementShape;
|
||||
private _registrationPromise: Promise<void>;
|
||||
private _registrationPromiseResolve;
|
||||
|
||||
constructor(mainContext: IMainContext) {
|
||||
super();
|
||||
|
||||
let self = this;
|
||||
|
||||
this._proxy = mainContext.getProxy(SqlMainContext.MainThreadCredentialManagement);
|
||||
|
||||
// Create a promise to resolve when a credential provider has been registered.
|
||||
// HACK: this gives us a deferred promise
|
||||
this._registrationPromise = new Promise((resolve) => { self._registrationPromiseResolve = resolve; });
|
||||
}
|
||||
|
||||
// PUBLIC METHODS //////////////////////////////////////////////////////
|
||||
public $registerCredentialProvider(provider: azdata.CredentialProvider): vscode.Disposable {
|
||||
// Store the credential provider
|
||||
provider.handle = this._nextHandle();
|
||||
this._adapter[provider.handle] = new CredentialAdapter(provider);
|
||||
|
||||
// Register the credential provider with the main thread
|
||||
this._proxy.$registerCredentialProvider(provider.handle);
|
||||
|
||||
// Resolve the credential provider registration promise
|
||||
this._registrationPromiseResolve();
|
||||
return this._createDisposable(provider.handle);
|
||||
}
|
||||
|
||||
public $getCredentialProvider(namespaceId: string): Thenable<azdata.CredentialProvider> {
|
||||
let self = this;
|
||||
|
||||
if (!namespaceId) {
|
||||
return Promise.reject(new Error('A namespace must be provided when retrieving a credential provider'));
|
||||
}
|
||||
|
||||
// When the registration promise has finished successfully,
|
||||
return this._registrationPromise.then(() =>
|
||||
self._withAdapter(0, CredentialAdapter, adapter => self._createNamespacedCredentialProvider(namespaceId, adapter))
|
||||
);
|
||||
}
|
||||
|
||||
public $saveCredential(credentialId: string, password: string): Thenable<boolean> {
|
||||
return this._withAdapter(0, CredentialAdapter, adapter => adapter.saveCredential(credentialId, password));
|
||||
}
|
||||
|
||||
public $readCredential(credentialId: string): Thenable<azdata.Credential> {
|
||||
return this._withAdapter(0, CredentialAdapter, adapter => adapter.readCredential(credentialId));
|
||||
}
|
||||
|
||||
public $deleteCredential(credentialId: string): Thenable<boolean> {
|
||||
return this._withAdapter(0, CredentialAdapter, adapter => adapter.deleteCredential(credentialId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method for tests. Not exposed via shape.
|
||||
* @return Number of providers registered
|
||||
*/
|
||||
public getProviderCount(): number {
|
||||
return Object.keys(this._adapter).length;
|
||||
}
|
||||
|
||||
// PRIVATE HELPERS /////////////////////////////////////////////////////
|
||||
private static _getNamespacedCredentialId(namespaceId: string, credentialId: string) {
|
||||
return `${namespaceId}|${credentialId}`;
|
||||
}
|
||||
|
||||
private _createNamespacedCredentialProvider(namespaceId: string, adapter: CredentialAdapter): Thenable<azdata.CredentialProvider> {
|
||||
// Create a provider that wraps the methods in a namespace
|
||||
let provider: azdata.CredentialProvider = {
|
||||
handle: adapter.provider.handle,
|
||||
deleteCredential: (credentialId: string) => {
|
||||
let namespacedId = ExtHostCredentialManagement._getNamespacedCredentialId(namespaceId, credentialId);
|
||||
return adapter.provider.deleteCredential(namespacedId);
|
||||
},
|
||||
readCredential: (credentialId: string) => {
|
||||
let namespacedId = ExtHostCredentialManagement._getNamespacedCredentialId(namespaceId, credentialId);
|
||||
return adapter.provider.readCredential(namespacedId);
|
||||
},
|
||||
saveCredential: (credentialId: string, credential: string) => {
|
||||
let namespacedId = ExtHostCredentialManagement._getNamespacedCredentialId(namespaceId, credentialId);
|
||||
return adapter.provider.saveCredential(namespacedId, credential);
|
||||
}
|
||||
};
|
||||
return Promise.resolve(provider);
|
||||
}
|
||||
|
||||
private _createDisposable(handle: number): Disposable {
|
||||
return new Disposable(() => {
|
||||
delete this._adapter[handle];
|
||||
this._proxy.$unregisterCredentialProvider(handle);
|
||||
});
|
||||
}
|
||||
|
||||
private _nextHandle(): number {
|
||||
return this._handlePool++;
|
||||
}
|
||||
|
||||
private _withAdapter<A, R>(handle: number, ctor: { new(...args: any[]): A }, callback: (adapter: A) => Thenable<R>): Thenable<R> {
|
||||
let adapter = this._adapter[handle];
|
||||
if (!(adapter instanceof ctor)) {
|
||||
return Promise.reject(new Error('no adapter found'));
|
||||
}
|
||||
return callback(<any>adapter);
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IMainContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
|
||||
import { ExtHostDashboardShape, MainThreadDashboardShape, SqlMainContext } from './sqlExtHost.protocol';
|
||||
|
||||
export class ExtHostDashboard implements ExtHostDashboardShape {
|
||||
private _onDidOpenDashboard = new Emitter<azdata.DashboardDocument>();
|
||||
public readonly onDidOpenDashboard: Event<azdata.DashboardDocument> = this._onDidOpenDashboard.event;
|
||||
|
||||
private _onDidChangeToDashboard = new Emitter<azdata.DashboardDocument>();
|
||||
public readonly onDidChangeToDashboard: Event<azdata.DashboardDocument> = this._onDidChangeToDashboard.event;
|
||||
|
||||
private _proxy: MainThreadDashboardShape;
|
||||
|
||||
constructor(mainContext: IMainContext) {
|
||||
this._proxy = mainContext.getProxy(SqlMainContext.MainThreadDashboard);
|
||||
}
|
||||
|
||||
$onDidOpenDashboard(dashboard: azdata.DashboardDocument) {
|
||||
this._onDidOpenDashboard.fire(dashboard);
|
||||
}
|
||||
|
||||
$onDidChangeToDashboard(dashboard: azdata.DashboardDocument) {
|
||||
this._onDidChangeToDashboard.fire(dashboard);
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { SqlMainContext, ExtHostDashboardWebviewsShape, MainThreadDashboardWebviewShape } from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
|
||||
import { IMainContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { deepClone } from 'vs/base/common/objects';
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import * as azdata from 'azdata';
|
||||
|
||||
class ExtHostDashboardWebview implements azdata.DashboardWebview {
|
||||
|
||||
private _html: string;
|
||||
public onMessageEmitter = new Emitter<any>();
|
||||
public onClosedEmitter = new Emitter<any>();
|
||||
|
||||
constructor(
|
||||
private readonly _proxy: MainThreadDashboardWebviewShape,
|
||||
private readonly _handle: number,
|
||||
private readonly _connection: azdata.connection.Connection,
|
||||
private readonly _serverInfo: azdata.ServerInfo
|
||||
) { }
|
||||
|
||||
public postMessage(message: any): Thenable<any> {
|
||||
return this._proxy.$sendMessage(this._handle, message);
|
||||
}
|
||||
|
||||
public get onMessage(): vscode.Event<any> {
|
||||
return this.onMessageEmitter.event;
|
||||
}
|
||||
|
||||
public get onClosed(): vscode.Event<any> {
|
||||
return this.onClosedEmitter.event;
|
||||
}
|
||||
|
||||
public get connection(): azdata.connection.Connection {
|
||||
return deepClone(this._connection);
|
||||
}
|
||||
|
||||
public get serverInfo(): azdata.ServerInfo {
|
||||
return deepClone(this._serverInfo);
|
||||
}
|
||||
|
||||
get html(): string {
|
||||
return this._html;
|
||||
}
|
||||
|
||||
set html(value: string) {
|
||||
if (this._html !== value) {
|
||||
this._html = value;
|
||||
this._proxy.$setHtml(this._handle, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class ExtHostDashboardWebviews implements ExtHostDashboardWebviewsShape {
|
||||
private readonly _proxy: MainThreadDashboardWebviewShape;
|
||||
|
||||
private readonly _webviews = new Map<number, ExtHostDashboardWebview>();
|
||||
private readonly _handlers = new Map<string, (webview: azdata.DashboardWebview) => void>();
|
||||
|
||||
constructor(
|
||||
mainContext: IMainContext
|
||||
) {
|
||||
this._proxy = mainContext.getProxy(SqlMainContext.MainThreadDashboardWebview);
|
||||
}
|
||||
|
||||
$onMessage(handle: number, message: any): void {
|
||||
const webview = this._webviews.get(handle);
|
||||
webview.onMessageEmitter.fire(message);
|
||||
}
|
||||
|
||||
$onClosed(handle: number): void {
|
||||
const webview = this._webviews.get(handle);
|
||||
webview.onClosedEmitter.fire(undefined);
|
||||
this._webviews.delete(handle);
|
||||
}
|
||||
|
||||
$registerProvider(widgetId: string, handler: (webview: azdata.DashboardWebview) => void): void {
|
||||
this._handlers.set(widgetId, handler);
|
||||
this._proxy.$registerProvider(widgetId);
|
||||
}
|
||||
|
||||
$registerWidget(handle: number, id: string, connection: azdata.connection.Connection, serverInfo: azdata.ServerInfo): void {
|
||||
let webview = new ExtHostDashboardWebview(this._proxy, handle, connection, serverInfo);
|
||||
this._webviews.set(handle, webview);
|
||||
this._handlers.get(id)(webview);
|
||||
}
|
||||
}
|
||||
@@ -1,717 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import * as azdata from 'azdata';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { IMainContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { Disposable } from 'vs/workbench/api/common/extHostTypes';
|
||||
import { SqlMainContext, MainThreadDataProtocolShape, ExtHostDataProtocolShape } from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
import { DataProviderType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
|
||||
export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
|
||||
|
||||
private readonly _onDidChangeLanguageFlavor = new Emitter<azdata.DidChangeLanguageFlavorParams>();
|
||||
|
||||
readonly onDidChangeLanguageFlavor: Event<azdata.DidChangeLanguageFlavorParams> = this._onDidChangeLanguageFlavor.event;
|
||||
|
||||
private _proxy: MainThreadDataProtocolShape;
|
||||
|
||||
private static _handlePool: number = 0;
|
||||
private _adapter = new Map<number, azdata.DataProvider>();
|
||||
private _providersByType = new Map<azdata.DataProviderType, azdata.DataProvider[]>();
|
||||
|
||||
constructor(
|
||||
mainContext: IMainContext
|
||||
) {
|
||||
super();
|
||||
this._proxy = mainContext.getProxy(SqlMainContext.MainThreadDataProtocol);
|
||||
}
|
||||
|
||||
private _createDisposable(handle: number): Disposable {
|
||||
return new Disposable(() => {
|
||||
this._adapter.delete(handle);
|
||||
this._proxy.$unregisterProvider(handle);
|
||||
});
|
||||
}
|
||||
|
||||
private _nextHandle(): number {
|
||||
return ExtHostDataProtocol._handlePool++;
|
||||
}
|
||||
|
||||
private _resolveProvider<P extends azdata.DataProvider>(handle: number): P {
|
||||
let provider = this._adapter.get(handle) as P;
|
||||
if (provider) {
|
||||
return provider;
|
||||
} else {
|
||||
throw new Error(`Unfound provider ${handle}`);
|
||||
}
|
||||
}
|
||||
|
||||
private registerProvider(provider: azdata.DataProvider, providerType: DataProviderType): vscode.Disposable {
|
||||
provider.handle = this._nextHandle();
|
||||
this._adapter.set(provider.handle, provider);
|
||||
let providersForType = this._providersByType.get(providerType);
|
||||
if (!providersForType) {
|
||||
providersForType = [provider];
|
||||
} else {
|
||||
providersForType.push(provider);
|
||||
}
|
||||
this._providersByType.set(providerType, providersForType);
|
||||
return this._createDisposable(provider.handle);
|
||||
}
|
||||
|
||||
public getProvider<T extends azdata.DataProvider>(providerId: string, providerType: azdata.DataProviderType): T {
|
||||
let providersForType = this._providersByType.get(providerType);
|
||||
if (!providersForType) {
|
||||
return undefined;
|
||||
}
|
||||
return providersForType.find(provider => provider.providerId === providerId) as T;
|
||||
}
|
||||
|
||||
public getProvidersByType<T extends azdata.DataProvider>(providerType: azdata.DataProviderType): T[] {
|
||||
let providersForType = this._providersByType.get(providerType);
|
||||
return (providersForType || []) as T[];
|
||||
}
|
||||
|
||||
$registerConnectionProvider(provider: azdata.ConnectionProvider): vscode.Disposable {
|
||||
let rt = this.registerProvider(provider, DataProviderType.ConnectionProvider);
|
||||
this._proxy.$registerConnectionProvider(provider.providerId, provider.handle);
|
||||
return rt;
|
||||
}
|
||||
|
||||
$registerBackupProvider(provider: azdata.BackupProvider): vscode.Disposable {
|
||||
let rt = this.registerProvider(provider, DataProviderType.BackupProvider);
|
||||
this._proxy.$registerBackupProvider(provider.providerId, provider.handle);
|
||||
return rt;
|
||||
}
|
||||
|
||||
$registerRestoreProvider(provider: azdata.RestoreProvider): vscode.Disposable {
|
||||
let rt = this.registerProvider(provider, DataProviderType.RestoreProvider);
|
||||
this._proxy.$registerRestoreProvider(provider.providerId, provider.handle);
|
||||
return rt;
|
||||
}
|
||||
|
||||
$registerScriptingProvider(provider: azdata.ScriptingProvider): vscode.Disposable {
|
||||
let rt = this.registerProvider(provider, DataProviderType.ScriptingProvider);
|
||||
this._proxy.$registerScriptingProvider(provider.providerId, provider.handle);
|
||||
return rt;
|
||||
}
|
||||
|
||||
$registerQueryProvider(provider: azdata.QueryProvider): vscode.Disposable {
|
||||
let rt = this.registerProvider(provider, DataProviderType.QueryProvider);
|
||||
this._proxy.$registerQueryProvider(provider.providerId, provider.handle);
|
||||
return rt;
|
||||
}
|
||||
|
||||
$registerMetadataProvider(provider: azdata.MetadataProvider): vscode.Disposable {
|
||||
let rt = this.registerProvider(provider, DataProviderType.MetadataProvider);
|
||||
this._proxy.$registerMetadataProvider(provider.providerId, provider.handle);
|
||||
return rt;
|
||||
}
|
||||
|
||||
$registerTaskServicesProvider(provider: azdata.TaskServicesProvider): vscode.Disposable {
|
||||
let rt = this.registerProvider(provider, DataProviderType.TaskServicesProvider);
|
||||
this._proxy.$registerTaskServicesProvider(provider.providerId, provider.handle);
|
||||
return rt;
|
||||
}
|
||||
|
||||
$registerFileBrowserProvider(provider: azdata.FileBrowserProvider): vscode.Disposable {
|
||||
let rt = this.registerProvider(provider, DataProviderType.FileBrowserProvider);
|
||||
this._proxy.$registerFileBrowserProvider(provider.providerId, provider.handle);
|
||||
return rt;
|
||||
}
|
||||
|
||||
$registerObjectExplorerProvider(provider: azdata.ObjectExplorerProvider): vscode.Disposable {
|
||||
let rt = this.registerProvider(provider, DataProviderType.ObjectExplorerProvider);
|
||||
this._proxy.$registerObjectExplorerProvider(provider.providerId, provider.handle);
|
||||
return rt;
|
||||
}
|
||||
|
||||
$registerObjectExplorerNodeProvider(provider: azdata.ObjectExplorerNodeProvider): vscode.Disposable {
|
||||
let rt = this.registerProvider(provider, DataProviderType.ObjectExplorerNodeProvider);
|
||||
this._proxy.$registerObjectExplorerNodeProvider(provider.providerId, provider.supportedProviderId, provider.group, provider.handle);
|
||||
return rt;
|
||||
}
|
||||
|
||||
$registerIconProvider(provider: azdata.IconProvider): vscode.Disposable {
|
||||
let rt = this.registerProvider(provider, DataProviderType.IconProvider);
|
||||
this._proxy.$registerIconProvider(provider.providerId, provider.handle);
|
||||
return rt;
|
||||
}
|
||||
|
||||
$registerProfilerProvider(provider: azdata.ProfilerProvider): vscode.Disposable {
|
||||
let rt = this.registerProvider(provider, DataProviderType.ProfilerProvider);
|
||||
this._proxy.$registerProfilerProvider(provider.providerId, provider.handle);
|
||||
return rt;
|
||||
}
|
||||
|
||||
$registerAdminServicesProvider(provider: azdata.AdminServicesProvider): vscode.Disposable {
|
||||
let rt = this.registerProvider(provider, DataProviderType.AdminServicesProvider);
|
||||
this._proxy.$registerAdminServicesProvider(provider.providerId, provider.handle);
|
||||
return rt;
|
||||
}
|
||||
|
||||
$registerAgentServiceProvider(provider: azdata.AgentServicesProvider): vscode.Disposable {
|
||||
let rt = this.registerProvider(provider, DataProviderType.AgentServicesProvider);
|
||||
this._proxy.$registerAgentServicesProvider(provider.providerId, provider.handle);
|
||||
return rt;
|
||||
}
|
||||
|
||||
$registerCapabilitiesServiceProvider(provider: azdata.CapabilitiesProvider): vscode.Disposable {
|
||||
let rt = this.registerProvider(provider, DataProviderType.CapabilitiesProvider);
|
||||
this._proxy.$registerCapabilitiesServiceProvider(provider.providerId, provider.handle);
|
||||
return rt;
|
||||
}
|
||||
|
||||
$registerDacFxServiceProvider(provider: azdata.DacFxServicesProvider): vscode.Disposable {
|
||||
let rt = this.registerProvider(provider, DataProviderType.DacFxServicesProvider);
|
||||
this._proxy.$registerDacFxServicesProvider(provider.providerId, provider.handle);
|
||||
return rt;
|
||||
}
|
||||
|
||||
$registerSchemaCompareServiceProvider(provider: azdata.SchemaCompareServicesProvider): vscode.Disposable {
|
||||
let rt = this.registerProvider(provider, DataProviderType.SchemaCompareServicesProvider);
|
||||
this._proxy.$registerSchemaCompareServicesProvider(provider.providerId, provider.handle);
|
||||
return rt;
|
||||
}
|
||||
|
||||
// Capabilities Discovery handlers
|
||||
$getServerCapabilities(handle: number, client: azdata.DataProtocolClientCapabilities): Thenable<azdata.DataProtocolServerCapabilities> {
|
||||
return this._resolveProvider<azdata.CapabilitiesProvider>(handle).getServerCapabilities(client);
|
||||
}
|
||||
|
||||
// Connection Management handlers
|
||||
$connect(handle: number, connectionUri: string, connection: azdata.ConnectionInfo): Thenable<boolean> {
|
||||
return this._resolveProvider<azdata.ConnectionProvider>(handle).connect(connectionUri, connection);
|
||||
}
|
||||
|
||||
$disconnect(handle: number, connectionUri: string): Thenable<boolean> {
|
||||
return this._resolveProvider<azdata.ConnectionProvider>(handle).disconnect(connectionUri);
|
||||
}
|
||||
|
||||
$cancelConnect(handle: number, connectionUri: string): Thenable<boolean> {
|
||||
return this._resolveProvider<azdata.ConnectionProvider>(handle).cancelConnect(connectionUri);
|
||||
}
|
||||
|
||||
$changeDatabase(handle: number, connectionUri: string, newDatabase: string): Thenable<boolean> {
|
||||
return this._resolveProvider<azdata.ConnectionProvider>(handle).changeDatabase(connectionUri, newDatabase);
|
||||
}
|
||||
|
||||
$listDatabases(handle: number, connectionUri: string): Thenable<azdata.ListDatabasesResult> {
|
||||
return this._resolveProvider<azdata.ConnectionProvider>(handle).listDatabases(connectionUri);
|
||||
}
|
||||
|
||||
$getConnectionString(handle: number, connectionUri: string, includePassword: boolean): Thenable<string> {
|
||||
return this._resolveProvider<azdata.ConnectionProvider>(handle).getConnectionString(connectionUri, includePassword);
|
||||
}
|
||||
|
||||
$buildConnectionInfo(handle: number, connectionString: string): Thenable<azdata.ConnectionInfo> {
|
||||
let provider = this._resolveProvider<azdata.ConnectionProvider>(handle);
|
||||
if (provider.buildConnectionInfo) {
|
||||
return provider.buildConnectionInfo(connectionString);
|
||||
} else {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
}
|
||||
|
||||
$rebuildIntelliSenseCache(handle: number, connectionUri: string): Thenable<void> {
|
||||
return this._resolveProvider<azdata.ConnectionProvider>(handle).rebuildIntelliSenseCache(connectionUri);
|
||||
}
|
||||
|
||||
$onConnectComplete(handle: number, connectionInfoSummary: azdata.ConnectionInfoSummary): void {
|
||||
this._proxy.$onConnectionComplete(handle, connectionInfoSummary);
|
||||
}
|
||||
|
||||
public $onIntelliSenseCacheComplete(handle: number, connectionUri: string): void {
|
||||
this._proxy.$onIntelliSenseCacheComplete(handle, connectionUri);
|
||||
}
|
||||
|
||||
public $onConnectionChanged(handle: number, changedConnInfo: azdata.ChangedConnectionInfo): void {
|
||||
this._proxy.$onConnectionChangeNotification(handle, changedConnInfo);
|
||||
}
|
||||
|
||||
// Protocol-wide Event Handlers
|
||||
public $languageFlavorChanged(params: azdata.DidChangeLanguageFlavorParams): void {
|
||||
this._onDidChangeLanguageFlavor.fire(params);
|
||||
}
|
||||
|
||||
// Query Management handlers
|
||||
|
||||
$cancelQuery(handle: number, ownerUri: string): Thenable<azdata.QueryCancelResult> {
|
||||
return this._resolveProvider<azdata.QueryProvider>(handle).cancelQuery(ownerUri);
|
||||
}
|
||||
|
||||
$runQuery(handle: number, ownerUri: string, selection: azdata.ISelectionData, runOptions?: azdata.ExecutionPlanOptions): Thenable<void> {
|
||||
return this._resolveProvider<azdata.QueryProvider>(handle).runQuery(ownerUri, selection, runOptions);
|
||||
}
|
||||
|
||||
$runQueryStatement(handle: number, ownerUri: string, line: number, column: number): Thenable<void> {
|
||||
return this._resolveProvider<azdata.QueryProvider>(handle).runQueryStatement(ownerUri, line, column);
|
||||
}
|
||||
|
||||
$runQueryString(handle: number, ownerUri: string, queryString: string): Thenable<void> {
|
||||
return this._resolveProvider<azdata.QueryProvider>(handle).runQueryString(ownerUri, queryString);
|
||||
}
|
||||
|
||||
$runQueryAndReturn(handle: number, ownerUri: string, queryString: string): Thenable<azdata.SimpleExecuteResult> {
|
||||
return this._resolveProvider<azdata.QueryProvider>(handle).runQueryAndReturn(ownerUri, queryString);
|
||||
}
|
||||
|
||||
$setQueryExecutionOptions(handle: number, ownerUri: string, options: azdata.QueryExecutionOptions): Thenable<void> {
|
||||
if (this._resolveProvider<azdata.QueryProvider>(handle).setQueryExecutionOptions) {
|
||||
return this._resolveProvider<azdata.QueryProvider>(handle).setQueryExecutionOptions(ownerUri, options);
|
||||
} else {
|
||||
return new Promise((r) => r());
|
||||
}
|
||||
}
|
||||
|
||||
$parseSyntax(handle: number, ownerUri: string, query: string): Thenable<azdata.SyntaxParseResult> {
|
||||
return this._resolveProvider<azdata.QueryProvider>(handle).parseSyntax(ownerUri, query);
|
||||
}
|
||||
|
||||
$getQueryRows(handle: number, rowData: azdata.QueryExecuteSubsetParams): Thenable<azdata.QueryExecuteSubsetResult> {
|
||||
return this._resolveProvider<azdata.QueryProvider>(handle).getQueryRows(rowData);
|
||||
}
|
||||
|
||||
$disposeQuery(handle: number, ownerUri: string): Thenable<void> {
|
||||
return this._resolveProvider<azdata.QueryProvider>(handle).disposeQuery(ownerUri);
|
||||
}
|
||||
|
||||
$onQueryComplete(handle: number, result: azdata.QueryExecuteCompleteNotificationResult): void {
|
||||
this._proxy.$onQueryComplete(handle, result);
|
||||
}
|
||||
$onBatchStart(handle: number, batchInfo: azdata.QueryExecuteBatchNotificationParams): void {
|
||||
this._proxy.$onBatchStart(handle, batchInfo);
|
||||
}
|
||||
$onBatchComplete(handle: number, batchInfo: azdata.QueryExecuteBatchNotificationParams): void {
|
||||
this._proxy.$onBatchComplete(handle, batchInfo);
|
||||
}
|
||||
$onResultSetAvailable(handle: number, resultSetInfo: azdata.QueryExecuteResultSetNotificationParams): void {
|
||||
this._proxy.$onResultSetAvailable(handle, resultSetInfo);
|
||||
}
|
||||
$onResultSetUpdated(handle: number, resultSetInfo: azdata.QueryExecuteResultSetNotificationParams): void {
|
||||
this._proxy.$onResultSetUpdated(handle, resultSetInfo);
|
||||
}
|
||||
$onQueryMessage(handle: number, message: azdata.QueryExecuteMessageParams): void {
|
||||
this._proxy.$onQueryMessage(handle, message);
|
||||
}
|
||||
|
||||
$saveResults(handle: number, requestParams: azdata.SaveResultsRequestParams): Thenable<azdata.SaveResultRequestResult> {
|
||||
return this._resolveProvider<azdata.QueryProvider>(handle).saveResults(requestParams);
|
||||
}
|
||||
|
||||
// Edit Data handlers
|
||||
$commitEdit(handle: number, ownerUri: string): Thenable<void> {
|
||||
return this._resolveProvider<azdata.QueryProvider>(handle).commitEdit(ownerUri);
|
||||
}
|
||||
|
||||
$createRow(handle: number, ownerUri: string): Thenable<azdata.EditCreateRowResult> {
|
||||
return this._resolveProvider<azdata.QueryProvider>(handle).createRow(ownerUri);
|
||||
}
|
||||
|
||||
$deleteRow(handle: number, ownerUri: string, rowId: number): Thenable<void> {
|
||||
return this._resolveProvider<azdata.QueryProvider>(handle).deleteRow(ownerUri, rowId);
|
||||
}
|
||||
|
||||
$disposeEdit(handle: number, ownerUri: string): Thenable<void> {
|
||||
return this._resolveProvider<azdata.QueryProvider>(handle).disposeEdit(ownerUri);
|
||||
}
|
||||
|
||||
$initializeEdit(handle: number, ownerUri: string, schemaName: string, objectName: string, objectType: string, rowLimit: number, queryString: string): Thenable<void> {
|
||||
return this._resolveProvider<azdata.QueryProvider>(handle).initializeEdit(ownerUri, schemaName, objectName, objectType, rowLimit, queryString);
|
||||
}
|
||||
|
||||
$revertCell(handle: number, ownerUri: string, rowId: number, columnId: number): Thenable<azdata.EditRevertCellResult> {
|
||||
return this._resolveProvider<azdata.QueryProvider>(handle).revertCell(ownerUri, rowId, columnId);
|
||||
}
|
||||
|
||||
$revertRow(handle: number, ownerUri: string, rowId: number): Thenable<void> {
|
||||
return this._resolveProvider<azdata.QueryProvider>(handle).revertRow(ownerUri, rowId);
|
||||
}
|
||||
|
||||
$updateCell(handle: number, ownerUri: string, rowId: number, columnId: number, newValue: string): Thenable<azdata.EditUpdateCellResult> {
|
||||
return this._resolveProvider<azdata.QueryProvider>(handle).updateCell(ownerUri, rowId, columnId, newValue);
|
||||
}
|
||||
|
||||
$getEditRows(handle: number, rowData: azdata.EditSubsetParams): Thenable<azdata.EditSubsetResult> {
|
||||
return this._resolveProvider<azdata.QueryProvider>(handle).getEditRows(rowData);
|
||||
}
|
||||
|
||||
$onEditSessionReady(handle: number, ownerUri: string, success: boolean, message: string): void {
|
||||
this._proxy.$onEditSessionReady(handle, ownerUri, success, message);
|
||||
}
|
||||
|
||||
public $getConnectionIconId(handle: number, connection: azdata.IConnectionProfile, serverInfo: azdata.ServerInfo): Thenable<string> {
|
||||
return this._resolveProvider<azdata.IconProvider>(handle).getConnectionIconId(connection, serverInfo);
|
||||
}
|
||||
|
||||
// Metadata handlers
|
||||
public $getMetadata(handle: number, connectionUri: string): Thenable<azdata.ProviderMetadata> {
|
||||
return this._resolveProvider<azdata.MetadataProvider>(handle).getMetadata(connectionUri);
|
||||
}
|
||||
|
||||
public $getDatabases(handle: number, connectionUri: string): Thenable<string[]> {
|
||||
return this._resolveProvider<azdata.MetadataProvider>(handle).getDatabases(connectionUri);
|
||||
}
|
||||
|
||||
public $getTableInfo(handle: number, connectionUri: string, metadata: azdata.ObjectMetadata): Thenable<azdata.ColumnMetadata[]> {
|
||||
return this._resolveProvider<azdata.MetadataProvider>(handle).getTableInfo(connectionUri, metadata);
|
||||
}
|
||||
|
||||
public $getViewInfo(handle: number, connectionUri: string, metadata: azdata.ObjectMetadata): Thenable<azdata.ColumnMetadata[]> {
|
||||
return this._resolveProvider<azdata.MetadataProvider>(handle).getViewInfo(connectionUri, metadata);
|
||||
}
|
||||
|
||||
// Object Explorer Service
|
||||
public $createObjectExplorerSession(handle: number, connInfo: azdata.ConnectionInfo): Thenable<azdata.ObjectExplorerSessionResponse> {
|
||||
return this._resolveProvider<azdata.ObjectExplorerProvider>(handle).createNewSession(connInfo);
|
||||
}
|
||||
|
||||
public $createObjectExplorerNodeProviderSession(handle: number, session: azdata.ObjectExplorerSession): Thenable<boolean> {
|
||||
return this._resolveProvider<azdata.ObjectExplorerNodeProvider>(handle).handleSessionOpen(session);
|
||||
}
|
||||
|
||||
public $expandObjectExplorerNode(handle: number, nodeInfo: azdata.ExpandNodeInfo): Thenable<boolean> {
|
||||
return this._resolveProvider<azdata.ObjectExplorerProviderBase>(handle).expandNode(nodeInfo);
|
||||
}
|
||||
|
||||
public $refreshObjectExplorerNode(handle: number, nodeInfo: azdata.ExpandNodeInfo): Thenable<boolean> {
|
||||
return this._resolveProvider<azdata.ObjectExplorerProviderBase>(handle).refreshNode(nodeInfo);
|
||||
}
|
||||
|
||||
public $closeObjectExplorerSession(handle: number, closeSessionInfo: azdata.ObjectExplorerCloseSessionInfo): Thenable<azdata.ObjectExplorerCloseSessionResponse> {
|
||||
return this._resolveProvider<azdata.ObjectExplorerProvider>(handle).closeSession(closeSessionInfo);
|
||||
}
|
||||
|
||||
public $handleSessionClose(handle: number, closeSessionInfo: azdata.ObjectExplorerCloseSessionInfo): void {
|
||||
return this._resolveProvider<azdata.ObjectExplorerNodeProvider>(handle).handleSessionClose(closeSessionInfo);
|
||||
}
|
||||
|
||||
public $findNodes(handle: number, findNodesInfo: azdata.FindNodesInfo): Thenable<azdata.ObjectExplorerFindNodesResponse> {
|
||||
return this._resolveProvider<azdata.ObjectExplorerProviderBase>(handle).findNodes(findNodesInfo);
|
||||
}
|
||||
|
||||
public $onObjectExplorerSessionCreated(handle: number, response: azdata.ObjectExplorerSession): void {
|
||||
this._proxy.$onObjectExplorerSessionCreated(handle, response);
|
||||
}
|
||||
|
||||
public $onObjectExplorerSessionDisconnected(handle: number, response: azdata.ObjectExplorerSession): void {
|
||||
this._proxy.$onObjectExplorerSessionDisconnected(handle, response);
|
||||
}
|
||||
|
||||
public $onObjectExplorerNodeExpanded(providerId: string, response: azdata.ObjectExplorerExpandInfo): void {
|
||||
this._proxy.$onObjectExplorerNodeExpanded(providerId, response);
|
||||
}
|
||||
|
||||
// Task Service
|
||||
public $getAllTasks(handle: number, listTasksParams: azdata.ListTasksParams): Thenable<azdata.ListTasksResponse> {
|
||||
return this._resolveProvider<azdata.TaskServicesProvider>(handle).getAllTasks(listTasksParams);
|
||||
}
|
||||
|
||||
public $cancelTask(handle: number, cancelTaskParams: azdata.CancelTaskParams): Thenable<boolean> {
|
||||
return this._resolveProvider<azdata.TaskServicesProvider>(handle).cancelTask(cancelTaskParams);
|
||||
}
|
||||
|
||||
public $onTaskStatusChanged(handle: number, response: azdata.TaskProgressInfo): void {
|
||||
this._proxy.$onTaskStatusChanged(handle, response);
|
||||
}
|
||||
|
||||
public $onTaskCreated(handle: number, response: azdata.TaskInfo): void {
|
||||
this._proxy.$onTaskCreated(handle, response);
|
||||
}
|
||||
|
||||
// Scripting handlers
|
||||
|
||||
public $scriptAsOperation(handle: number, connectionUri: string, operation: azdata.ScriptOperation, metadata: azdata.ObjectMetadata, paramDetails: azdata.ScriptingParamDetails): Thenable<azdata.ScriptingResult> {
|
||||
return this._resolveProvider<azdata.ScriptingProvider>(handle).scriptAsOperation(connectionUri, operation, metadata, paramDetails);
|
||||
}
|
||||
|
||||
public $onScriptingComplete(handle: number, scriptingCompleteResult: azdata.ScriptingCompleteResult): void {
|
||||
this._proxy.$onScriptingComplete(handle, scriptingCompleteResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new database on the provided connection
|
||||
*/
|
||||
public $createDatabase(handle: number, connectionUri: string, database: azdata.DatabaseInfo): Thenable<azdata.CreateDatabaseResponse> {
|
||||
return this._resolveProvider<azdata.AdminServicesProvider>(handle).createDatabase(connectionUri, database);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new database on the provided connection
|
||||
*/
|
||||
public $getDefaultDatabaseInfo(handle: number, connectionUri: string): Thenable<azdata.DatabaseInfo> {
|
||||
return this._resolveProvider<azdata.AdminServicesProvider>(handle).getDefaultDatabaseInfo(connectionUri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the info on a database
|
||||
*/
|
||||
public $getDatabaseInfo(handle: number, connectionUri: string): Thenable<azdata.DatabaseInfo> {
|
||||
return this._resolveProvider<azdata.AdminServicesProvider>(handle).getDatabaseInfo(connectionUri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new login on the provided connection
|
||||
*/
|
||||
public $createLogin(handle: number, connectionUri: string, login: azdata.LoginInfo): Thenable<azdata.CreateLoginResponse> {
|
||||
return this._resolveProvider<azdata.AdminServicesProvider>(handle).createLogin(connectionUri, login);
|
||||
}
|
||||
|
||||
/**
|
||||
* Backup a database
|
||||
*/
|
||||
public $backup(handle: number, connectionUri: string, backupInfo: { [key: string]: any }, taskExecutionMode: azdata.TaskExecutionMode): Thenable<azdata.BackupResponse> {
|
||||
return this._resolveProvider<azdata.BackupProvider>(handle).backup(connectionUri, backupInfo, taskExecutionMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new database on the provided connection
|
||||
*/
|
||||
public $getBackupConfigInfo(handle: number, connectionUri: string): Thenable<azdata.BackupConfigInfo> {
|
||||
return this._resolveProvider<azdata.BackupProvider>(handle).getBackupConfigInfo(connectionUri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restores a database
|
||||
*/
|
||||
public $restore(handle: number, connectionUri: string, restoreInfo: azdata.RestoreInfo): Thenable<azdata.RestoreResponse> {
|
||||
return this._resolveProvider<azdata.RestoreProvider>(handle).restore(connectionUri, restoreInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a plan for restoring a database
|
||||
*/
|
||||
public $getRestorePlan(handle: number, connectionUri: string, restoreInfo: azdata.RestoreInfo): Thenable<azdata.RestorePlanResponse> {
|
||||
return this._resolveProvider<azdata.RestoreProvider>(handle).getRestorePlan(connectionUri, restoreInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* cancels a restore plan
|
||||
*/
|
||||
public $cancelRestorePlan(handle: number, connectionUri: string, restoreInfo: azdata.RestoreInfo): Thenable<boolean> {
|
||||
return this._resolveProvider<azdata.RestoreProvider>(handle).cancelRestorePlan(connectionUri, restoreInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets restore config Info
|
||||
*/
|
||||
public $getRestoreConfigInfo(handle: number, connectionUri: string): Thenable<azdata.RestoreConfigInfo> {
|
||||
return this._resolveProvider<azdata.RestoreProvider>(handle).getRestoreConfigInfo(connectionUri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a file browser
|
||||
*/
|
||||
public $openFileBrowser(handle: number, ownerUri: string, expandPath: string, fileFilters: string[], changeFilter: boolean): Thenable<boolean> {
|
||||
return this._resolveProvider<azdata.FileBrowserProvider>(handle).openFileBrowser(ownerUri, expandPath, fileFilters, changeFilter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send event when opening browser is complete
|
||||
*/
|
||||
public $onFileBrowserOpened(handle: number, response: azdata.FileBrowserOpenedParams): void {
|
||||
this._proxy.$onFileBrowserOpened(handle, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expand a folder node
|
||||
*/
|
||||
public $expandFolderNode(handle: number, ownerUri: string, expandPath: string): Thenable<boolean> {
|
||||
return this._resolveProvider<azdata.FileBrowserProvider>(handle).expandFolderNode(ownerUri, expandPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send event when expansion is complete
|
||||
*/
|
||||
public $onFolderNodeExpanded(handle: number, response: azdata.FileBrowserExpandedParams): void {
|
||||
this._proxy.$onFolderNodeExpanded(handle, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate selected file path
|
||||
*/
|
||||
public $validateFilePaths(handle: number, ownerUri: string, serviceType: string, selectedFiles: string[]): Thenable<boolean> {
|
||||
return this._resolveProvider<azdata.FileBrowserProvider>(handle).validateFilePaths(ownerUri, serviceType, selectedFiles);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send event when validation is complete
|
||||
*/
|
||||
public $onFilePathsValidated(handle: number, response: azdata.FileBrowserValidatedParams) {
|
||||
this._proxy.$onFilePathsValidated(handle, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close file browser
|
||||
*/
|
||||
public $closeFileBrowser(handle: number, ownerUri: string): Thenable<azdata.FileBrowserCloseResponse> {
|
||||
return this._resolveProvider<azdata.FileBrowserProvider>(handle).closeFileBrowser(ownerUri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Profiler Provider methods
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create a new profiler session
|
||||
*/
|
||||
public $createSession(handle: number, sessionId: string, createStatement: string, template: azdata.ProfilerSessionTemplate): Thenable<boolean> {
|
||||
return this._resolveProvider<azdata.ProfilerProvider>(handle).createSession(sessionId, createStatement, template);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start a profiler session
|
||||
*/
|
||||
public $startSession(handle: number, sessionId: string, sessionName: string): Thenable<boolean> {
|
||||
return this._resolveProvider<azdata.ProfilerProvider>(handle).startSession(sessionId, sessionName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop a profiler session
|
||||
*/
|
||||
public $stopSession(handle: number, sessionId: string): Thenable<boolean> {
|
||||
return this._resolveProvider<azdata.ProfilerProvider>(handle).stopSession(sessionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pause a profiler session
|
||||
*/
|
||||
public $pauseSession(handle: number, sessionId: string): Thenable<boolean> {
|
||||
return this._resolveProvider<azdata.ProfilerProvider>(handle).pauseSession(sessionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnect a profiler session
|
||||
*/
|
||||
public $disconnectSession(handle: number, sessionId: string): Thenable<boolean> {
|
||||
return this._resolveProvider<azdata.ProfilerProvider>(handle).disconnectSession(sessionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of running XEvent sessions on the session's target server
|
||||
*/
|
||||
public $getXEventSessions(handle: number, sessionId: string): Thenable<string[]> {
|
||||
return this._resolveProvider<azdata.ProfilerProvider>(handle).getXEventSessions(sessionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Profiler session events available notification
|
||||
*/
|
||||
public $onSessionEventsAvailable(handle: number, response: azdata.ProfilerSessionEvents): void {
|
||||
this._proxy.$onSessionEventsAvailable(handle, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Profiler session stopped unexpectedly notification
|
||||
*/
|
||||
public $onSessionStopped(handle: number, response: azdata.ProfilerSessionStoppedParams): void {
|
||||
this._proxy.$onSessionStopped(handle, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Profiler session created notification
|
||||
*/
|
||||
public $onProfilerSessionCreated(handle: number, response: azdata.ProfilerSessionCreatedParams): void {
|
||||
this._proxy.$onProfilerSessionCreated(handle, response);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Agent Job Provider methods
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get Agent Job list
|
||||
*/
|
||||
public $getJobs(handle: number, ownerUri: string): Thenable<azdata.AgentJobsResult> {
|
||||
return this._resolveProvider<azdata.AgentServicesProvider>(handle).getJobs(ownerUri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Agent Job's history
|
||||
*/
|
||||
public $getJobHistory(handle: number, ownerUri: string, jobID: string, jobName: string): Thenable<azdata.AgentJobHistoryResult> {
|
||||
return this._resolveProvider<azdata.AgentServicesProvider>(handle).getJobHistory(ownerUri, jobID, jobName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run an action on a job
|
||||
*/
|
||||
public $jobAction(handle: number, ownerUri: string, jobName: string, action: string): Thenable<azdata.ResultStatus> {
|
||||
return this._resolveProvider<azdata.AgentServicesProvider>(handle).jobAction(ownerUri, jobName, action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a job
|
||||
*/
|
||||
$deleteJob(handle: number, ownerUri: string, job: azdata.AgentJobInfo): Thenable<azdata.ResultStatus> {
|
||||
throw this._resolveProvider<azdata.AgentServicesProvider>(handle).deleteJob(ownerUri, job);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a job step
|
||||
*/
|
||||
$deleteJobStep(handle: number, ownerUri: string, step: azdata.AgentJobStepInfo): Thenable<azdata.ResultStatus> {
|
||||
throw this._resolveProvider<azdata.AgentServicesProvider>(handle).deleteJobStep(ownerUri, step);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Agent Alerts list
|
||||
*/
|
||||
$getAlerts(handle: number, ownerUri: string): Thenable<azdata.AgentAlertsResult> {
|
||||
return this._resolveProvider<azdata.AgentServicesProvider>(handle).getAlerts(ownerUri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an alert
|
||||
*/
|
||||
$deleteAlert(handle: number, ownerUri: string, alert: azdata.AgentAlertInfo): Thenable<azdata.ResultStatus> {
|
||||
return this._resolveProvider<azdata.AgentServicesProvider>(handle).deleteAlert(ownerUri, alert);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Agent Oeprators list
|
||||
*/
|
||||
$getOperators(handle: number, ownerUri: string): Thenable<azdata.AgentOperatorsResult> {
|
||||
return this._resolveProvider<azdata.AgentServicesProvider>(handle).getOperators(ownerUri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an operator
|
||||
*/
|
||||
$deleteOperator(handle: number, ownerUri: string, operator: azdata.AgentOperatorInfo): Thenable<azdata.ResultStatus> {
|
||||
return this._resolveProvider<azdata.AgentServicesProvider>(handle).deleteOperator(ownerUri, operator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Agent Proxies list
|
||||
*/
|
||||
$getProxies(handle: number, ownerUri: string): Thenable<azdata.AgentProxiesResult> {
|
||||
return this._resolveProvider<azdata.AgentServicesProvider>(handle).getProxies(ownerUri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a proxy
|
||||
*/
|
||||
$deleteProxy(handle: number, ownerUri: string, proxy: azdata.AgentProxyInfo): Thenable<azdata.ResultStatus> {
|
||||
return this._resolveProvider<azdata.AgentServicesProvider>(handle).deleteProxy(ownerUri, proxy);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Agent Credentials from server
|
||||
*/
|
||||
$getCredentials(handle: number, ownerUri: string): Thenable<azdata.GetCredentialsResult> {
|
||||
return this._resolveProvider<azdata.AgentServicesProvider>(handle).getCredentials(ownerUri);
|
||||
}
|
||||
|
||||
/**
|
||||
* SQL Agent job data update notification
|
||||
*/
|
||||
public $onJobDataUpdated(handle: Number): void {
|
||||
this._proxy.$onJobDataUpdated(handle);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IMainContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
|
||||
import { ExtHostExtensionManagementShape, MainThreadExtensionManagementShape, SqlMainContext } from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
|
||||
|
||||
export class ExtHostExtensionManagement implements ExtHostExtensionManagementShape {
|
||||
|
||||
private readonly _proxy: MainThreadExtensionManagementShape;
|
||||
|
||||
constructor(_mainContext: IMainContext) {
|
||||
this._proxy = _mainContext.getProxy(SqlMainContext.MainThreadExtensionManagement);
|
||||
}
|
||||
|
||||
$install(vsixPath: string): Thenable<string> {
|
||||
return this._proxy.$install(vsixPath);
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { SqlMainContext, MainThreadModalDialogShape, ExtHostModalDialogsShape } from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
import { IMainContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import * as vscode from 'vscode';
|
||||
import * as azdata from 'azdata';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
|
||||
class ExtHostDialog implements azdata.ModalDialog {
|
||||
private _title: string;
|
||||
private _html: string;
|
||||
private _okTitle: string;
|
||||
private _closeTitle: string;
|
||||
public onMessageEmitter = new Emitter<any>();
|
||||
public onClosedEmitter = new Emitter<any>();
|
||||
|
||||
constructor(
|
||||
private readonly _proxy: MainThreadModalDialogShape,
|
||||
private readonly _handle: number,
|
||||
) { }
|
||||
|
||||
get title(): string {
|
||||
return this._title;
|
||||
}
|
||||
|
||||
set title(value: string) {
|
||||
if (this._title !== value) {
|
||||
this._title = value;
|
||||
this._proxy.$setTitle(this._handle, value);
|
||||
}
|
||||
}
|
||||
|
||||
get html(): string {
|
||||
return this._html;
|
||||
}
|
||||
|
||||
set html(value: string) {
|
||||
if (this._html !== value) {
|
||||
this._html = value;
|
||||
this._proxy.$setHtml(this._handle, value);
|
||||
}
|
||||
}
|
||||
|
||||
public set okTitle(value: string) {
|
||||
this._okTitle = value;
|
||||
}
|
||||
|
||||
public get okTitle(): string {
|
||||
return this._okTitle;
|
||||
}
|
||||
|
||||
public set closeTitle(value: string) {
|
||||
this._closeTitle = value;
|
||||
}
|
||||
|
||||
public get closeTitle(): string {
|
||||
return this._closeTitle;
|
||||
}
|
||||
|
||||
public open(): void {
|
||||
this._proxy.$show(this._handle);
|
||||
}
|
||||
|
||||
public close(): void {
|
||||
this._proxy.$disposeDialog(this._handle);
|
||||
}
|
||||
|
||||
public postMessage(message: any): Thenable<any> {
|
||||
return this._proxy.$sendMessage(this._handle, message);
|
||||
}
|
||||
|
||||
public get onMessage(): vscode.Event<any> {
|
||||
return this.onMessageEmitter.event;
|
||||
}
|
||||
|
||||
public get onClosed(): vscode.Event<any> {
|
||||
return this.onClosedEmitter.event;
|
||||
}
|
||||
}
|
||||
|
||||
export class ExtHostModalDialogs implements ExtHostModalDialogsShape {
|
||||
private static _handlePool = 0;
|
||||
|
||||
private readonly _proxy: MainThreadModalDialogShape;
|
||||
|
||||
private readonly _webviews = new Map<number, ExtHostDialog>();
|
||||
|
||||
constructor(
|
||||
mainContext: IMainContext
|
||||
) {
|
||||
this._proxy = mainContext.getProxy(SqlMainContext.MainThreadModalDialog);
|
||||
}
|
||||
|
||||
createDialog(
|
||||
title: string
|
||||
): azdata.ModalDialog {
|
||||
const handle = ExtHostModalDialogs._handlePool++;
|
||||
this._proxy.$createDialog(handle);
|
||||
|
||||
const webview = new ExtHostDialog(this._proxy, handle);
|
||||
this._webviews.set(handle, webview);
|
||||
webview.title = title;
|
||||
//webview.options = options;
|
||||
//this._proxy.$show(handle);
|
||||
return webview;
|
||||
}
|
||||
|
||||
$onMessage(handle: number, message: any): void {
|
||||
const webview = this._webviews.get(handle);
|
||||
webview.onMessageEmitter.fire(message);
|
||||
}
|
||||
|
||||
$onClosed(handle: number): void {
|
||||
const webview = this._webviews.get(handle);
|
||||
webview.onClosedEmitter.fire(undefined);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,695 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IMainContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import * as nls from 'vs/nls';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import * as azdata from 'azdata';
|
||||
|
||||
import { SqlMainContext, ExtHostModelViewDialogShape, MainThreadModelViewDialogShape, ExtHostModelViewShape, ExtHostBackgroundTaskManagementShape } from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
|
||||
const DONE_LABEL = nls.localize('dialogDoneLabel', 'Done');
|
||||
const CANCEL_LABEL = nls.localize('dialogCancelLabel', 'Cancel');
|
||||
const GENERATE_SCRIPT_LABEL = nls.localize('generateScriptLabel', 'Generate script');
|
||||
const NEXT_LABEL = nls.localize('dialogNextLabel', 'Next');
|
||||
const PREVIOUS_LABEL = nls.localize('dialogPreviousLabel', 'Previous');
|
||||
|
||||
class ModelViewPanelImpl implements azdata.window.ModelViewPanel {
|
||||
private _modelView: azdata.ModelView;
|
||||
private _handle: number;
|
||||
protected _modelViewId: string;
|
||||
protected _valid: boolean = true;
|
||||
protected _onValidityChanged: vscode.Event<boolean>;
|
||||
|
||||
constructor(private _viewType: string,
|
||||
protected _extHostModelViewDialog: ExtHostModelViewDialog,
|
||||
protected _extHostModelView: ExtHostModelViewShape,
|
||||
protected _extension: IExtensionDescription) {
|
||||
this._onValidityChanged = this._extHostModelViewDialog.getValidityChangedEvent(this);
|
||||
this._onValidityChanged(valid => this._valid = valid);
|
||||
}
|
||||
|
||||
public registerContent(handler: (view: azdata.ModelView) => Thenable<void>): void {
|
||||
if (!this._modelViewId) {
|
||||
let viewId = this._viewType + this._handle;
|
||||
this.setModelViewId(viewId);
|
||||
this._extHostModelView.$registerProvider(viewId, modelView => {
|
||||
this._modelView = modelView;
|
||||
handler(modelView);
|
||||
}, this._extension);
|
||||
}
|
||||
}
|
||||
|
||||
public set handle(value: number) {
|
||||
this._handle = value;
|
||||
}
|
||||
|
||||
public setModelViewId(value: string) {
|
||||
this._modelViewId = value;
|
||||
}
|
||||
|
||||
public get modelView(): azdata.ModelView {
|
||||
return this._modelView;
|
||||
}
|
||||
|
||||
public set modelView(value: azdata.ModelView) {
|
||||
this._modelView = value;
|
||||
}
|
||||
|
||||
public get valid(): boolean {
|
||||
return this._valid;
|
||||
}
|
||||
|
||||
public get onValidityChanged(): Event<boolean> {
|
||||
return this._onValidityChanged;
|
||||
}
|
||||
}
|
||||
|
||||
class ModelViewEditorImpl extends ModelViewPanelImpl implements azdata.workspace.ModelViewEditor {
|
||||
private _isDirty: boolean;
|
||||
private _saveHandler: () => Thenable<boolean>;
|
||||
|
||||
constructor(
|
||||
extHostModelViewDialog: ExtHostModelViewDialog,
|
||||
extHostModelView: ExtHostModelViewShape,
|
||||
extension: IExtensionDescription,
|
||||
private _proxy: MainThreadModelViewDialogShape,
|
||||
private _title: string,
|
||||
private _options: azdata.ModelViewEditorOptions
|
||||
) {
|
||||
super('modelViewEditor', extHostModelViewDialog, extHostModelView, extension);
|
||||
this._isDirty = false;
|
||||
}
|
||||
|
||||
public openEditor(position?: vscode.ViewColumn): Thenable<void> {
|
||||
return this._proxy.$openEditor(this.handle, this._modelViewId, this._title, this._options, position);
|
||||
}
|
||||
|
||||
public get isDirty(): boolean {
|
||||
return this._isDirty;
|
||||
}
|
||||
|
||||
public set isDirty(value: boolean) {
|
||||
this._isDirty = value;
|
||||
this._proxy.$setDirty(this.handle, value);
|
||||
}
|
||||
|
||||
registerSaveHandler(handler: () => Thenable<boolean>): void {
|
||||
this._saveHandler = handler;
|
||||
}
|
||||
|
||||
public handleSave(): Thenable<boolean> {
|
||||
if (this._saveHandler) {
|
||||
return Promise.resolve(this._saveHandler());
|
||||
} else {
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DialogImpl extends ModelViewPanelImpl implements azdata.window.Dialog {
|
||||
public title: string;
|
||||
public content: string | azdata.window.DialogTab[];
|
||||
public okButton: azdata.window.Button;
|
||||
public cancelButton: azdata.window.Button;
|
||||
public customButtons: azdata.window.Button[];
|
||||
private _message: azdata.window.DialogMessage;
|
||||
private _closeValidator: () => boolean | Thenable<boolean>;
|
||||
private _operationHandler: BackgroundOperationHandler;
|
||||
private _dialogName: string;
|
||||
private _isWide: boolean;
|
||||
|
||||
constructor(extHostModelViewDialog: ExtHostModelViewDialog,
|
||||
extHostModelView: ExtHostModelViewShape,
|
||||
extHostTaskManagement: ExtHostBackgroundTaskManagementShape,
|
||||
extension: IExtensionDescription) {
|
||||
super('modelViewDialog', extHostModelViewDialog, extHostModelView, extension);
|
||||
this.okButton = this._extHostModelViewDialog.createButton(DONE_LABEL);
|
||||
this.cancelButton = this._extHostModelViewDialog.createButton(CANCEL_LABEL);
|
||||
this._operationHandler = new BackgroundOperationHandler('dialog', extHostTaskManagement);
|
||||
this.okButton.onClick(() => {
|
||||
this._operationHandler.createOperation();
|
||||
});
|
||||
}
|
||||
|
||||
public registerOperation(operationInfo: azdata.BackgroundOperationInfo): void {
|
||||
this._operationHandler.registerOperation(operationInfo);
|
||||
}
|
||||
|
||||
public setModelViewId(value: string) {
|
||||
super.setModelViewId(value);
|
||||
this.content = value;
|
||||
}
|
||||
|
||||
public get message(): azdata.window.DialogMessage {
|
||||
return this._message;
|
||||
}
|
||||
|
||||
public set message(value: azdata.window.DialogMessage) {
|
||||
this._message = value;
|
||||
this._extHostModelViewDialog.updateDialogContent(this);
|
||||
}
|
||||
|
||||
public get dialogName(): string {
|
||||
return this._dialogName;
|
||||
}
|
||||
|
||||
public set dialogName(value: string) {
|
||||
this._dialogName = value;
|
||||
}
|
||||
|
||||
public get isWide(): boolean {
|
||||
return this._isWide;
|
||||
}
|
||||
|
||||
public set isWide(value: boolean) {
|
||||
this._isWide = value;
|
||||
}
|
||||
|
||||
public registerCloseValidator(validator: () => boolean | Thenable<boolean>): void {
|
||||
this._closeValidator = validator;
|
||||
}
|
||||
|
||||
public validateClose(): Thenable<boolean> {
|
||||
if (this._closeValidator) {
|
||||
return Promise.resolve(this._closeValidator());
|
||||
} else {
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TabImpl extends ModelViewPanelImpl implements azdata.window.DialogTab {
|
||||
constructor(
|
||||
extHostModelViewDialog: ExtHostModelViewDialog,
|
||||
extHostModelView: ExtHostModelViewShape,
|
||||
extension: IExtensionDescription) {
|
||||
super('modelViewDialogTab', extHostModelViewDialog, extHostModelView, extension);
|
||||
}
|
||||
|
||||
public title: string;
|
||||
public content: string;
|
||||
public handle: number;
|
||||
|
||||
public setModelViewId(value: string) {
|
||||
super.setModelViewId(value);
|
||||
this.content = value;
|
||||
}
|
||||
}
|
||||
|
||||
class ButtonImpl implements azdata.window.Button {
|
||||
private _label: string;
|
||||
private _enabled: boolean;
|
||||
private _hidden: boolean;
|
||||
|
||||
private _onClick = new Emitter<void>();
|
||||
public onClick = this._onClick.event;
|
||||
|
||||
constructor(private _extHostModelViewDialog: ExtHostModelViewDialog) {
|
||||
this._enabled = true;
|
||||
this._hidden = false;
|
||||
}
|
||||
|
||||
public get label(): string {
|
||||
return this._label;
|
||||
}
|
||||
|
||||
public set label(label: string) {
|
||||
this._label = label;
|
||||
this._extHostModelViewDialog.updateButton(this);
|
||||
}
|
||||
|
||||
public get enabled(): boolean {
|
||||
return this._enabled;
|
||||
}
|
||||
|
||||
public set enabled(enabled: boolean) {
|
||||
this._enabled = enabled;
|
||||
this._extHostModelViewDialog.updateButton(this);
|
||||
}
|
||||
|
||||
public get hidden(): boolean {
|
||||
return this._hidden;
|
||||
}
|
||||
|
||||
public set hidden(hidden: boolean) {
|
||||
this._hidden = hidden;
|
||||
this._extHostModelViewDialog.updateButton(this);
|
||||
}
|
||||
|
||||
public getOnClickCallback(): () => void {
|
||||
return () => this._onClick.fire();
|
||||
}
|
||||
}
|
||||
|
||||
class BackgroundOperationHandler {
|
||||
|
||||
private _operationInfo: azdata.BackgroundOperationInfo;
|
||||
|
||||
constructor(
|
||||
private _name: string,
|
||||
private _extHostTaskManagement: ExtHostBackgroundTaskManagementShape) {
|
||||
}
|
||||
|
||||
public createOperation(): void {
|
||||
if (!this._operationInfo) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this._operationInfo.operationId) {
|
||||
let uniqueId = generateUuid();
|
||||
this._operationInfo.operationId = 'OperationId' + uniqueId + this._name;
|
||||
}
|
||||
|
||||
if (this._operationInfo.operation) {
|
||||
this._extHostTaskManagement.$registerTask(this._operationInfo);
|
||||
}
|
||||
}
|
||||
|
||||
public registerOperation(operationInfo: azdata.BackgroundOperationInfo): void {
|
||||
this._operationInfo = operationInfo;
|
||||
}
|
||||
}
|
||||
|
||||
class WizardPageImpl extends ModelViewPanelImpl implements azdata.window.WizardPage {
|
||||
public customButtons: azdata.window.Button[];
|
||||
private _enabled: boolean = true;
|
||||
private _description: string;
|
||||
|
||||
constructor(public title: string,
|
||||
extHostModelViewDialog: ExtHostModelViewDialog,
|
||||
extHostModelView: ExtHostModelViewShape,
|
||||
extension: IExtensionDescription) {
|
||||
super('modelViewWizardPage', extHostModelViewDialog, extHostModelView, extension);
|
||||
}
|
||||
|
||||
public get enabled(): boolean {
|
||||
return this._enabled;
|
||||
}
|
||||
|
||||
public set enabled(enabled: boolean) {
|
||||
this._enabled = enabled;
|
||||
this._extHostModelViewDialog.updateWizardPage(this);
|
||||
}
|
||||
|
||||
public get content(): string {
|
||||
return this._modelViewId;
|
||||
}
|
||||
|
||||
public set content(content: string) {
|
||||
this._modelViewId = content;
|
||||
}
|
||||
|
||||
public get description(): string {
|
||||
return this._description;
|
||||
}
|
||||
|
||||
public set description(description: string) {
|
||||
this._description = description;
|
||||
this._extHostModelViewDialog.updateWizardPage(this);
|
||||
}
|
||||
}
|
||||
|
||||
export enum WizardPageInfoEventType {
|
||||
PageChanged,
|
||||
PageAddedOrRemoved
|
||||
}
|
||||
|
||||
export interface WizardPageEventInfo {
|
||||
eventType: WizardPageInfoEventType;
|
||||
pageChangeInfo: azdata.window.WizardPageChangeInfo;
|
||||
pages?: azdata.window.WizardPage[];
|
||||
}
|
||||
|
||||
class WizardImpl implements azdata.window.Wizard {
|
||||
private _currentPage: number = undefined;
|
||||
public pages: azdata.window.WizardPage[] = [];
|
||||
public doneButton: azdata.window.Button;
|
||||
public cancelButton: azdata.window.Button;
|
||||
public generateScriptButton: azdata.window.Button;
|
||||
public nextButton: azdata.window.Button;
|
||||
public backButton: azdata.window.Button;
|
||||
public customButtons: azdata.window.Button[];
|
||||
private _pageChangedEmitter = new Emitter<azdata.window.WizardPageChangeInfo>();
|
||||
public readonly onPageChanged = this._pageChangedEmitter.event;
|
||||
private _navigationValidator: (info: azdata.window.WizardPageChangeInfo) => boolean | Thenable<boolean>;
|
||||
private _message: azdata.window.DialogMessage;
|
||||
private _displayPageTitles: boolean = true;
|
||||
private _operationHandler: BackgroundOperationHandler;
|
||||
|
||||
constructor(public title: string, private _extHostModelViewDialog: ExtHostModelViewDialog, extHostTaskManagement: ExtHostBackgroundTaskManagementShape) {
|
||||
this.doneButton = this._extHostModelViewDialog.createButton(DONE_LABEL);
|
||||
this.cancelButton = this._extHostModelViewDialog.createButton(CANCEL_LABEL);
|
||||
this.generateScriptButton = this._extHostModelViewDialog.createButton(GENERATE_SCRIPT_LABEL);
|
||||
this.nextButton = this._extHostModelViewDialog.createButton(NEXT_LABEL);
|
||||
this.backButton = this._extHostModelViewDialog.createButton(PREVIOUS_LABEL);
|
||||
this._extHostModelViewDialog.registerWizardPageInfoChangedCallback(this, info => this.handlePageInfoChanged(info));
|
||||
this._currentPage = 0;
|
||||
this.onPageChanged(info => this._currentPage = info.newPage);
|
||||
this._operationHandler = new BackgroundOperationHandler('wizard' + this.title, extHostTaskManagement);
|
||||
this.doneButton.onClick(() => {
|
||||
this._operationHandler.createOperation();
|
||||
});
|
||||
}
|
||||
|
||||
public registerOperation(operationInfo: azdata.BackgroundOperationInfo): void {
|
||||
this._operationHandler.registerOperation(operationInfo);
|
||||
}
|
||||
|
||||
public get currentPage(): number {
|
||||
return this._currentPage;
|
||||
}
|
||||
|
||||
public get message(): azdata.window.DialogMessage {
|
||||
return this._message;
|
||||
}
|
||||
|
||||
public set message(value: azdata.window.DialogMessage) {
|
||||
this._message = value;
|
||||
this._extHostModelViewDialog.updateWizard(this);
|
||||
}
|
||||
|
||||
public get displayPageTitles(): boolean {
|
||||
return this._displayPageTitles;
|
||||
}
|
||||
|
||||
public set displayPageTitles(value: boolean) {
|
||||
this._displayPageTitles = value;
|
||||
this._extHostModelViewDialog.updateWizard(this);
|
||||
}
|
||||
|
||||
public addPage(page: azdata.window.WizardPage, index?: number): Thenable<void> {
|
||||
return this._extHostModelViewDialog.updateWizardPage(page).then(() => {
|
||||
this._extHostModelViewDialog.addPage(this, page, index);
|
||||
});
|
||||
}
|
||||
|
||||
public removePage(index: number): Thenable<void> {
|
||||
return this._extHostModelViewDialog.removePage(this, index);
|
||||
}
|
||||
|
||||
public setCurrentPage(index: number): Thenable<void> {
|
||||
return this._extHostModelViewDialog.setWizardPage(this, index);
|
||||
}
|
||||
|
||||
public open(): Thenable<void> {
|
||||
return this._extHostModelViewDialog.openWizard(this);
|
||||
}
|
||||
|
||||
public close(): Thenable<void> {
|
||||
return this._extHostModelViewDialog.closeWizard(this);
|
||||
}
|
||||
|
||||
public registerNavigationValidator(validator: (pageChangeInfo: azdata.window.WizardPageChangeInfo) => boolean | Thenable<boolean>): void {
|
||||
this._navigationValidator = validator;
|
||||
}
|
||||
|
||||
public validateNavigation(info: azdata.window.WizardPageChangeInfo): Thenable<boolean> {
|
||||
if (this._navigationValidator) {
|
||||
return Promise.resolve(this._navigationValidator(info));
|
||||
} else {
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
}
|
||||
|
||||
private handlePageInfoChanged(info: WizardPageEventInfo): void {
|
||||
this._currentPage = info.pageChangeInfo.newPage;
|
||||
if (info.eventType === WizardPageInfoEventType.PageAddedOrRemoved) {
|
||||
this.pages = info.pages;
|
||||
} else if (info.eventType === WizardPageInfoEventType.PageChanged) {
|
||||
this._pageChangedEmitter.fire(info.pageChangeInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class ExtHostModelViewDialog implements ExtHostModelViewDialogShape {
|
||||
private static _currentHandle = 0;
|
||||
|
||||
private readonly _proxy: MainThreadModelViewDialogShape;
|
||||
|
||||
private readonly _objectHandles = new Map<object, number>();
|
||||
private readonly _objectsByHandle = new Map<number, object>();
|
||||
private readonly _validityEmitters = new Map<number, Emitter<boolean>>();
|
||||
private readonly _pageInfoChangedCallbacks = new Map<number, (info: WizardPageEventInfo) => void>();
|
||||
private readonly _onClickCallbacks = new Map<number, () => void>();
|
||||
|
||||
constructor(
|
||||
mainContext: IMainContext,
|
||||
private _extHostModelView: ExtHostModelViewShape,
|
||||
private _extHostTaskManagement: ExtHostBackgroundTaskManagementShape
|
||||
) {
|
||||
this._proxy = mainContext.getProxy(SqlMainContext.MainThreadModelViewDialog);
|
||||
}
|
||||
|
||||
private static getNewHandle() {
|
||||
let handle = ExtHostModelViewDialog._currentHandle;
|
||||
ExtHostModelViewDialog._currentHandle += 1;
|
||||
return handle;
|
||||
}
|
||||
|
||||
private getHandle(item: azdata.window.Button | azdata.window.Dialog | azdata.window.DialogTab
|
||||
| azdata.window.ModelViewPanel | azdata.window.Wizard | azdata.window.WizardPage | azdata.workspace.ModelViewEditor) {
|
||||
let handle = this._objectHandles.get(item);
|
||||
if (handle === undefined) {
|
||||
handle = ExtHostModelViewDialog.getNewHandle();
|
||||
this._objectHandles.set(item, handle);
|
||||
this._objectsByHandle.set(handle, item);
|
||||
}
|
||||
return handle;
|
||||
}
|
||||
|
||||
public $onButtonClick(handle: number): void {
|
||||
this._onClickCallbacks.get(handle)();
|
||||
}
|
||||
|
||||
public $onPanelValidityChanged(handle: number, valid: boolean): void {
|
||||
let emitter = this._validityEmitters.get(handle);
|
||||
if (emitter) {
|
||||
emitter.fire(valid);
|
||||
}
|
||||
}
|
||||
|
||||
public $onWizardPageChanged(handle: number, info: azdata.window.WizardPageChangeInfo): void {
|
||||
let callback = this._pageInfoChangedCallbacks.get(handle);
|
||||
if (callback) {
|
||||
callback({
|
||||
eventType: WizardPageInfoEventType.PageChanged,
|
||||
pageChangeInfo: info
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public $updateWizardPageInfo(handle: number, pageHandles: number[], currentPageIndex: number): void {
|
||||
let callback = this._pageInfoChangedCallbacks.get(handle);
|
||||
if (callback) {
|
||||
let pages = pageHandles.map(pageHandle => this._objectsByHandle.get(pageHandle) as azdata.window.WizardPage);
|
||||
callback({
|
||||
eventType: WizardPageInfoEventType.PageAddedOrRemoved,
|
||||
pageChangeInfo: {
|
||||
lastPage: undefined,
|
||||
newPage: currentPageIndex
|
||||
},
|
||||
pages: pages
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public $validateNavigation(handle: number, info: azdata.window.WizardPageChangeInfo): Thenable<boolean> {
|
||||
let wizard = this._objectsByHandle.get(handle) as WizardImpl;
|
||||
return wizard.validateNavigation(info);
|
||||
}
|
||||
|
||||
public $validateDialogClose(handle: number): Thenable<boolean> {
|
||||
let dialog = this._objectsByHandle.get(handle) as DialogImpl;
|
||||
return dialog.validateClose();
|
||||
}
|
||||
|
||||
public $handleSave(handle: number): Thenable<boolean> {
|
||||
let editor = this._objectsByHandle.get(handle) as ModelViewEditorImpl;
|
||||
return editor.handleSave();
|
||||
}
|
||||
|
||||
public openDialog(dialog: azdata.window.Dialog): void {
|
||||
let handle = this.getHandle(dialog);
|
||||
this.updateDialogContent(dialog);
|
||||
dialog.dialogName ? this._proxy.$openDialog(handle, dialog.dialogName) :
|
||||
this._proxy.$openDialog(handle);
|
||||
}
|
||||
|
||||
public closeDialog(dialog: azdata.window.Dialog): void {
|
||||
let handle = this.getHandle(dialog);
|
||||
this._proxy.$closeDialog(handle);
|
||||
}
|
||||
|
||||
public createModelViewEditor(title: string, extension: IExtensionDescription, options?: azdata.ModelViewEditorOptions): azdata.workspace.ModelViewEditor {
|
||||
let editor = new ModelViewEditorImpl(this, this._extHostModelView, extension, this._proxy, title, options);
|
||||
editor.handle = this.getHandle(editor);
|
||||
return editor;
|
||||
}
|
||||
|
||||
public updateDialogContent(dialog: azdata.window.Dialog): void {
|
||||
let handle = this.getHandle(dialog);
|
||||
let tabs = dialog.content;
|
||||
if (tabs && typeof tabs !== 'string') {
|
||||
tabs.forEach(tab => this.updateTabContent(tab));
|
||||
}
|
||||
if (dialog.customButtons) {
|
||||
dialog.customButtons.forEach(button => this.updateButton(button));
|
||||
}
|
||||
this.updateButton(dialog.okButton);
|
||||
this.updateButton(dialog.cancelButton);
|
||||
this._proxy.$setDialogDetails(handle, {
|
||||
title: dialog.title,
|
||||
isWide: dialog.isWide,
|
||||
okButton: this.getHandle(dialog.okButton),
|
||||
cancelButton: this.getHandle(dialog.cancelButton),
|
||||
content: dialog.content && typeof dialog.content !== 'string' ? dialog.content.map(tab => this.getHandle(tab)) : dialog.content as string,
|
||||
customButtons: dialog.customButtons ? dialog.customButtons.map(button => this.getHandle(button)) : undefined,
|
||||
message: dialog.message
|
||||
});
|
||||
}
|
||||
|
||||
public updateTabContent(tab: azdata.window.DialogTab): void {
|
||||
let handle = this.getHandle(tab);
|
||||
this._proxy.$setTabDetails(handle, {
|
||||
title: tab.title,
|
||||
content: tab.content
|
||||
});
|
||||
}
|
||||
|
||||
public updateButton(button: azdata.window.Button): void {
|
||||
let handle = this.getHandle(button);
|
||||
this._proxy.$setButtonDetails(handle, {
|
||||
label: button.label,
|
||||
enabled: button.enabled,
|
||||
hidden: button.hidden
|
||||
});
|
||||
}
|
||||
|
||||
public registerOnClickCallback(button: azdata.window.Button, callback: () => void) {
|
||||
let handle = this.getHandle(button);
|
||||
this._onClickCallbacks.set(handle, callback);
|
||||
}
|
||||
|
||||
public createDialog(title: string, dialogName?: string, extension?: IExtensionDescription, isWide?: boolean): azdata.window.Dialog {
|
||||
let dialog = new DialogImpl(this, this._extHostModelView, this._extHostTaskManagement, extension);
|
||||
if (dialogName) {
|
||||
dialog.dialogName = dialogName;
|
||||
}
|
||||
dialog.title = title;
|
||||
dialog.isWide = isWide;
|
||||
dialog.handle = this.getHandle(dialog);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public createTab(title: string, extension?: IExtensionDescription): azdata.window.DialogTab {
|
||||
let tab = new TabImpl(this, this._extHostModelView, extension);
|
||||
tab.title = title;
|
||||
tab.handle = this.getHandle(tab);
|
||||
return tab;
|
||||
}
|
||||
|
||||
public createButton(label: string): azdata.window.Button {
|
||||
let button = new ButtonImpl(this);
|
||||
this.getHandle(button);
|
||||
this.registerOnClickCallback(button, button.getOnClickCallback());
|
||||
button.label = label;
|
||||
return button;
|
||||
}
|
||||
|
||||
public getValidityChangedEvent(panel: azdata.window.ModelViewPanel) {
|
||||
let handle = this.getHandle(panel);
|
||||
let emitter = this._validityEmitters.get(handle);
|
||||
if (!emitter) {
|
||||
emitter = new Emitter<boolean>();
|
||||
this._validityEmitters.set(handle, emitter);
|
||||
}
|
||||
return emitter.event;
|
||||
}
|
||||
|
||||
public registerWizardPageInfoChangedCallback(wizard: azdata.window.Wizard, callback: (info: WizardPageEventInfo) => void): void {
|
||||
let handle = this.getHandle(wizard);
|
||||
this._pageInfoChangedCallbacks.set(handle, callback);
|
||||
}
|
||||
|
||||
public createWizardPage(title: string, extension?: IExtensionDescription): azdata.window.WizardPage {
|
||||
let page = new WizardPageImpl(title, this, this._extHostModelView, extension);
|
||||
page.handle = this.getHandle(page);
|
||||
return page;
|
||||
}
|
||||
|
||||
public createWizard(title: string): azdata.window.Wizard {
|
||||
let wizard = new WizardImpl(title, this, this._extHostTaskManagement);
|
||||
this.getHandle(wizard);
|
||||
return wizard;
|
||||
}
|
||||
|
||||
public updateWizardPage(page: azdata.window.WizardPage): Thenable<void> {
|
||||
let handle = this.getHandle(page);
|
||||
if (page.customButtons) {
|
||||
page.customButtons.forEach(button => this.updateButton(button));
|
||||
}
|
||||
return this._proxy.$setWizardPageDetails(handle, {
|
||||
content: page.content,
|
||||
customButtons: page.customButtons ? page.customButtons.map(button => this.getHandle(button)) : undefined,
|
||||
enabled: page.enabled,
|
||||
title: page.title,
|
||||
description: page.description
|
||||
});
|
||||
}
|
||||
|
||||
public updateWizard(wizard: azdata.window.Wizard): Thenable<void> {
|
||||
let handle = this.getHandle(wizard);
|
||||
wizard.pages.forEach(page => this.updateWizardPage(page));
|
||||
this.updateButton(wizard.backButton);
|
||||
this.updateButton(wizard.cancelButton);
|
||||
this.updateButton(wizard.generateScriptButton);
|
||||
this.updateButton(wizard.doneButton);
|
||||
this.updateButton(wizard.nextButton);
|
||||
if (wizard.customButtons) {
|
||||
wizard.customButtons.forEach(button => this.updateButton(button));
|
||||
}
|
||||
return this._proxy.$setWizardDetails(handle, {
|
||||
title: wizard.title,
|
||||
pages: wizard.pages.map(page => this.getHandle(page)),
|
||||
currentPage: wizard.currentPage,
|
||||
backButton: this.getHandle(wizard.backButton),
|
||||
cancelButton: this.getHandle(wizard.cancelButton),
|
||||
generateScriptButton: this.getHandle(wizard.generateScriptButton),
|
||||
doneButton: this.getHandle(wizard.doneButton),
|
||||
nextButton: this.getHandle(wizard.nextButton),
|
||||
customButtons: wizard.customButtons ? wizard.customButtons.map(button => this.getHandle(button)) : undefined,
|
||||
message: wizard.message,
|
||||
displayPageTitles: wizard.displayPageTitles
|
||||
});
|
||||
}
|
||||
|
||||
public addPage(wizard: azdata.window.Wizard, page: azdata.window.WizardPage, pageIndex?: number): Thenable<void> {
|
||||
return this._proxy.$addWizardPage(this.getHandle(wizard), this.getHandle(page), pageIndex);
|
||||
}
|
||||
|
||||
public removePage(wizard: azdata.window.Wizard, pageIndex: number): Thenable<void> {
|
||||
return this._proxy.$removeWizardPage(this.getHandle(wizard), pageIndex);
|
||||
}
|
||||
|
||||
public setWizardPage(wizard: azdata.window.Wizard, pageIndex: number): Thenable<void> {
|
||||
return this._proxy.$setWizardPage(this.getHandle(wizard), pageIndex);
|
||||
}
|
||||
|
||||
public openWizard(wizard: azdata.window.Wizard): Thenable<void> {
|
||||
let handle = this.getHandle(wizard);
|
||||
this.updateWizard(wizard);
|
||||
return this._proxy.$openWizard(handle);
|
||||
}
|
||||
|
||||
public closeWizard(wizard: azdata.window.Wizard): Thenable<void> {
|
||||
let handle = this.getHandle(wizard);
|
||||
return this._proxy.$closeWizard(handle);
|
||||
}
|
||||
}
|
||||
@@ -1,168 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { localize } from 'vs/nls';
|
||||
import * as vscode from 'vscode';
|
||||
import { SqlMainContext, ExtHostModelViewTreeViewsShape, MainThreadModelViewShape } from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
import { ITreeComponentItem } from 'sql/workbench/common/views';
|
||||
import { CommandsConverter } from 'vs/workbench/api/common/extHostCommands';
|
||||
import { IMainContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import * as azdata from 'azdata';
|
||||
import * as vsTreeExt from 'vs/workbench/api/common/extHostTreeViews';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
|
||||
export class ExtHostModelViewTreeViews implements ExtHostModelViewTreeViewsShape {
|
||||
private _proxy: MainThreadModelViewShape;
|
||||
|
||||
private treeViews: Map<string, ExtHostTreeView<any>> = new Map<string, ExtHostTreeView<any>>();
|
||||
|
||||
constructor(
|
||||
private _mainContext: IMainContext
|
||||
) {
|
||||
this._proxy = this._mainContext.getProxy(SqlMainContext.MainThreadModelView);
|
||||
}
|
||||
|
||||
$createTreeView<T>(handle: number, componentId: string, options: { treeDataProvider: azdata.TreeComponentDataProvider<T> }, extension: IExtensionDescription): azdata.TreeComponentView<T> {
|
||||
if (!options || !options.treeDataProvider) {
|
||||
throw new Error('Options with treeDataProvider is mandatory');
|
||||
}
|
||||
|
||||
const treeView = this.createExtHostTreeViewer(handle, componentId, options.treeDataProvider, extension);
|
||||
return {
|
||||
dispose: () => {
|
||||
this.treeViews.delete(componentId);
|
||||
treeView.dispose();
|
||||
},
|
||||
onNodeCheckedChanged: treeView.NodeCheckedChanged,
|
||||
onDidChangeSelection: treeView.ChangeSelection
|
||||
};
|
||||
}
|
||||
|
||||
$getChildren(treeViewId: string, treeItemHandle?: string): Promise<ITreeComponentItem[]> {
|
||||
const treeView = this.treeViews.get(treeViewId);
|
||||
if (!treeView) {
|
||||
|
||||
return Promise.reject(new Error(localize('treeView.notRegistered', 'No tree view with id \'{0}\' registered.', treeViewId)));
|
||||
}
|
||||
return treeView.getChildren(treeItemHandle);
|
||||
}
|
||||
|
||||
$onNodeCheckedChanged(treeViewId: string, treeItemHandle?: string, checked?: boolean): void {
|
||||
const treeView = this.treeViews.get(treeViewId);
|
||||
if (treeView) {
|
||||
treeView.onNodeCheckedChanged(treeItemHandle, checked);
|
||||
}
|
||||
}
|
||||
|
||||
$onNodeSelected(treeViewId: string, handles: string[]): void {
|
||||
const treeView = this.treeViews.get(treeViewId);
|
||||
if (treeView) {
|
||||
treeView.onNodeSelectedChanged(handles);
|
||||
}
|
||||
}
|
||||
|
||||
$setExpanded(treeViewId: string, treeItemHandle: string, expanded: boolean): void {
|
||||
}
|
||||
|
||||
$setSelection(treeViewId: string, treeItemHandles: string[]): void {
|
||||
}
|
||||
|
||||
$setVisible(treeViewId: string, visible: boolean): void {
|
||||
}
|
||||
|
||||
private createExtHostTreeViewer<T>(handle: number, id: string, dataProvider: azdata.TreeComponentDataProvider<T>, extension: IExtensionDescription): ExtHostTreeView<T> {
|
||||
const treeView = new ExtHostTreeView<T>(handle, id, dataProvider, this._proxy, undefined, extension);
|
||||
this.treeViews.set(`${handle}-${id}`, treeView);
|
||||
return treeView;
|
||||
}
|
||||
}
|
||||
|
||||
export class ExtHostTreeView<T> extends vsTreeExt.ExtHostTreeView<T> {
|
||||
|
||||
private _onNodeCheckedChanged = new Emitter<azdata.NodeCheckedEventParameters<T>>();
|
||||
private _onChangeSelection = new Emitter<vscode.TreeViewSelectionChangeEvent<T>>();
|
||||
public readonly NodeCheckedChanged: vscode.Event<azdata.NodeCheckedEventParameters<T>> = this._onNodeCheckedChanged.event;
|
||||
public readonly ChangeSelection: vscode.Event<vscode.TreeViewSelectionChangeEvent<T>> = this._onChangeSelection.event;
|
||||
constructor(
|
||||
private handle: number, private componentId: string, private componentDataProvider: azdata.TreeComponentDataProvider<T>,
|
||||
private modelViewProxy: MainThreadModelViewShape, commands: CommandsConverter, extension: IExtensionDescription) {
|
||||
super(componentId, { treeDataProvider: componentDataProvider }, undefined, commands, undefined, extension);
|
||||
}
|
||||
|
||||
onNodeCheckedChanged(parentHandle?: vsTreeExt.TreeItemHandle, checked?: boolean): void {
|
||||
const parentElement = parentHandle ? this.getExtensionElement(parentHandle) : void 0;
|
||||
if (parentHandle && !parentElement) {
|
||||
console.error(`No tree item with id \'${parentHandle}\' found.`);
|
||||
}
|
||||
|
||||
this._onNodeCheckedChanged.fire({ element: parentElement, checked: checked });
|
||||
}
|
||||
|
||||
onNodeSelectedChanged(parentHandles?: vsTreeExt.TreeItemHandle[]): void {
|
||||
if (parentHandles) {
|
||||
let nodes = parentHandles.map(parentHandle => {
|
||||
return parentHandle ? this.getExtensionElement(parentHandle) : void 0;
|
||||
});
|
||||
this._onChangeSelection.fire({ selection: nodes });
|
||||
}
|
||||
}
|
||||
|
||||
reveal(element: T, options?: { select?: boolean }): Promise<void> {
|
||||
if (typeof this.componentDataProvider.getParent !== 'function') {
|
||||
return Promise.reject(new Error(`Required registered TreeDataProvider to implement 'getParent' method to access 'reveal' method`));
|
||||
}
|
||||
let i: void;
|
||||
return Promise.resolve(this.resolveUnknownParentChain(element)
|
||||
.then(parentChain => this.resolveTreeNode(element, parentChain[parentChain.length - 1])
|
||||
.then(treeNode => i)));
|
||||
}
|
||||
|
||||
protected refreshElements(elements: T[]): void {
|
||||
const hasRoot = elements.some(element => !element);
|
||||
if (hasRoot) {
|
||||
this.clearAll(); // clear cache
|
||||
this.modelViewProxy.$refreshDataProvider(this.handle, this.componentId);
|
||||
} else {
|
||||
const handlesToRefresh = this.getHandlesToRefresh(elements);
|
||||
if (handlesToRefresh.length) {
|
||||
this.refreshHandles(handlesToRefresh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected refreshHandles(itemHandles: vsTreeExt.TreeItemHandle[]): Promise<void> {
|
||||
const itemsToRefresh: { [treeItemHandle: string]: ITreeComponentItem } = {};
|
||||
return Promise.all(itemHandles.map(treeItemHandle =>
|
||||
this.refreshNode(treeItemHandle)
|
||||
.then(node => {
|
||||
if (node) {
|
||||
itemsToRefresh[treeItemHandle] = node.item;
|
||||
}
|
||||
})))
|
||||
.then(() => Object.keys(itemsToRefresh).length ? this.modelViewProxy.$refreshDataProvider(this.handle, this.componentId, itemsToRefresh) : null);
|
||||
}
|
||||
|
||||
protected refreshNode(treeItemHandle: vsTreeExt.TreeItemHandle): Promise<vsTreeExt.TreeNode> {
|
||||
const extElement = this.getExtensionElement(treeItemHandle);
|
||||
const existing = this.nodes.get(extElement);
|
||||
//this.clearChildren(extElement); // clear children cache
|
||||
return Promise.resolve(this.componentDataProvider.getTreeItem(extElement))
|
||||
.then(extTreeItem => {
|
||||
if (extTreeItem) {
|
||||
const newNode = this.createTreeNode(extElement, extTreeItem, existing.parent);
|
||||
this.updateNodeCache(extElement, newNode, existing, existing.parent);
|
||||
return newNode;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
protected createTreeNode(element: T, extensionTreeItem: azdata.TreeComponentItem, parent?: vsTreeExt.TreeNode): vsTreeExt.TreeNode {
|
||||
let item = super.createTreeNode(element, extensionTreeItem, parent);
|
||||
item = Object.assign({}, item, { checked: extensionTreeItem.checked, enabled: extensionTreeItem.enabled });
|
||||
return item;
|
||||
}
|
||||
}
|
||||
@@ -1,356 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
import { IMainContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { Disposable } from 'vs/workbench/api/common/extHostTypes';
|
||||
import { localize } from 'vs/nls';
|
||||
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
|
||||
import { ExtHostNotebookShape, MainThreadNotebookShape, SqlMainContext } from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
import { INotebookManagerDetails, INotebookSessionDetails, INotebookKernelDetails, INotebookFutureDetails, FutureMessageType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
|
||||
type Adapter = azdata.nb.NotebookProvider | azdata.nb.NotebookManager | azdata.nb.ISession | azdata.nb.IKernel | azdata.nb.IFuture;
|
||||
|
||||
export class ExtHostNotebook implements ExtHostNotebookShape {
|
||||
private static _handlePool: number = 0;
|
||||
|
||||
private readonly _proxy: MainThreadNotebookShape;
|
||||
private _adapters = new Map<number, Adapter>();
|
||||
|
||||
// Notebook URI to manager lookup.
|
||||
constructor(_mainContext: IMainContext) {
|
||||
this._proxy = _mainContext.getProxy(SqlMainContext.MainThreadNotebook);
|
||||
}
|
||||
|
||||
//#region APIs called by main thread
|
||||
async $getNotebookManager(providerHandle: number, notebookUri: UriComponents): Promise<INotebookManagerDetails> {
|
||||
let uri = URI.revive(notebookUri);
|
||||
let uriString = uri.toString();
|
||||
let adapter = this.findManagerForUri(uriString);
|
||||
if (!adapter) {
|
||||
adapter = await this._withProvider(providerHandle, (provider) => {
|
||||
return this.createManager(provider, uri);
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
handle: adapter.handle,
|
||||
hasContentManager: !!adapter.contentManager,
|
||||
hasServerManager: !!adapter.serverManager
|
||||
};
|
||||
}
|
||||
$handleNotebookClosed(notebookUri: UriComponents): void {
|
||||
let uri = URI.revive(notebookUri);
|
||||
let uriString = uri.toString();
|
||||
let manager = this.findManagerForUri(uriString);
|
||||
if (manager) {
|
||||
manager.provider.handleNotebookClosed(uri);
|
||||
this._adapters.delete(manager.handle);
|
||||
}
|
||||
}
|
||||
|
||||
$doStartServer(managerHandle: number): Thenable<void> {
|
||||
return this._withServerManager(managerHandle, (serverManager) => serverManager.startServer());
|
||||
}
|
||||
|
||||
$doStopServer(managerHandle: number): Thenable<void> {
|
||||
return this._withServerManager(managerHandle, (serverManager) => serverManager.stopServer());
|
||||
}
|
||||
|
||||
$getNotebookContents(managerHandle: number, notebookUri: UriComponents): Thenable<azdata.nb.INotebookContents> {
|
||||
return this._withContentManager(managerHandle, (contentManager) => contentManager.getNotebookContents(URI.revive(notebookUri)));
|
||||
}
|
||||
|
||||
$save(managerHandle: number, notebookUri: UriComponents, notebook: azdata.nb.INotebookContents): Thenable<azdata.nb.INotebookContents> {
|
||||
return this._withContentManager(managerHandle, (contentManager) => contentManager.save(URI.revive(notebookUri), notebook));
|
||||
}
|
||||
|
||||
$refreshSpecs(managerHandle: number): Thenable<azdata.nb.IAllKernels> {
|
||||
return this._withSessionManager(managerHandle, async (sessionManager) => {
|
||||
await sessionManager.ready;
|
||||
return sessionManager.specs;
|
||||
});
|
||||
}
|
||||
|
||||
$startNewSession(managerHandle: number, options: azdata.nb.ISessionOptions): Thenable<INotebookSessionDetails> {
|
||||
return this._withSessionManager(managerHandle, async (sessionManager) => {
|
||||
try {
|
||||
let session = await sessionManager.startNew(options);
|
||||
let sessionId = this._addNewAdapter(session);
|
||||
let kernelDetails: INotebookKernelDetails = undefined;
|
||||
if (session.kernel) {
|
||||
kernelDetails = this.saveKernel(session.kernel);
|
||||
}
|
||||
let details: INotebookSessionDetails = {
|
||||
sessionId: sessionId,
|
||||
id: session.id,
|
||||
path: session.path,
|
||||
name: session.name,
|
||||
type: session.type,
|
||||
status: session.status,
|
||||
canChangeKernels: session.canChangeKernels,
|
||||
kernelDetails: kernelDetails
|
||||
};
|
||||
return details;
|
||||
} catch (error) {
|
||||
throw typeof (error) === 'string' ? new Error(error) : error;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private saveKernel(kernel: azdata.nb.IKernel): INotebookKernelDetails {
|
||||
let kernelId = this._addNewAdapter(kernel);
|
||||
let kernelDetails: INotebookKernelDetails = {
|
||||
kernelId: kernelId,
|
||||
id: kernel.id,
|
||||
info: kernel.info,
|
||||
name: kernel.name,
|
||||
supportsIntellisense: kernel.supportsIntellisense,
|
||||
requiresConnection: kernel.requiresConnection
|
||||
};
|
||||
return kernelDetails;
|
||||
}
|
||||
|
||||
$shutdownSession(managerHandle: number, sessionId: string): Thenable<void> {
|
||||
// If manager handle has already been removed, don't try to access it again when shutting down
|
||||
if (this._adapters.get(managerHandle) === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
return this._withSessionManager(managerHandle, async (sessionManager) => {
|
||||
return sessionManager.shutdown(sessionId);
|
||||
});
|
||||
}
|
||||
|
||||
$changeKernel(sessionId: number, kernelInfo: azdata.nb.IKernelSpec): Thenable<INotebookKernelDetails> {
|
||||
let session = this._getAdapter<azdata.nb.ISession>(sessionId);
|
||||
return session.changeKernel(kernelInfo).then(kernel => this.saveKernel(kernel));
|
||||
}
|
||||
|
||||
$configureKernel(sessionId: number, kernelInfo: azdata.nb.IKernelSpec): Thenable<void> {
|
||||
let session = this._getAdapter<azdata.nb.ISession>(sessionId);
|
||||
return session.configureKernel(kernelInfo).then(() => null);
|
||||
}
|
||||
|
||||
$configureConnection(sessionId: number, connection: azdata.IConnectionProfile): Thenable<void> {
|
||||
let session = this._getAdapter<azdata.nb.ISession>(sessionId);
|
||||
return session.configureConnection(connection).then(() => null);
|
||||
}
|
||||
|
||||
$getKernelReadyStatus(kernelId: number): Thenable<azdata.nb.IInfoReply> {
|
||||
let kernel = this._getAdapter<azdata.nb.IKernel>(kernelId);
|
||||
return kernel.ready.then(success => kernel.info);
|
||||
}
|
||||
|
||||
$getKernelSpec(kernelId: number): Thenable<azdata.nb.IKernelSpec> {
|
||||
let kernel = this._getAdapter<azdata.nb.IKernel>(kernelId);
|
||||
return kernel.getSpec();
|
||||
}
|
||||
|
||||
$requestComplete(kernelId: number, content: azdata.nb.ICompleteRequest): Thenable<azdata.nb.ICompleteReplyMsg> {
|
||||
let kernel = this._getAdapter<azdata.nb.IKernel>(kernelId);
|
||||
return kernel.requestComplete(content);
|
||||
}
|
||||
|
||||
$requestExecute(kernelId: number, content: azdata.nb.IExecuteRequest, disposeOnDone?: boolean): Thenable<INotebookFutureDetails> {
|
||||
let kernel = this._getAdapter<azdata.nb.IKernel>(kernelId);
|
||||
let future = kernel.requestExecute(content, disposeOnDone);
|
||||
let futureId = this._addNewAdapter(future);
|
||||
this.hookFutureDone(futureId, future);
|
||||
this.hookFutureMessages(futureId, future);
|
||||
return Promise.resolve({
|
||||
futureId: futureId,
|
||||
msg: future.msg
|
||||
});
|
||||
}
|
||||
|
||||
private hookFutureDone(futureId: number, future: azdata.nb.IFuture): void {
|
||||
future.done.then(success => {
|
||||
return this._proxy.$onFutureDone(futureId, { succeeded: true, message: success, rejectReason: undefined });
|
||||
}, err => {
|
||||
let rejectReason: string;
|
||||
if (typeof err === 'string') {
|
||||
rejectReason = err;
|
||||
}
|
||||
else if (err instanceof Error && typeof err.message === 'string') {
|
||||
rejectReason = err.message;
|
||||
}
|
||||
else {
|
||||
rejectReason = err;
|
||||
}
|
||||
return this._proxy.$onFutureDone(futureId, { succeeded: false, message: undefined, rejectReason: rejectReason });
|
||||
});
|
||||
}
|
||||
|
||||
private hookFutureMessages(futureId: number, future: azdata.nb.IFuture): void {
|
||||
future.setReplyHandler({ handle: (msg) => this._proxy.$onFutureMessage(futureId, FutureMessageType.Reply, msg) });
|
||||
future.setStdInHandler({ handle: (msg) => this._proxy.$onFutureMessage(futureId, FutureMessageType.StdIn, msg) });
|
||||
future.setIOPubHandler({ handle: (msg) => this._proxy.$onFutureMessage(futureId, FutureMessageType.IOPub, msg) });
|
||||
}
|
||||
|
||||
$interruptKernel(kernelId: number): Thenable<void> {
|
||||
let kernel = this._getAdapter<azdata.nb.IKernel>(kernelId);
|
||||
return kernel.interrupt();
|
||||
}
|
||||
|
||||
$sendInputReply(futureId: number, content: azdata.nb.IInputReply): void {
|
||||
let future = this._getAdapter<azdata.nb.IFuture>(futureId);
|
||||
return future.sendInputReply(content);
|
||||
}
|
||||
|
||||
$disposeFuture(futureId: number): void {
|
||||
let future = this._getAdapter<azdata.nb.IFuture>(futureId);
|
||||
future.dispose();
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region APIs called by extensions
|
||||
registerNotebookProvider(provider: azdata.nb.NotebookProvider): vscode.Disposable {
|
||||
if (!provider || !provider.providerId) {
|
||||
throw new Error(localize('providerRequired', 'A NotebookProvider with valid providerId must be passed to this method'));
|
||||
}
|
||||
const handle = this._addNewAdapter(provider);
|
||||
this._proxy.$registerNotebookProvider(provider.providerId, handle);
|
||||
return this._createDisposable(handle);
|
||||
}
|
||||
//#endregion
|
||||
|
||||
|
||||
//#region private methods
|
||||
|
||||
private getAdapters<A>(ctor: { new(...args: any[]): A }): A[] {
|
||||
let matchingAdapters = [];
|
||||
this._adapters.forEach(a => {
|
||||
if (a instanceof ctor) {
|
||||
matchingAdapters.push(a);
|
||||
}
|
||||
});
|
||||
return matchingAdapters;
|
||||
}
|
||||
|
||||
private findManagerForUri(uriString: string): NotebookManagerAdapter {
|
||||
for (let manager of this.getAdapters(NotebookManagerAdapter)) {
|
||||
if (manager.uriString === uriString) {
|
||||
return manager;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private async createManager(provider: azdata.nb.NotebookProvider, notebookUri: URI): Promise<NotebookManagerAdapter> {
|
||||
let manager = await provider.getNotebookManager(notebookUri);
|
||||
let uriString = notebookUri.toString();
|
||||
let adapter = new NotebookManagerAdapter(provider, manager, uriString);
|
||||
adapter.handle = this._addNewAdapter(adapter);
|
||||
return adapter;
|
||||
}
|
||||
|
||||
private _createDisposable(handle: number): Disposable {
|
||||
return new Disposable(() => {
|
||||
this._adapters.delete(handle);
|
||||
});
|
||||
}
|
||||
|
||||
private _nextHandle(): number {
|
||||
return ExtHostNotebook._handlePool++;
|
||||
}
|
||||
|
||||
private _withProvider<R>(handle: number, callback: (provider: azdata.nb.NotebookProvider) => R | PromiseLike<R>): Promise<R> {
|
||||
let provider = this._adapters.get(handle) as azdata.nb.NotebookProvider;
|
||||
if (provider === undefined) {
|
||||
return Promise.reject(new Error(localize('errNoProvider', 'no notebook provider found')));
|
||||
}
|
||||
return Promise.resolve(callback(provider));
|
||||
}
|
||||
|
||||
private _withNotebookManager<R>(handle: number, callback: (manager: NotebookManagerAdapter) => R | PromiseLike<R>): Promise<R> {
|
||||
let manager = this._adapters.get(handle) as NotebookManagerAdapter;
|
||||
if (manager === undefined) {
|
||||
return Promise.reject(new Error(localize('errNoManager', 'No Manager found')));
|
||||
}
|
||||
return this.callbackWithErrorWrap<R>(callback, manager);
|
||||
}
|
||||
|
||||
private async callbackWithErrorWrap<R>(callback: (manager: NotebookManagerAdapter) => R | PromiseLike<R>, manager: NotebookManagerAdapter): Promise<R> {
|
||||
try {
|
||||
let value = await callback(manager);
|
||||
return value;
|
||||
} catch (error) {
|
||||
throw typeof (error) === 'string' ? new Error(error) : error;
|
||||
}
|
||||
}
|
||||
|
||||
private _withServerManager<R>(handle: number, callback: (manager: azdata.nb.ServerManager) => R | PromiseLike<R>): Promise<R> {
|
||||
return this._withNotebookManager(handle, (notebookManager) => {
|
||||
let serverManager = notebookManager.serverManager;
|
||||
if (!serverManager) {
|
||||
return Promise.reject(new Error(localize('noServerManager', 'Notebook Manager for notebook {0} does not have a server manager. Cannot perform operations on it', notebookManager.uriString)));
|
||||
}
|
||||
return callback(serverManager);
|
||||
});
|
||||
}
|
||||
|
||||
private _withContentManager<R>(handle: number, callback: (manager: azdata.nb.ContentManager) => R | PromiseLike<R>): Promise<R> {
|
||||
return this._withNotebookManager(handle, (notebookManager) => {
|
||||
let contentManager = notebookManager.contentManager;
|
||||
if (!contentManager) {
|
||||
return Promise.reject(new Error(localize('noContentManager', 'Notebook Manager for notebook {0} does not have a content manager. Cannot perform operations on it', notebookManager.uriString)));
|
||||
}
|
||||
return callback(contentManager);
|
||||
});
|
||||
}
|
||||
|
||||
private _withSessionManager<R>(handle: number, callback: (manager: azdata.nb.SessionManager) => R | PromiseLike<R>): Promise<R> {
|
||||
return this._withNotebookManager(handle, (notebookManager) => {
|
||||
let sessionManager = notebookManager.sessionManager;
|
||||
if (!sessionManager) {
|
||||
return Promise.reject(new Error(localize('noSessionManager', 'Notebook Manager for notebook {0} does not have a session manager. Cannot perform operations on it', notebookManager.uriString)));
|
||||
}
|
||||
return callback(sessionManager);
|
||||
});
|
||||
}
|
||||
|
||||
private _addNewAdapter(adapter: Adapter): number {
|
||||
const handle = this._nextHandle();
|
||||
this._adapters.set(handle, adapter);
|
||||
return handle;
|
||||
}
|
||||
|
||||
private _getAdapter<T>(id: number): T {
|
||||
let adapter = <T><any>this._adapters.get(id);
|
||||
if (adapter === undefined) {
|
||||
throw new Error('No adapter found');
|
||||
}
|
||||
return adapter;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
}
|
||||
|
||||
|
||||
class NotebookManagerAdapter implements azdata.nb.NotebookManager {
|
||||
public handle: number;
|
||||
constructor(
|
||||
public readonly provider: azdata.nb.NotebookProvider,
|
||||
private manager: azdata.nb.NotebookManager,
|
||||
public readonly uriString: string
|
||||
) {
|
||||
}
|
||||
|
||||
public get contentManager(): azdata.nb.ContentManager {
|
||||
return this.manager.contentManager;
|
||||
}
|
||||
|
||||
public get sessionManager(): azdata.nb.SessionManager {
|
||||
return this.manager.sessionManager;
|
||||
}
|
||||
|
||||
public get serverManager(): azdata.nb.ServerManager {
|
||||
return this.manager.serverManager;
|
||||
}
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { ok } from 'vs/base/common/assert';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
|
||||
import { MainThreadNotebookDocumentsAndEditorsShape, INotebookModelChangedData } from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
import { CellRange } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
|
||||
|
||||
export class ExtHostNotebookDocumentData implements IDisposable {
|
||||
private _document: azdata.nb.NotebookDocument;
|
||||
private _isDisposed: boolean = false;
|
||||
private _kernelSpec: azdata.nb.IKernelSpec;
|
||||
|
||||
constructor(private readonly _proxy: MainThreadNotebookDocumentsAndEditorsShape,
|
||||
private readonly _uri: URI,
|
||||
private _providerId: string,
|
||||
private _isDirty: boolean,
|
||||
private _cells: azdata.nb.NotebookCell[]
|
||||
) {
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
// we don't really dispose documents but let
|
||||
// extensions still read from them. some
|
||||
// operations, live saving, will now error tho
|
||||
ok(!this._isDisposed);
|
||||
this._isDisposed = true;
|
||||
this._isDirty = false;
|
||||
}
|
||||
|
||||
|
||||
get document(): azdata.nb.NotebookDocument {
|
||||
if (!this._document) {
|
||||
const data = this;
|
||||
this._document = {
|
||||
get uri() { return data._uri; },
|
||||
get fileName() { return data._uri.fsPath; },
|
||||
get isUntitled() { return data._uri.scheme === Schemas.untitled; },
|
||||
get providerId() { return data._providerId; },
|
||||
get isClosed() { return data._isDisposed; },
|
||||
get isDirty() { return data._isDirty; },
|
||||
get cells() { return data._cells; },
|
||||
get kernelSpec() { return data._kernelSpec; },
|
||||
save() { return data._save(); },
|
||||
validateCellRange(range) { return data._validateRange(range); },
|
||||
};
|
||||
}
|
||||
return Object.freeze(this._document);
|
||||
}
|
||||
|
||||
private _save(): Thenable<boolean> {
|
||||
if (this._isDisposed) {
|
||||
return Promise.reject(new Error('Document has been closed'));
|
||||
}
|
||||
return this._proxy.$trySaveDocument(this._uri);
|
||||
|
||||
}
|
||||
|
||||
public onModelChanged(data: INotebookModelChangedData) {
|
||||
if (data) {
|
||||
this._isDirty = data.isDirty;
|
||||
this._cells = data.cells;
|
||||
this._providerId = data.providerId;
|
||||
this._kernelSpec = data.kernelSpec;
|
||||
}
|
||||
}
|
||||
|
||||
// ---- range math
|
||||
|
||||
private _validateRange(range: azdata.nb.CellRange): azdata.nb.CellRange {
|
||||
if (!(range instanceof CellRange)) {
|
||||
throw new Error('Invalid argument');
|
||||
}
|
||||
|
||||
let start = this._validateIndex(range.start);
|
||||
let end = this._validateIndex(range.end);
|
||||
|
||||
if (start === range.start && end === range.end) {
|
||||
return range;
|
||||
}
|
||||
return new CellRange(start, end);
|
||||
}
|
||||
|
||||
private _validateIndex(index: number): number {
|
||||
if (typeof (index) !== 'number') {
|
||||
throw new Error('Invalid argument');
|
||||
}
|
||||
|
||||
if (index < 0) {
|
||||
index = 0;
|
||||
} else if (this._cells.length > 0 && index > this._cells.length) {
|
||||
// We allow off by 1 as end needs to be outside current length in order to
|
||||
// handle replace scenario. Long term should consider different start vs end validation instead
|
||||
index = this._cells.length;
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,260 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { dispose } from 'vs/base/common/lifecycle';
|
||||
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import { Disposable } from 'vs/workbench/api/common/extHostTypes';
|
||||
import * as typeConverters from 'vs/workbench/api/common/extHostTypeConverters';
|
||||
import { IMainContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { ok } from 'vs/base/common/assert';
|
||||
import { localize } from 'vs/nls';
|
||||
|
||||
import {
|
||||
SqlMainContext, INotebookDocumentsAndEditorsDelta, ExtHostNotebookDocumentsAndEditorsShape,
|
||||
MainThreadNotebookDocumentsAndEditorsShape, INotebookShowOptions, INotebookModelChangedData
|
||||
} from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
import { ExtHostNotebookDocumentData } from 'sql/workbench/api/node/extHostNotebookDocumentData';
|
||||
import { ExtHostNotebookEditor } from 'sql/workbench/api/node/extHostNotebookEditor';
|
||||
|
||||
type Adapter = azdata.nb.NavigationProvider;
|
||||
|
||||
export class ExtHostNotebookDocumentsAndEditors implements ExtHostNotebookDocumentsAndEditorsShape {
|
||||
private static _handlePool: number = 0;
|
||||
|
||||
private _disposables: Disposable[] = [];
|
||||
private _adapters = new Map<number, Adapter>();
|
||||
|
||||
private _activeEditorId: string;
|
||||
private _proxy: MainThreadNotebookDocumentsAndEditorsShape;
|
||||
|
||||
private readonly _editors = new Map<string, ExtHostNotebookEditor>();
|
||||
private readonly _documents = new Map<string, ExtHostNotebookDocumentData>();
|
||||
|
||||
private readonly _onDidChangeVisibleNotebookEditors = new Emitter<ExtHostNotebookEditor[]>();
|
||||
private readonly _onDidChangeActiveNotebookEditor = new Emitter<ExtHostNotebookEditor>();
|
||||
private _onDidOpenNotebook = new Emitter<azdata.nb.NotebookDocument>();
|
||||
private _onDidChangeNotebookCell = new Emitter<azdata.nb.NotebookCellChangeEvent>();
|
||||
|
||||
readonly onDidChangeVisibleNotebookEditors: Event<ExtHostNotebookEditor[]> = this._onDidChangeVisibleNotebookEditors.event;
|
||||
readonly onDidChangeActiveNotebookEditor: Event<ExtHostNotebookEditor> = this._onDidChangeActiveNotebookEditor.event;
|
||||
readonly onDidOpenNotebookDocument: Event<azdata.nb.NotebookDocument> = this._onDidOpenNotebook.event;
|
||||
readonly onDidChangeNotebookCell: Event<azdata.nb.NotebookCellChangeEvent> = this._onDidChangeNotebookCell.event;
|
||||
|
||||
|
||||
constructor(
|
||||
private readonly _mainContext: IMainContext,
|
||||
) {
|
||||
if (this._mainContext) {
|
||||
this._proxy = this._mainContext.getProxy(SqlMainContext.MainThreadNotebookDocumentsAndEditors);
|
||||
}
|
||||
}
|
||||
|
||||
dispose() {
|
||||
this._disposables = dispose(this._disposables);
|
||||
}
|
||||
|
||||
//#region Main Thread accessible methods
|
||||
$acceptDocumentsAndEditorsDelta(delta: INotebookDocumentsAndEditorsDelta): void {
|
||||
|
||||
const removedDocuments: ExtHostNotebookDocumentData[] = [];
|
||||
const addedDocuments: ExtHostNotebookDocumentData[] = [];
|
||||
const removedEditors: ExtHostNotebookEditor[] = [];
|
||||
|
||||
if (delta.removedDocuments) {
|
||||
for (const uriComponent of delta.removedDocuments) {
|
||||
const uri = URI.revive(uriComponent);
|
||||
const id = uri.toString();
|
||||
const data = this._documents.get(id);
|
||||
this._documents.delete(id);
|
||||
removedDocuments.push(data);
|
||||
}
|
||||
}
|
||||
|
||||
if (delta.addedDocuments) {
|
||||
for (const data of delta.addedDocuments) {
|
||||
const resource = URI.revive(data.uri);
|
||||
ok(!this._documents.has(resource.toString()), `document '${resource} already exists!'`);
|
||||
|
||||
const documentData = new ExtHostNotebookDocumentData(
|
||||
this._proxy,
|
||||
resource,
|
||||
data.providerId,
|
||||
data.isDirty,
|
||||
data.cells
|
||||
);
|
||||
this._documents.set(resource.toString(), documentData);
|
||||
addedDocuments.push(documentData);
|
||||
}
|
||||
}
|
||||
|
||||
if (delta.removedEditors) {
|
||||
for (const id of delta.removedEditors) {
|
||||
const editor = this._editors.get(id);
|
||||
this._editors.delete(id);
|
||||
removedEditors.push(editor);
|
||||
}
|
||||
}
|
||||
|
||||
if (delta.addedEditors) {
|
||||
for (const data of delta.addedEditors) {
|
||||
const resource = URI.revive(data.documentUri);
|
||||
ok(this._documents.has(resource.toString()), `document '${resource}' does not exist`);
|
||||
ok(!this._editors.has(data.id), `editor '${data.id}' already exists!`);
|
||||
|
||||
const documentData = this._documents.get(resource.toString());
|
||||
const editor = new ExtHostNotebookEditor(
|
||||
this._mainContext.getProxy(SqlMainContext.MainThreadNotebookDocumentsAndEditors),
|
||||
data.id,
|
||||
documentData,
|
||||
typeof data.editorPosition === 'number' ? typeConverters.ViewColumn.to(data.editorPosition) : undefined
|
||||
);
|
||||
this._editors.set(data.id, editor);
|
||||
}
|
||||
}
|
||||
|
||||
if (delta.newActiveEditor !== undefined) {
|
||||
ok(delta.newActiveEditor === null || this._editors.has(delta.newActiveEditor), `active editor '${delta.newActiveEditor}' does not exist`);
|
||||
this._activeEditorId = delta.newActiveEditor;
|
||||
}
|
||||
|
||||
dispose(removedDocuments);
|
||||
dispose(removedEditors);
|
||||
|
||||
// now that the internal state is complete, fire events
|
||||
if (removedDocuments) {
|
||||
// TODO add doc close event
|
||||
}
|
||||
if (addedDocuments) {
|
||||
addedDocuments.forEach(d => this._onDidOpenNotebook.fire(d.document));
|
||||
}
|
||||
|
||||
if (delta.removedEditors || delta.addedEditors) {
|
||||
this._onDidChangeVisibleNotebookEditors.fire(this.getAllEditors());
|
||||
}
|
||||
if (delta.newActiveEditor !== undefined) {
|
||||
this._onDidChangeActiveNotebookEditor.fire(this.getActiveEditor());
|
||||
}
|
||||
}
|
||||
|
||||
$acceptModelChanged(uriComponents: UriComponents, e: INotebookModelChangedData): void {
|
||||
const uri = URI.revive(uriComponents);
|
||||
const strURL = uri.toString();
|
||||
let data = this._documents.get(strURL);
|
||||
if (data) {
|
||||
data.onModelChanged(e);
|
||||
this._onDidChangeNotebookCell.fire({
|
||||
cells: data.document.cells,
|
||||
notebook: data.document,
|
||||
kind: e.changeKind
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private _nextHandle(): number {
|
||||
return ExtHostNotebookDocumentsAndEditors._handlePool++;
|
||||
}
|
||||
|
||||
private _addNewAdapter(adapter: Adapter): number {
|
||||
const handle = this._nextHandle();
|
||||
this._adapters.set(handle, adapter);
|
||||
return handle;
|
||||
}
|
||||
|
||||
private _getAdapter<T>(id: number): T {
|
||||
let adapter = <T><any>this._adapters.get(id);
|
||||
if (adapter === undefined) {
|
||||
throw new Error('No adapter found');
|
||||
}
|
||||
return adapter;
|
||||
}
|
||||
|
||||
$getNavigation(handle: number, notebookUri: UriComponents): Thenable<azdata.nb.NavigationResult> {
|
||||
let navProvider = this._getAdapter<azdata.nb.NavigationProvider>(handle);
|
||||
if (navProvider) {
|
||||
let uri = URI.revive(notebookUri);
|
||||
return navProvider.getNavigation(uri);
|
||||
}
|
||||
throw new Error('No navigation provider found for handle ${handle}');
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Extension accessible methods
|
||||
showNotebookDocument(uri: vscode.Uri, showOptions: azdata.nb.NotebookShowOptions): Thenable<azdata.nb.NotebookEditor> {
|
||||
return this.doShowNotebookDocument(uri, showOptions);
|
||||
}
|
||||
|
||||
private async doShowNotebookDocument(uri: vscode.Uri, showOptions: azdata.nb.NotebookShowOptions): Promise<azdata.nb.NotebookEditor> {
|
||||
let options: INotebookShowOptions = {};
|
||||
if (showOptions) {
|
||||
options.preserveFocus = showOptions.preserveFocus;
|
||||
options.preview = showOptions.preview;
|
||||
options.position = showOptions.viewColumn;
|
||||
options.providerId = showOptions.providerId;
|
||||
options.connectionProfile = showOptions.connectionProfile;
|
||||
options.defaultKernel = showOptions.defaultKernel;
|
||||
if (showOptions.initialContent) {
|
||||
if (typeof (showOptions.initialContent) !== 'string') {
|
||||
options.initialContent = JSON.stringify(showOptions.initialContent);
|
||||
} else {
|
||||
options.initialContent = showOptions.initialContent;
|
||||
}
|
||||
}
|
||||
options.initialDirtyState = showOptions.initialDirtyState;
|
||||
}
|
||||
let id = await this._proxy.$tryShowNotebookDocument(uri, options);
|
||||
let editor = this.getEditor(id);
|
||||
if (editor) {
|
||||
return editor;
|
||||
} else {
|
||||
throw new Error(`Failed to show notebook document ${uri.toString()}, should show in editor #${id}`);
|
||||
}
|
||||
}
|
||||
|
||||
getDocument(strUrl: string): ExtHostNotebookDocumentData {
|
||||
return this._documents.get(strUrl);
|
||||
}
|
||||
|
||||
getAllDocuments(): ExtHostNotebookDocumentData[] {
|
||||
const result: ExtHostNotebookDocumentData[] = [];
|
||||
this._documents.forEach(data => result.push(data));
|
||||
return result;
|
||||
}
|
||||
|
||||
getEditor(id: string): ExtHostNotebookEditor {
|
||||
return this._editors.get(id);
|
||||
}
|
||||
|
||||
getActiveEditor(): ExtHostNotebookEditor | undefined {
|
||||
if (!this._activeEditorId) {
|
||||
return undefined;
|
||||
} else {
|
||||
return this._editors.get(this._activeEditorId);
|
||||
}
|
||||
}
|
||||
|
||||
getAllEditors(): ExtHostNotebookEditor[] {
|
||||
const result: ExtHostNotebookEditor[] = [];
|
||||
this._editors.forEach(data => result.push(data));
|
||||
return result;
|
||||
}
|
||||
|
||||
registerNavigationProvider(provider: azdata.nb.NavigationProvider): vscode.Disposable {
|
||||
if (!provider || !provider.providerId) {
|
||||
throw new Error(localize('providerRequired', 'A NotebookProvider with valid providerId must be passed to this method'));
|
||||
}
|
||||
const handle = this._addNewAdapter(provider);
|
||||
this._proxy.$registerNavigationProvider(provider.providerId, handle);
|
||||
return new Disposable(() => {
|
||||
this._adapters.delete(handle);
|
||||
});
|
||||
}
|
||||
|
||||
//#endregion
|
||||
}
|
||||
@@ -1,230 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
import { ok } from 'vs/base/common/assert';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { readonly } from 'vs/base/common/errors';
|
||||
|
||||
import { MainThreadNotebookDocumentsAndEditorsShape } from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
import { ExtHostNotebookDocumentData } from 'sql/workbench/api/node/extHostNotebookDocumentData';
|
||||
import { CellRange, ISingleNotebookEditOperation, ICellRange } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
|
||||
export interface INotebookEditOperation {
|
||||
range: azdata.nb.CellRange;
|
||||
cell: Partial<azdata.nb.ICellContents>;
|
||||
forceMoveMarkers: boolean;
|
||||
}
|
||||
|
||||
export interface INotebookEditData {
|
||||
documentVersionId: number;
|
||||
edits: INotebookEditOperation[];
|
||||
undoStopBefore: boolean;
|
||||
undoStopAfter: boolean;
|
||||
}
|
||||
|
||||
function toICellRange(range: azdata.nb.CellRange): ICellRange {
|
||||
return {
|
||||
start: range.start,
|
||||
end: range.end
|
||||
};
|
||||
}
|
||||
|
||||
export class NotebookEditorEdit {
|
||||
|
||||
private readonly _document: azdata.nb.NotebookDocument;
|
||||
private readonly _documentVersionId: number;
|
||||
private _collectedEdits: INotebookEditOperation[];
|
||||
private readonly _undoStopBefore: boolean;
|
||||
private readonly _undoStopAfter: boolean;
|
||||
|
||||
constructor(document: azdata.nb.NotebookDocument, options: { undoStopBefore: boolean; undoStopAfter: boolean; }) {
|
||||
this._document = document;
|
||||
// TODO add version handling
|
||||
this._documentVersionId = 0;
|
||||
// this._documentVersionId = document.version;
|
||||
this._collectedEdits = [];
|
||||
this._undoStopBefore = options ? options.undoStopBefore : true;
|
||||
this._undoStopAfter = options ? options.undoStopAfter : false;
|
||||
}
|
||||
|
||||
finalize(): INotebookEditData {
|
||||
return {
|
||||
documentVersionId: this._documentVersionId,
|
||||
edits: this._collectedEdits,
|
||||
undoStopBefore: this._undoStopBefore,
|
||||
undoStopAfter: this._undoStopAfter
|
||||
};
|
||||
}
|
||||
|
||||
replace(location: number | CellRange, value: Partial<azdata.nb.ICellContents>): void {
|
||||
let range: CellRange = this.getAsRange(location);
|
||||
this._pushEdit(range, value, false);
|
||||
}
|
||||
|
||||
private getAsRange(location: number | CellRange): CellRange {
|
||||
let range: CellRange = null;
|
||||
if (typeof (location) === 'number') {
|
||||
range = new CellRange(location, location + 1);
|
||||
}
|
||||
else if (location instanceof CellRange) {
|
||||
range = location;
|
||||
}
|
||||
else {
|
||||
throw new Error('Unrecognized location');
|
||||
}
|
||||
return range;
|
||||
}
|
||||
|
||||
insertCell(value: Partial<azdata.nb.ICellContents>, location?: number): void {
|
||||
if (location === null || location === undefined) {
|
||||
// If not specified, assume adding to end of list
|
||||
location = this._document.cells.length;
|
||||
}
|
||||
this._pushEdit(new CellRange(location, location), value, true);
|
||||
}
|
||||
|
||||
deleteCell(index: number): void {
|
||||
let range: CellRange = null;
|
||||
|
||||
if (typeof (index) === 'number') {
|
||||
// Currently only allowing single-cell deletion.
|
||||
// Do this by saying the range extends over 1 cell so on the main thread
|
||||
// we can delete that cell, then handle insertions
|
||||
range = new CellRange(index, index + 1);
|
||||
} else {
|
||||
throw new Error('Unrecognized index');
|
||||
}
|
||||
|
||||
this._pushEdit(range, null, true);
|
||||
}
|
||||
|
||||
private _pushEdit(range: azdata.nb.CellRange, cell: Partial<azdata.nb.ICellContents>, forceMoveMarkers: boolean): void {
|
||||
let validRange = this._document.validateCellRange(range);
|
||||
this._collectedEdits.push({
|
||||
range: validRange,
|
||||
cell: cell,
|
||||
forceMoveMarkers: forceMoveMarkers
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class ExtHostNotebookEditor implements azdata.nb.NotebookEditor, IDisposable {
|
||||
private _disposed: boolean = false;
|
||||
|
||||
constructor(
|
||||
private _proxy: MainThreadNotebookDocumentsAndEditorsShape,
|
||||
private _id: string,
|
||||
private readonly _documentData: ExtHostNotebookDocumentData,
|
||||
private _viewColumn: vscode.ViewColumn
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
dispose() {
|
||||
ok(!this._disposed);
|
||||
this._disposed = true;
|
||||
}
|
||||
|
||||
get document(): azdata.nb.NotebookDocument {
|
||||
return this._documentData.document;
|
||||
}
|
||||
|
||||
set document(value) {
|
||||
throw readonly('document');
|
||||
}
|
||||
|
||||
get viewColumn(): vscode.ViewColumn {
|
||||
return this._viewColumn;
|
||||
}
|
||||
|
||||
set viewColumn(value) {
|
||||
throw readonly('viewColumn');
|
||||
}
|
||||
|
||||
get id(): string {
|
||||
return this._id;
|
||||
}
|
||||
|
||||
public runCell(cell: azdata.nb.NotebookCell): Thenable<boolean> {
|
||||
let uri = cell ? cell.uri : undefined;
|
||||
return this._proxy.$runCell(this._id, uri);
|
||||
}
|
||||
|
||||
public runAllCells(startCell?: azdata.nb.NotebookCell, endCell?: azdata.nb.NotebookCell): Thenable<boolean> {
|
||||
let startCellUri = startCell ? startCell.uri : undefined;
|
||||
let endCellUri = endCell ? endCell.uri : undefined;
|
||||
return this._proxy.$runAllCells(this._id, startCellUri, endCellUri);
|
||||
}
|
||||
|
||||
public clearOutput(cell: azdata.nb.NotebookCell): Thenable<boolean> {
|
||||
let uri = cell ? cell.uri : undefined;
|
||||
return this._proxy.$clearOutput(this._id, uri);
|
||||
}
|
||||
|
||||
public clearAllOutputs(): Thenable<boolean> {
|
||||
return this._proxy.$clearAllOutputs(this._id);
|
||||
}
|
||||
|
||||
public changeKernel(kernel: azdata.nb.IKernelSpec): Thenable<boolean> {
|
||||
return this._proxy.$changeKernel(this._id, kernel);
|
||||
}
|
||||
|
||||
public edit(callback: (editBuilder: azdata.nb.NotebookEditorEdit) => void, options?: { undoStopBefore: boolean; undoStopAfter: boolean; }): Thenable<boolean> {
|
||||
if (this._disposed) {
|
||||
return Promise.reject(new Error('NotebookEditor#edit not possible on closed editors'));
|
||||
}
|
||||
let edit = new NotebookEditorEdit(this._documentData.document, options);
|
||||
callback(edit);
|
||||
return this._applyEdit(edit);
|
||||
}
|
||||
|
||||
private _applyEdit(editBuilder: NotebookEditorEdit): Promise<boolean> {
|
||||
let editData = editBuilder.finalize();
|
||||
|
||||
// return when there is nothing to do
|
||||
if (editData.edits.length === 0) {
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
// check that the edits are not overlapping (i.e. illegal)
|
||||
let editRanges = editData.edits.map(edit => edit.range);
|
||||
|
||||
// sort ascending (by end and then by start)
|
||||
editRanges.sort((a, b) => {
|
||||
if (a.end === b.end) {
|
||||
return a.start - b.start;
|
||||
}
|
||||
return a.end - b.end;
|
||||
});
|
||||
|
||||
// check that no edits are overlapping
|
||||
for (let i = 0, count = editRanges.length - 1; i < count; i++) {
|
||||
const rangeEnd = editRanges[i].end;
|
||||
const nextRangeStart = editRanges[i + 1].start;
|
||||
|
||||
if (nextRangeStart < rangeEnd) {
|
||||
// overlapping ranges
|
||||
return Promise.reject(new Error('Overlapping ranges are not allowed!'));
|
||||
}
|
||||
}
|
||||
|
||||
// prepare data for serialization
|
||||
let edits: ISingleNotebookEditOperation[] = editData.edits.map((edit) => {
|
||||
return {
|
||||
range: toICellRange(edit.range),
|
||||
cell: edit.cell,
|
||||
forceMoveMarkers: edit.forceMoveMarkers
|
||||
};
|
||||
});
|
||||
|
||||
return this._proxy.$tryApplyEdits(this._id, editData.documentVersionId, edits, {
|
||||
undoStopBefore: editData.undoStopBefore,
|
||||
undoStopAfter: editData.undoStopAfter
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IMainContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { ExtHostObjectExplorerShape, SqlMainContext, MainThreadObjectExplorerShape } from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
import * as azdata from 'azdata';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
export class ExtHostObjectExplorer implements ExtHostObjectExplorerShape {
|
||||
|
||||
private _proxy: MainThreadObjectExplorerShape;
|
||||
|
||||
constructor(
|
||||
mainContext: IMainContext
|
||||
) {
|
||||
this._proxy = mainContext.getProxy(SqlMainContext.MainThreadObjectExplorer);
|
||||
}
|
||||
|
||||
public $getNode(connectionId: string, nodePath?: string): Thenable<azdata.objectexplorer.ObjectExplorerNode> {
|
||||
return this._proxy.$getNode(connectionId, nodePath).then(nodeInfo => nodeInfo === undefined ? undefined : new ExtHostObjectExplorerNode(nodeInfo, connectionId, this._proxy));
|
||||
}
|
||||
|
||||
public $getActiveConnectionNodes(): Thenable<azdata.objectexplorer.ObjectExplorerNode[]> {
|
||||
return this._proxy.$getActiveConnectionNodes().then(results => results.map(result => new ExtHostObjectExplorerNode(result.nodeInfo, result.connectionId, this._proxy)));
|
||||
}
|
||||
|
||||
public $findNodes(connectionId: string, type: string, schema: string, name: string, database: string, parentObjectNames: string[]): Thenable<azdata.objectexplorer.ObjectExplorerNode[]> {
|
||||
return this._proxy.$findNodes(connectionId, type, schema, name, database, parentObjectNames).then(results => results.map(result => new ExtHostObjectExplorerNode(result, connectionId, this._proxy)));
|
||||
}
|
||||
|
||||
public $getNodeActions(connectionId: string, nodePath: string): Thenable<string[]> {
|
||||
return this._proxy.$getNodeActions(connectionId, nodePath);
|
||||
}
|
||||
|
||||
public $getSessionConnectionProfile(sessionId: string): Thenable<azdata.IConnectionProfile> {
|
||||
return this._proxy.$getSessionConnectionProfile(sessionId);
|
||||
}
|
||||
}
|
||||
|
||||
export class ExtHostObjectExplorerNode implements azdata.objectexplorer.ObjectExplorerNode {
|
||||
public connectionId: string;
|
||||
public nodePath: string;
|
||||
public nodeType: string;
|
||||
public nodeSubType: string;
|
||||
public nodeStatus: string;
|
||||
public label: string;
|
||||
public isLeaf: boolean;
|
||||
public metadata: azdata.ObjectMetadata;
|
||||
public errorMessage: string;
|
||||
|
||||
constructor(nodeInfo: azdata.NodeInfo, connectionId: string, private _proxy: MainThreadObjectExplorerShape) {
|
||||
this.getDetailsFromInfo(nodeInfo);
|
||||
this.connectionId = connectionId;
|
||||
}
|
||||
|
||||
isExpanded(): Thenable<boolean> {
|
||||
return this._proxy.$isExpanded(this.connectionId, this.nodePath);
|
||||
}
|
||||
|
||||
setExpandedState(expandedState: vscode.TreeItemCollapsibleState): Thenable<void> {
|
||||
return this._proxy.$setExpandedState(this.connectionId, this.nodePath, expandedState);
|
||||
}
|
||||
|
||||
setSelected(selected: boolean, clearOtherSelections: boolean = undefined): Thenable<void> {
|
||||
return this._proxy.$setSelected(this.connectionId, this.nodePath, selected, clearOtherSelections);
|
||||
}
|
||||
|
||||
getChildren(): Thenable<azdata.objectexplorer.ObjectExplorerNode[]> {
|
||||
return this._proxy.$getChildren(this.connectionId, this.nodePath).then(children => children.map(nodeInfo => new ExtHostObjectExplorerNode(nodeInfo, this.connectionId, this._proxy)));
|
||||
}
|
||||
|
||||
getParent(): Thenable<azdata.objectexplorer.ObjectExplorerNode> {
|
||||
// Object nodes have a name like <schema>.<name> in the nodePath - we can't use label because
|
||||
// that may have additional display information appended to it. Items without metadata are nodes
|
||||
// such as folders that don't correspond to actual objects and so just use the label
|
||||
let nodePathName = this.metadata ?
|
||||
`${this.metadata.schema ? this.metadata.schema + '.' : ''}${this.metadata.name}` :
|
||||
this.label;
|
||||
|
||||
// -1 to remove the / as well
|
||||
let parentPathEndIndex: number = this.nodePath.lastIndexOf(nodePathName) - 1;
|
||||
if (parentPathEndIndex < 0) {
|
||||
// At root node
|
||||
Promise.resolve(undefined);
|
||||
}
|
||||
return this._proxy.$getNode(this.connectionId, this.nodePath.slice(0, parentPathEndIndex)).then(
|
||||
nodeInfo => nodeInfo ? new ExtHostObjectExplorerNode(nodeInfo, this.connectionId, this._proxy) : undefined);
|
||||
}
|
||||
|
||||
refresh(): Thenable<void> {
|
||||
return this._proxy.$refresh(this.connectionId, this.nodePath).then(nodeInfo => this.getDetailsFromInfo(nodeInfo));
|
||||
}
|
||||
|
||||
private getDetailsFromInfo(nodeInfo: azdata.NodeInfo): void {
|
||||
this.nodePath = nodeInfo.nodePath;
|
||||
this.nodeType = nodeInfo.nodeType;
|
||||
this.nodeSubType = nodeInfo.nodeSubType;
|
||||
this.nodeStatus = nodeInfo.nodeStatus;
|
||||
this.label = nodeInfo.label;
|
||||
this.isLeaf = nodeInfo.isLeaf;
|
||||
this.metadata = nodeInfo.metadata;
|
||||
this.errorMessage = nodeInfo.errorMessage;
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IMainContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { ExtHostQueryEditorShape, SqlMainContext, MainThreadQueryEditorShape } from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
import * as azdata from 'azdata';
|
||||
import { IQueryEvent } from 'sql/platform/query/common/queryModel';
|
||||
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
|
||||
class ExtHostQueryDocument implements azdata.queryeditor.QueryDocument {
|
||||
constructor(
|
||||
public providerId: string,
|
||||
public uri: string,
|
||||
private _proxy: MainThreadQueryEditorShape) {
|
||||
}
|
||||
|
||||
public setExecutionOptions(options: Map<string, any>): Thenable<void> {
|
||||
let executionOptions: azdata.QueryExecutionOptions = {
|
||||
options: options
|
||||
};
|
||||
return this._proxy.$setQueryExecutionOptions(this.uri, executionOptions);
|
||||
}
|
||||
|
||||
public createQueryTab(tab: azdata.window.DialogTab): void {
|
||||
this._proxy.$createQueryTab(this.uri, tab.title, tab.content);
|
||||
}
|
||||
}
|
||||
|
||||
export class ExtHostQueryEditor implements ExtHostQueryEditorShape {
|
||||
|
||||
private _proxy: MainThreadQueryEditorShape;
|
||||
private _nextListenerHandle: number = 0;
|
||||
private _queryListeners = new Map<number, azdata.queryeditor.QueryEventListener>();
|
||||
|
||||
constructor(
|
||||
mainContext: IMainContext
|
||||
) {
|
||||
this._proxy = mainContext.getProxy(SqlMainContext.MainThreadQueryEditor);
|
||||
}
|
||||
|
||||
public $connect(fileUri: string, connectionId: string): Thenable<void> {
|
||||
return this._proxy.$connect(fileUri, connectionId);
|
||||
}
|
||||
|
||||
public $runQuery(fileUri: string): void {
|
||||
return this._proxy.$runQuery(fileUri);
|
||||
}
|
||||
|
||||
public $registerQueryInfoListener(providerId: string, listener: azdata.queryeditor.QueryEventListener): void {
|
||||
this._queryListeners[this._nextListenerHandle] = listener;
|
||||
this._proxy.$registerQueryInfoListener(this._nextListenerHandle, providerId);
|
||||
this._nextListenerHandle++;
|
||||
}
|
||||
|
||||
public $onQueryEvent(handle: number, fileUri: string, event: IQueryEvent): void {
|
||||
let listener: azdata.queryeditor.QueryEventListener = this._queryListeners[handle];
|
||||
if (listener) {
|
||||
let planXml = event.params ? event.params.planXml : undefined;
|
||||
listener.onQueryEvent(event.type, new ExtHostQueryDocument(mssqlProviderName, fileUri, this._proxy), planXml);
|
||||
}
|
||||
}
|
||||
|
||||
public $getQueryDocument(fileUri: string): Thenable<azdata.queryeditor.QueryDocument> {
|
||||
return new Promise((resolve) => {
|
||||
resolve(new ExtHostQueryDocument(mssqlProviderName, fileUri, this._proxy));
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import { IMainContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { Disposable } from 'vs/workbench/api/common/extHostTypes';
|
||||
import {
|
||||
ExtHostResourceProviderShape,
|
||||
MainThreadResourceProviderShape,
|
||||
SqlMainContext,
|
||||
} from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
|
||||
export class ExtHostResourceProvider extends ExtHostResourceProviderShape {
|
||||
private _handlePool: number = 0;
|
||||
private _proxy: MainThreadResourceProviderShape;
|
||||
private _providers: { [handle: number]: ResourceProviderWithMetadata } = {};
|
||||
|
||||
constructor(mainContext: IMainContext) {
|
||||
super();
|
||||
this._proxy = mainContext.getProxy(SqlMainContext.MainThreadResourceProvider);
|
||||
}
|
||||
|
||||
// PUBLIC METHODS //////////////////////////////////////////////////////
|
||||
// - MAIN THREAD AVAILABLE METHODS /////////////////////////////////////
|
||||
public $createFirewallRule(handle: number, account: azdata.Account, firewallRuleInfo: azdata.FirewallRuleInfo): Thenable<azdata.CreateFirewallRuleResponse> {
|
||||
return this._withProvider(handle, (provider: azdata.ResourceProvider) => provider.createFirewallRule(account, firewallRuleInfo));
|
||||
}
|
||||
public $handleFirewallRule(handle: number, errorCode: number, errorMessage: string, connectionTypeId: string): Thenable<azdata.HandleFirewallRuleResponse> {
|
||||
return this._withProvider(handle, (provider: azdata.ResourceProvider) => provider.handleFirewallRule(errorCode, errorMessage, connectionTypeId));
|
||||
}
|
||||
|
||||
// - EXTENSION HOST AVAILABLE METHODS //////////////////////////////////
|
||||
public $registerResourceProvider(providerMetadata: azdata.ResourceProviderMetadata, provider: azdata.ResourceProvider): Disposable {
|
||||
let self = this;
|
||||
|
||||
// Look for any account providers that have the same provider ID
|
||||
let matchingProviderIndex = Object.values(this._providers).findIndex((provider: ResourceProviderWithMetadata) => {
|
||||
return provider.metadata.id === providerMetadata.id;
|
||||
});
|
||||
if (matchingProviderIndex >= 0) {
|
||||
throw new Error(`Resource Provider with ID '${providerMetadata.id}' has already been registered`);
|
||||
}
|
||||
|
||||
// Create the handle for the provider
|
||||
let handle: number = this._nextHandle();
|
||||
this._providers[handle] = {
|
||||
metadata: providerMetadata,
|
||||
provider: provider
|
||||
};
|
||||
|
||||
// Register the provider in the main thread via the proxy
|
||||
this._proxy.$registerResourceProvider(providerMetadata, handle);
|
||||
|
||||
// Return a disposable to cleanup the provider
|
||||
return new Disposable(() => {
|
||||
delete self._providers[handle];
|
||||
self._proxy.$unregisterResourceProvider(handle);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is for testing only, it is not exposed via the shape.
|
||||
* @return Number of providers that are currently registered
|
||||
*/
|
||||
public getProviderCount(): number {
|
||||
return Object.keys(this._providers).length;
|
||||
}
|
||||
|
||||
// PRIVATE METHODS /////////////////////////////////////////////////////
|
||||
private _nextHandle(): number {
|
||||
return this._handlePool++;
|
||||
}
|
||||
|
||||
private _withProvider<R>(handle: number, callback: (provider: azdata.ResourceProvider) => Thenable<R>): Thenable<R> {
|
||||
let provider = this._providers[handle];
|
||||
if (provider === undefined) {
|
||||
return Promise.reject(new Error(`Provider ${handle} not found.`));
|
||||
}
|
||||
return callback(provider.provider);
|
||||
}
|
||||
}
|
||||
|
||||
interface ResourceProviderWithMetadata {
|
||||
metadata: azdata.ResourceProviderMetadata;
|
||||
provider: azdata.ResourceProvider;
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IMainContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { SqlMainContext, MainThreadSerializationProviderShape, ExtHostSerializationProviderShape } from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
import * as vscode from 'vscode';
|
||||
import * as azdata from 'azdata';
|
||||
import { Disposable } from 'vs/workbench/api/common/extHostTypes';
|
||||
|
||||
class SerializationAdapter {
|
||||
private _provider: azdata.SerializationProvider;
|
||||
|
||||
constructor(provider: azdata.SerializationProvider) {
|
||||
this._provider = provider;
|
||||
}
|
||||
|
||||
public saveAs(saveFormat: string, savePath: string, results: string, appendToFile: boolean): Thenable<azdata.SaveResultRequestResult> {
|
||||
return this._provider.saveAs(saveFormat, savePath, results, appendToFile);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
type Adapter = SerializationAdapter;
|
||||
|
||||
export class ExtHostSerializationProvider extends ExtHostSerializationProviderShape {
|
||||
|
||||
private _proxy: MainThreadSerializationProviderShape;
|
||||
|
||||
private static _handlePool: number = 0;
|
||||
private _adapter: { [handle: number]: Adapter } = Object.create(null);
|
||||
|
||||
private _createDisposable(handle: number): Disposable {
|
||||
return new Disposable(() => {
|
||||
delete this._adapter[handle];
|
||||
this._proxy.$unregisterSerializationProvider(handle);
|
||||
});
|
||||
}
|
||||
|
||||
private _nextHandle(): number {
|
||||
return ExtHostSerializationProvider._handlePool++;
|
||||
}
|
||||
|
||||
private _withAdapter<A, R>(handle: number, ctor: { new(...args: any[]): A }, callback: (adapter: A) => Thenable<R>): Thenable<R> {
|
||||
let adapter = this._adapter[handle];
|
||||
if (!(adapter instanceof ctor)) {
|
||||
return Promise.reject(new Error('no adapter found'));
|
||||
}
|
||||
return callback(<any>adapter);
|
||||
}
|
||||
|
||||
constructor(
|
||||
mainContext: IMainContext
|
||||
) {
|
||||
super();
|
||||
this._proxy = mainContext.getProxy(SqlMainContext.MainThreadSerializationProvider);
|
||||
}
|
||||
|
||||
public $registerSerializationProvider(provider: azdata.SerializationProvider): vscode.Disposable {
|
||||
provider.handle = this._nextHandle();
|
||||
this._adapter[provider.handle] = new SerializationAdapter(provider);
|
||||
this._proxy.$registerSerializationProvider(provider.handle);
|
||||
return this._createDisposable(provider.handle);
|
||||
}
|
||||
|
||||
public $saveAs(saveFormat: string, savePath: string, results: string, appendToFile: boolean): Thenable<azdata.SaveResultRequestResult> {
|
||||
return this._withAdapter(0, SerializationAdapter, adapter => adapter.saveAs(saveFormat, savePath, results, appendToFile));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { validateConstraint } from 'vs/base/common/types';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { IMainContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import * as extHostTypes from 'vs/workbench/api/common/extHostTypes';
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
|
||||
import { ITaskHandlerDescription } from 'sql/platform/tasks/common/tasks';
|
||||
import { SqlMainContext, MainThreadTasksShape, ExtHostTasksShape } from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
|
||||
interface TaskHandler {
|
||||
callback: Function;
|
||||
thisArg: any;
|
||||
description: ITaskHandlerDescription;
|
||||
}
|
||||
|
||||
export class ExtHostTasks implements ExtHostTasksShape {
|
||||
private _proxy: MainThreadTasksShape;
|
||||
private _tasks = new Map<string, TaskHandler>();
|
||||
|
||||
constructor(
|
||||
mainContext: IMainContext,
|
||||
private logService: ILogService
|
||||
) {
|
||||
this._proxy = mainContext.getProxy(SqlMainContext.MainThreadTasks);
|
||||
}
|
||||
|
||||
registerTask(id: string, callback: azdata.tasks.ITaskHandler, thisArg?: any, description?: ITaskHandlerDescription): extHostTypes.Disposable {
|
||||
this.logService.trace('ExtHostTasks#registerTask', id);
|
||||
|
||||
if (!id.trim().length) {
|
||||
throw new Error('invalid id');
|
||||
}
|
||||
|
||||
if (this._tasks.has(id)) {
|
||||
throw new Error(`task '${id}' already exists`);
|
||||
}
|
||||
|
||||
this._tasks.set(id, { callback, thisArg, description });
|
||||
this._proxy.$registerTask(id);
|
||||
|
||||
return new extHostTypes.Disposable(() => {
|
||||
if (this._tasks.delete(id)) {
|
||||
this._proxy.$unregisterTask(id);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$executeContributedTask<T>(id: string, ...args: any[]): Thenable<T> {
|
||||
let command = this._tasks.get(id);
|
||||
if (!command) {
|
||||
return Promise.reject(new Error(`Contributed task '${id}' does not exist.`));
|
||||
}
|
||||
|
||||
let { callback, thisArg, description } = command;
|
||||
|
||||
if (description) {
|
||||
for (let i = 0; i < description.args.length; i++) {
|
||||
try {
|
||||
validateConstraint(args[i], description.args[i].constraint);
|
||||
} catch (err) {
|
||||
return Promise.reject(new Error(`Running the contributed task:'${id}' failed. Illegal argument '${description.args[i].name}' - ${description.args[i].description}`));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
let result = callback.apply(thisArg, args);
|
||||
return Promise.resolve(result);
|
||||
} catch (err) {
|
||||
return Promise.reject(new Error(`Running the contributed task:'${id}' failed.`));
|
||||
}
|
||||
}
|
||||
|
||||
$getContributedTaskHandlerDescriptions(): Promise<{ [id: string]: any; }> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
}
|
||||
@@ -11,29 +11,29 @@ import { URI } from 'vs/base/common/uri';
|
||||
import * as azdata from 'azdata';
|
||||
import * as sqlops from 'sqlops';
|
||||
import * as vscode from 'vscode';
|
||||
import { SqlExtHostContext } from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
import { ExtHostAccountManagement } from 'sql/workbench/api/node/extHostAccountManagement';
|
||||
import { ExtHostCredentialManagement } from 'sql/workbench/api/node/extHostCredentialManagement';
|
||||
import { ExtHostDataProtocol } from 'sql/workbench/api/node/extHostDataProtocol';
|
||||
import { ExtHostSerializationProvider } from 'sql/workbench/api/node/extHostSerializationProvider';
|
||||
import { ExtHostResourceProvider } from 'sql/workbench/api/node/extHostResourceProvider';
|
||||
import { SqlExtHostContext } from 'sql/workbench/api/common/sqlExtHost.protocol';
|
||||
import { ExtHostAccountManagement } from 'sql/workbench/api/common/extHostAccountManagement';
|
||||
import { ExtHostCredentialManagement } from 'sql/workbench/api/common/extHostCredentialManagement';
|
||||
import { ExtHostDataProtocol } from 'sql/workbench/api/common/extHostDataProtocol';
|
||||
import { ExtHostSerializationProvider } from 'sql/workbench/api/common/extHostSerializationProvider';
|
||||
import { ExtHostResourceProvider } from 'sql/workbench/api/common/extHostResourceProvider';
|
||||
import * as sqlExtHostTypes from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { ExtHostModalDialogs } from 'sql/workbench/api/node/extHostModalDialog';
|
||||
import { ExtHostTasks } from 'sql/workbench/api/node/extHostTasks';
|
||||
import { ExtHostDashboardWebviews } from 'sql/workbench/api/node/extHostDashboardWebview';
|
||||
import { ExtHostModelView } from 'sql/workbench/api/node/extHostModelView';
|
||||
import { ExtHostConnectionManagement } from 'sql/workbench/api/node/extHostConnectionManagement';
|
||||
import { ExtHostDashboard } from 'sql/workbench/api/node/extHostDashboard';
|
||||
import { ExtHostObjectExplorer } from 'sql/workbench/api/node/extHostObjectExplorer';
|
||||
import { ExtHostModalDialogs } from 'sql/workbench/api/common/extHostModalDialog';
|
||||
import { ExtHostTasks } from 'sql/workbench/api/common/extHostTasks';
|
||||
import { ExtHostDashboardWebviews } from 'sql/workbench/api/common/extHostDashboardWebview';
|
||||
import { ExtHostModelView } from 'sql/workbench/api/common/extHostModelView';
|
||||
import { ExtHostConnectionManagement } from 'sql/workbench/api/common/extHostConnectionManagement';
|
||||
import { ExtHostDashboard } from 'sql/workbench/api/common/extHostDashboard';
|
||||
import { ExtHostObjectExplorer } from 'sql/workbench/api/common/extHostObjectExplorer';
|
||||
import { ExtHostLogService } from 'vs/workbench/api/common/extHostLogService';
|
||||
import { ExtHostModelViewDialog } from 'sql/workbench/api/node/extHostModelViewDialog';
|
||||
import { ExtHostModelViewTreeViews } from 'sql/workbench/api/node/extHostModelViewTree';
|
||||
import { ExtHostQueryEditor } from 'sql/workbench/api/node/extHostQueryEditor';
|
||||
import { ExtHostBackgroundTaskManagement } from './extHostBackgroundTaskManagement';
|
||||
import { ExtHostNotebook } from 'sql/workbench/api/node/extHostNotebook';
|
||||
import { ExtHostNotebookDocumentsAndEditors } from 'sql/workbench/api/node/extHostNotebookDocumentsAndEditors';
|
||||
import { ExtHostModelViewDialog } from 'sql/workbench/api/common/extHostModelViewDialog';
|
||||
import { ExtHostModelViewTreeViews } from 'sql/workbench/api/common/extHostModelViewTree';
|
||||
import { ExtHostQueryEditor } from 'sql/workbench/api/common/extHostQueryEditor';
|
||||
import { ExtHostBackgroundTaskManagement } from 'sql/workbench/api/common/extHostBackgroundTaskManagement';
|
||||
import { ExtHostNotebook } from 'sql/workbench/api/common/extHostNotebook';
|
||||
import { ExtHostNotebookDocumentsAndEditors } from 'sql/workbench/api/common/extHostNotebookDocumentsAndEditors';
|
||||
import { ExtensionDescriptionRegistry } from 'vs/workbench/services/extensions/common/extensionDescriptionRegistry';
|
||||
import { ExtHostExtensionManagement } from 'sql/workbench/api/node/extHostExtensionManagement';
|
||||
import { ExtHostExtensionManagement } from 'sql/workbench/api/common/extHostExtensionManagement';
|
||||
import { ExtensionIdentifier, IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
import { TernarySearchTree } from 'vs/base/common/map';
|
||||
import { ExtHostWorkspace } from 'vs/workbench/api/common/extHostWorkspace';
|
||||
|
||||
@@ -1,938 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import {
|
||||
createMainContextProxyIdentifier as createMainId,
|
||||
createExtHostContextProxyIdentifier as createExtId
|
||||
} from 'vs/workbench/services/extensions/common/proxyIdentifier';
|
||||
import { UriComponents } from 'vs/base/common/uri';
|
||||
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
import { ITreeComponentItem } from 'sql/workbench/common/views';
|
||||
import { ITaskHandlerDescription } from 'sql/platform/tasks/common/tasks';
|
||||
import {
|
||||
IItemConfig, IComponentShape, IModelViewDialogDetails, IModelViewTabDetails, IModelViewButtonDetails,
|
||||
IModelViewWizardDetails, IModelViewWizardPageDetails, INotebookManagerDetails, INotebookSessionDetails,
|
||||
INotebookKernelDetails, INotebookFutureDetails, FutureMessageType, INotebookFutureDone, ISingleNotebookEditOperation,
|
||||
NotebookChangeKind
|
||||
} from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { EditorViewColumn } from 'vs/workbench/api/common/shared/editor';
|
||||
import { IUndoStopOptions } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
import { IQueryEvent } from 'sql/platform/query/common/queryModel';
|
||||
|
||||
export abstract class ExtHostAccountManagementShape {
|
||||
$autoOAuthCancelled(handle: number): Thenable<void> { throw ni(); }
|
||||
$clear(handle: number, accountKey: azdata.AccountKey): Thenable<void> { throw ni(); }
|
||||
$getSecurityToken(account: azdata.Account, resource?: azdata.AzureResource): Thenable<{}> { throw ni(); }
|
||||
$initialize(handle: number, restoredAccounts: azdata.Account[]): Thenable<azdata.Account[]> { throw ni(); }
|
||||
$prompt(handle: number): Thenable<azdata.Account | azdata.PromptFailedResult> { throw ni(); }
|
||||
$refresh(handle: number, account: azdata.Account): Thenable<azdata.Account | azdata.PromptFailedResult> { throw ni(); }
|
||||
$accountsChanged(handle: number, accounts: azdata.Account[]): Thenable<void> { throw ni(); }
|
||||
}
|
||||
|
||||
export abstract class ExtHostConnectionManagementShape {
|
||||
$onConnectionOpened(handleId: string, connection: azdata.connection.Connection): void { throw ni; }
|
||||
}
|
||||
|
||||
export abstract class ExtHostDataProtocolShape {
|
||||
|
||||
/**
|
||||
* Establish a connection to a data source using the provided ConnectionInfo instance.
|
||||
*/
|
||||
$connect(handle: number, connectionUri: string, connection: azdata.ConnectionInfo): Thenable<boolean> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Disconnect from a data source using the provided connectionUri string.
|
||||
*/
|
||||
$disconnect(handle: number, connectionUri: string): Thenable<boolean> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Cancel a connection to a data source using the provided connectionUri string.
|
||||
*/
|
||||
$cancelConnect(handle: number, connectionUri: string): Thenable<boolean> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Change the database for the connection.
|
||||
*/
|
||||
$changeDatabase(handle: number, connectionUri: string, newDatabase: string): Thenable<boolean> { throw ni(); }
|
||||
|
||||
/**
|
||||
* List databases for a data source using the provided connectionUri string.
|
||||
* @param handle the handle to use when looking up a provider
|
||||
* @param connectionUri URI identifying a connected resource
|
||||
*/
|
||||
$listDatabases(handle: number, connectionUri: string): Thenable<azdata.ListDatabasesResult> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Get the connection string for the connection specified by connectionUri
|
||||
* @param handle the handle to use when looking up a provider
|
||||
* @param connectionUri URI identifying a connected resource
|
||||
*/
|
||||
$getConnectionString(handle: number, connectionUri: string, includePassword: boolean): Thenable<string> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Serialize connection string
|
||||
* @param handle the handle to use when looking up a provider
|
||||
* @param connectionString the connection string to serialize
|
||||
*/
|
||||
$buildConnectionInfo(handle: number, connectionString: string): Thenable<azdata.ConnectionInfo> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Notifies all listeners on the Extension Host side that a language change occurred
|
||||
* for a dataprotocol language. The sub-flavor is the specific implementation used for query
|
||||
* and other events
|
||||
* @param params information on what URI was changed and the new language
|
||||
*/
|
||||
$languageFlavorChanged(params: azdata.DidChangeLanguageFlavorParams): void { throw ni(); }
|
||||
|
||||
/**
|
||||
* Callback when a connection request has completed
|
||||
*/
|
||||
$onConnectComplete(handle: number, connectionInfoSummary: azdata.ConnectionInfoSummary): void { throw ni(); }
|
||||
|
||||
/**
|
||||
* Callback when a IntelliSense cache has been built
|
||||
*/
|
||||
$onIntelliSenseCacheComplete(handle: number, connectionUri: string): void { throw ni(); }
|
||||
|
||||
$getServerCapabilities(handle: number, client: azdata.DataProtocolClientCapabilities): Thenable<azdata.DataProtocolServerCapabilities> { throw ni(); }
|
||||
|
||||
$getConnectionIconId(handle: number, connection: azdata.IConnectionProfile, serverInfo: azdata.ServerInfo): Thenable<string> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Metadata service methods
|
||||
*
|
||||
*/
|
||||
$getMetadata(handle: number, connectionUri: string): Thenable<azdata.ProviderMetadata> { throw ni(); }
|
||||
|
||||
$getDatabases(handle: number, connectionUri: string): Thenable<string[]> { throw ni(); }
|
||||
|
||||
$getTableInfo(handle: number, connectionUri: string, metadata: azdata.ObjectMetadata): Thenable<azdata.ColumnMetadata[]> { throw ni(); }
|
||||
|
||||
$getViewInfo(handle: number, connectionUri: string, metadata: azdata.ObjectMetadata): Thenable<azdata.ColumnMetadata[]> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Object Explorer
|
||||
*/
|
||||
$createObjectExplorerSession(handle: number, connInfo: azdata.ConnectionInfo): Thenable<azdata.ObjectExplorerSessionResponse> { throw ni(); }
|
||||
|
||||
$expandObjectExplorerNode(handle: number, nodeInfo: azdata.ExpandNodeInfo): Thenable<boolean> { throw ni(); }
|
||||
|
||||
$refreshObjectExplorerNode(handle: number, nodeInfo: azdata.ExpandNodeInfo): Thenable<boolean> { throw ni(); }
|
||||
|
||||
$closeObjectExplorerSession(handle: number, closeSessionInfo: azdata.ObjectExplorerCloseSessionInfo): Thenable<azdata.ObjectExplorerCloseSessionResponse> { throw ni(); }
|
||||
|
||||
$findNodes(handle: number, findNodesInfo: azdata.FindNodesInfo): Thenable<azdata.ObjectExplorerFindNodesResponse> { throw ni(); }
|
||||
|
||||
$createObjectExplorerNodeProviderSession(handle: number, sessionInfo: azdata.ObjectExplorerSession): Thenable<boolean> { throw ni(); }
|
||||
|
||||
$handleSessionClose(handle: number, closeSessionInfo: azdata.ObjectExplorerCloseSessionInfo): void { throw ni(); }
|
||||
|
||||
/**
|
||||
* Tasks
|
||||
*/
|
||||
$getAllTasks(handle: number, listTasksParams: azdata.ListTasksParams): Thenable<azdata.ListTasksResponse> { throw ni(); }
|
||||
$cancelTask(handle: number, cancelTaskParams: azdata.CancelTaskParams): Thenable<boolean> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Scripting methods
|
||||
*/
|
||||
$scriptAsOperation(handle: number, connectionUri: string, operation: azdata.ScriptOperation, metadata: azdata.ObjectMetadata, paramDetails: azdata.ScriptingParamDetails): Thenable<azdata.ScriptingResult> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Cancels the currently running query for a URI
|
||||
*/
|
||||
$cancelQuery(handle: number, ownerUri: string): Thenable<azdata.QueryCancelResult> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Runs a query for a text selection inside a document
|
||||
*/
|
||||
$runQuery(handle: number, ownerUri: string, selection: azdata.ISelectionData, runOptions?: azdata.ExecutionPlanOptions): Thenable<void> { throw ni(); }
|
||||
/**
|
||||
* Runs the current SQL statement query for a text document
|
||||
*/
|
||||
$runQueryStatement(handle: number, ownerUri: string, line: number, column: number): Thenable<void> { throw ni(); }
|
||||
/**
|
||||
* Runs a query for a provided query
|
||||
*/
|
||||
$runQueryString(handle: number, ownerUri: string, queryString: string): Thenable<void> { throw ni(); }
|
||||
/**
|
||||
* Runs a query for a provided query and returns result
|
||||
*/
|
||||
$runQueryAndReturn(handle: number, ownerUri: string, queryString: string): Thenable<azdata.SimpleExecuteResult> { throw ni(); }
|
||||
/**
|
||||
* Parses a T-SQL string without actually executing it
|
||||
*/
|
||||
$parseSyntax(handle: number, ownerUri: string, query: string): Thenable<azdata.SyntaxParseResult> { throw ni(); }
|
||||
/**
|
||||
* Gets a subset of rows in a result set in order to display in the UI
|
||||
*/
|
||||
$getQueryRows(handle: number, rowData: azdata.QueryExecuteSubsetParams): Thenable<azdata.QueryExecuteSubsetResult> { throw ni(); }
|
||||
/**
|
||||
* Sets the query execution options for a query editor document
|
||||
*/
|
||||
$setQueryExecutionOptions(handle: number, ownerUri: string, options: azdata.QueryExecutionOptions): Thenable<void> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Disposes the cached information regarding a query
|
||||
*/
|
||||
$disposeQuery(handle: number, ownerUri: string): Thenable<void> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Refreshes the IntelliSense cache
|
||||
*/
|
||||
$rebuildIntelliSenseCache(handle: number, ownerUri: string): Thenable<void> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Callback when a query has completed
|
||||
*/
|
||||
$onQueryComplete(handle: number, result: azdata.QueryExecuteCompleteNotificationResult): void { throw ni(); }
|
||||
/**
|
||||
* Callback when a batch has started. This enables the UI to display when batch execution has started
|
||||
*/
|
||||
$onBatchStart(handle: number, batchInfo: azdata.QueryExecuteBatchNotificationParams): void { throw ni(); }
|
||||
/**
|
||||
* Callback when a batch is complete. This includes updated information on result sets, time to execute, and
|
||||
* other relevant batch information
|
||||
*/
|
||||
$onBatchComplete(handle: number, batchInfo: azdata.QueryExecuteBatchNotificationParams): void { throw ni(); }
|
||||
/**
|
||||
* Callback when a result set has been returned from query execution and can be displayed
|
||||
*/
|
||||
$onResultSetAvailable(handle: number, resultSetInfo: azdata.QueryExecuteResultSetNotificationParams): void { throw ni(); }
|
||||
/**
|
||||
* Callback when a result set has been returned from query execution and can be displayed
|
||||
*/
|
||||
$onResultSetUpdate(handle: number, resultSetInfo: azdata.QueryExecuteResultSetNotificationParams): void { throw ni(); }
|
||||
/**
|
||||
* Callback when a message generated during query execution is issued
|
||||
*/
|
||||
$onQueryMessage(handle: number, message: azdata.QueryExecuteMessageParams): void { throw ni(); }
|
||||
|
||||
/**
|
||||
* Requests saving of the results from a result set into a specific format (CSV, JSON, Excel)
|
||||
*/
|
||||
$saveResults(handle: number, requestParams: azdata.SaveResultsRequestParams): Thenable<azdata.SaveResultRequestResult> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Commits all pending edits in an edit session
|
||||
*/
|
||||
$commitEdit(handle: number, ownerUri: string): Thenable<void> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Creates a new row in the edit session
|
||||
*/
|
||||
$createRow(handle: number, ownerUri: string): Thenable<azdata.EditCreateRowResult> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Marks the selected row for deletion in the edit session
|
||||
*/
|
||||
$deleteRow(handle: number, ownerUri: string, rowId: number): Thenable<void> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Initializes a new edit data session for the requested table/view
|
||||
*/
|
||||
$initializeEdit(handle: number, ownerUri: string, schemaName: string, objectName: string, objectType: string, rowLimit: number, queryString: string): Thenable<void> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Reverts any pending changes for the requested cell and returns the original value
|
||||
*/
|
||||
$revertCell(handle: number, ownerUri: string, rowId: number, columnId: number): Thenable<azdata.EditRevertCellResult> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Reverts any pending changes for the requested row
|
||||
*/
|
||||
$revertRow(handle: number, ownerUri: string, rowId: number): Thenable<void> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Updates a cell value in the requested row. Returns if there are any corrections to the value
|
||||
*/
|
||||
$updateCell(handle: number, ownerUri: string, rowId: number, columId: number, newValue: string): Thenable<azdata.EditUpdateCellResult> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Gets a subset of rows in a result set, merging pending edit changes in order to display in the UI
|
||||
*/
|
||||
$getEditRows(handle: number, rowData: azdata.EditSubsetParams): Thenable<azdata.EditSubsetResult> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Diposes an initialized edit session and cleans up pending edits
|
||||
*/
|
||||
$disposeEdit(handle: number, ownerUri: string): Thenable<void> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Create a new database on the provided connection
|
||||
*/
|
||||
$createDatabase(handle: number, connectionUri: string, database: azdata.DatabaseInfo): Thenable<azdata.CreateDatabaseResponse> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Get the default database prototype
|
||||
*/
|
||||
$getDefaultDatabaseInfo(handle: number, connectionUri: string): Thenable<azdata.DatabaseInfo> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Get the database info
|
||||
*/
|
||||
$getDatabaseInfo(handle: number, connectionUri: string): Thenable<azdata.DatabaseInfo> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Create a new login on the provided connection
|
||||
*/
|
||||
$createLogin(handle: number, connectionUri: string, login: azdata.LoginInfo): Thenable<azdata.CreateLoginResponse> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Backup a database
|
||||
*/
|
||||
$backup(handle: number, connectionUri: string, backupInfo: { [key: string]: any }, taskExecutionMode: azdata.TaskExecutionMode): Thenable<azdata.BackupResponse> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Get the extended database prototype
|
||||
*/
|
||||
$getBackupConfigInfo(handle: number, connectionUri: string): Thenable<azdata.BackupConfigInfo> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Restores a database
|
||||
*/
|
||||
$restore(handle: number, connectionUri: string, restoreInfo: azdata.RestoreInfo): Thenable<azdata.RestoreResponse> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Gets a plan for restoring a database
|
||||
*/
|
||||
$getRestorePlan(handle: number, connectionUri: string, restoreInfo: azdata.RestoreInfo): Thenable<azdata.RestorePlanResponse> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Cancels a plan
|
||||
*/
|
||||
$cancelRestorePlan(handle: number, connectionUri: string, restoreInfo: azdata.RestoreInfo): Thenable<boolean> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Gets restore config Info
|
||||
*/
|
||||
$getRestoreConfigInfo(handle: number, connectionUri: string): Thenable<azdata.RestoreConfigInfo> { throw ni(); }
|
||||
|
||||
|
||||
/**
|
||||
* Open a file browser
|
||||
*/
|
||||
$openFileBrowser(handle: number, ownerUri: string, expandPath: string, fileFilters: string[], changeFilter: boolean): Thenable<boolean> { throw ni(); }
|
||||
|
||||
|
||||
/**
|
||||
* Expand a folder node
|
||||
*/
|
||||
$expandFolderNode(handle: number, ownerUri: string, expandPath: string): Thenable<boolean> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Validate selected file paths
|
||||
*/
|
||||
$validateFilePaths(handle: number, ownerUri: string, serviceType: string, selectedFiles: string[]): Thenable<boolean> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Close file browser
|
||||
*/
|
||||
$closeFileBrowser(handle: number, ownerUri: string): Thenable<azdata.FileBrowserCloseResponse> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Profiler Provider methods
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create a profiler session
|
||||
*/
|
||||
$createSession(handle: number, sessionId: string, createStatement: string, template: azdata.ProfilerSessionTemplate): Thenable<boolean> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Start a profiler session
|
||||
*/
|
||||
$startSession(handle: number, sessionId: string, sessionName: string): Thenable<boolean> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Stop a profiler session
|
||||
*/
|
||||
$stopSession(handle: number, sessionId: string): Thenable<boolean> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Pause a profiler session
|
||||
*/
|
||||
$pauseSession(handle: number, sessionId: string): Thenable<boolean> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Get list of running XEvent sessions on the profiler session's target server
|
||||
*/
|
||||
$getXEventSessions(handle: number, sessionId: string): Thenable<string[]> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Disconnect a profiler session
|
||||
*/
|
||||
$disconnectSession(handle: number, sessionId: string): Thenable<boolean> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Get Agent Job list
|
||||
*/
|
||||
$getJobs(handle: number, ownerUri: string): Thenable<azdata.AgentJobsResult> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Get a Agent Job's history
|
||||
*/
|
||||
$getJobHistory(handle: number, ownerUri: string, jobID: string, jobName: string): Thenable<azdata.AgentJobHistoryResult> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Run an action on a Job
|
||||
*/
|
||||
$jobAction(handle: number, ownerUri: string, jobName: string, action: string): Thenable<azdata.ResultStatus> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Deletes a job
|
||||
*/
|
||||
$deleteJob(handle: number, ownerUri: string, job: azdata.AgentJobInfo): Thenable<azdata.ResultStatus> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Deletes a job step
|
||||
*/
|
||||
$deleteJobStep(handle: number, ownerUri: string, step: azdata.AgentJobStepInfo): Thenable<azdata.ResultStatus> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Get Agent Alerts list
|
||||
*/
|
||||
$getAlerts(handle: number, connectionUri: string): Thenable<azdata.AgentAlertsResult> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Deletes an alert
|
||||
*/
|
||||
$deleteAlert(handle: number, connectionUri: string, alert: azdata.AgentAlertInfo): Thenable<azdata.ResultStatus> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Get Agent Oeprators list
|
||||
*/
|
||||
$getOperators(handle: number, connectionUri: string): Thenable<azdata.AgentOperatorsResult> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Deletes an operator
|
||||
*/
|
||||
$deleteOperator(handle: number, connectionUri: string, operator: azdata.AgentOperatorInfo): Thenable<azdata.ResultStatus> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Get Agent Proxies list
|
||||
*/
|
||||
$getProxies(handle: number, connectionUri: string): Thenable<azdata.AgentProxiesResult> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Deletes a proxy
|
||||
*/
|
||||
$deleteProxy(handle: number, connectionUri: string, proxy: azdata.AgentProxyInfo): Thenable<azdata.ResultStatus> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Get Agent Credentials list
|
||||
*/
|
||||
$getCredentials(handle: number, connectionUri: string): Thenable<azdata.GetCredentialsResult> { throw ni(); }
|
||||
|
||||
/**
|
||||
* DacFx export bacpac
|
||||
*/
|
||||
$exportBacpac(handle: number, databaseName: string, packageFilePath: string, ownerUri: string, taskExecutionMode: azdata.TaskExecutionMode): Thenable<azdata.DacFxResult> { throw ni(); }
|
||||
|
||||
/**
|
||||
* DacFx import bacpac
|
||||
*/
|
||||
$importBacpac(handle: number, packageFilePath: string, databaseName: string, ownerUri: string, taskExecutionMode: azdata.TaskExecutionMode): Thenable<azdata.DacFxResult> { throw ni(); }
|
||||
|
||||
/**
|
||||
* DacFx extract dacpac
|
||||
*/
|
||||
$extractDacpac(handle: number, databaseName: string, packageFilePath: string, applicationName: string, applicationVersion: string, ownerUri: string, taskExecutionMode: azdata.TaskExecutionMode): Thenable<azdata.DacFxResult> { throw ni(); }
|
||||
|
||||
/**
|
||||
* DacFx deploy dacpac
|
||||
*/
|
||||
$deployDacpac(handle: number, packageFilePath: string, databaseName: string, upgradeExisting: boolean, ownerUri: string, taskExecutionMode: azdata.TaskExecutionMode): Thenable<azdata.DacFxResult> { throw ni(); }
|
||||
|
||||
/**
|
||||
* DacFx generate deploy script
|
||||
*/
|
||||
$generateDeployScript(handle: number, packageFilePath: string, databaseName: string, ownerUri: string, taskExecutionMode: azdata.TaskExecutionMode): Thenable<azdata.DacFxResult> { throw ni(); }
|
||||
|
||||
/**
|
||||
* DacFx generate deploy plan
|
||||
*/
|
||||
$generateDeployPlan(handle: number, packageFilePath: string, databaseName: string, ownerUri: string, taskExecutionMode: azdata.TaskExecutionMode): Thenable<azdata.GenerateDeployPlanResult> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Schema compare
|
||||
*/
|
||||
$schemaCompare(handle: number, operationId: string, sourceEndpointInfo: azdata.SchemaCompareEndpointInfo, targetEndpointInfo: azdata.SchemaCompareEndpointInfo, taskExecutionMode: azdata.TaskExecutionMode, schemaComapareOptions: azdata.DeploymentOptions): Thenable<azdata.SchemaCompareResult> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Schema compare generate script
|
||||
*/
|
||||
$schemaCompareGenerateScript(handle: number, operationId: string, targetServerName: string, targetDatabaseName: string, taskExecutionMode: azdata.TaskExecutionMode): Thenable<azdata.ResultStatus> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Schema compare publish changes
|
||||
*/
|
||||
$schemaComparePublishChanges(handle: number, operationId: string, targetServerName: string, targetDatabaseName: string, taskExecutionMode: azdata.TaskExecutionMode): Thenable<azdata.SchemaCompareResult> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Schema compare get default options
|
||||
*/
|
||||
$schemaCompareGetDefaultOptions(handle: number): Thenable<azdata.SchemaCompareOptionsResult> { throw ni(); }
|
||||
|
||||
|
||||
/**
|
||||
* Schema compare Include node
|
||||
*/
|
||||
$schemaCompareIncludeExcludeNode(handle: number, operationId: string, diffEntry: azdata.DiffEntry, includeRequest: boolean, taskExecutionMode: azdata.TaskExecutionMode): Thenable<azdata.ResultStatus> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Schema compare open scmp
|
||||
*/
|
||||
$schemaCompareOpenScmp(handle: number, filePath: string): Thenable<azdata.SchemaCompareOpenScmpResult> { throw ni(); }
|
||||
|
||||
|
||||
/**
|
||||
* Schema compare save scmp
|
||||
*/
|
||||
$schemaCompareSaveScmp(handle: number, sourceEndpointInfo: azdata.SchemaCompareEndpointInfo, targetEndpointInfo: azdata.SchemaCompareEndpointInfo, taskExecutionMode: azdata.TaskExecutionMode, deploymentOptions: azdata.DeploymentOptions, scmpFilePath: string, excludedSourceObjects: azdata.SchemaCompareObjectId[], excludedTargetObjects: azdata.SchemaCompareObjectId[]): Thenable<azdata.ResultStatus> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Schema compare cancel
|
||||
*/
|
||||
$schemaCompareCancel(handle: number, operationId: string): Thenable<azdata.ResultStatus> { throw ni(); }
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* ResourceProvider extension host class.
|
||||
*/
|
||||
export abstract class ExtHostResourceProviderShape {
|
||||
/**
|
||||
* Create a firewall rule
|
||||
*/
|
||||
$createFirewallRule(handle: number, account: azdata.Account, firewallRuleInfo: azdata.FirewallRuleInfo): Thenable<azdata.CreateFirewallRuleResponse> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Handle firewall rule
|
||||
*/
|
||||
$handleFirewallRule(handle: number, errorCode: number, errorMessage: string, connectionTypeId: string): Thenable<azdata.HandleFirewallRuleResponse> { throw ni(); }
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Credential Management extension host class.
|
||||
*/
|
||||
export abstract class ExtHostCredentialManagementShape {
|
||||
$saveCredential(credentialId: string, password: string): Thenable<boolean> { throw ni(); }
|
||||
|
||||
$readCredential(credentialId: string): Thenable<azdata.Credential> { throw ni(); }
|
||||
|
||||
$deleteCredential(credentialId: string): Thenable<boolean> { throw ni(); }
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialization provider extension host class.
|
||||
*/
|
||||
export abstract class ExtHostSerializationProviderShape {
|
||||
$saveAs(saveFormat: string, savePath: string, results: string, appendToFile: boolean): Thenable<azdata.SaveResultRequestResult> { throw ni(); }
|
||||
}
|
||||
|
||||
export interface MainThreadAccountManagementShape extends IDisposable {
|
||||
$registerAccountProvider(providerMetadata: azdata.AccountProviderMetadata, handle: number): Thenable<any>;
|
||||
$unregisterAccountProvider(handle: number): Thenable<any>;
|
||||
|
||||
$beginAutoOAuthDeviceCode(providerId: string, title: string, message: string, userCode: string, uri: string): Thenable<void>;
|
||||
$endAutoOAuthDeviceCode(): void;
|
||||
|
||||
$accountUpdated(updatedAccount: azdata.Account): void;
|
||||
|
||||
$getAccountsForProvider(providerId: string): Thenable<azdata.Account[]>;
|
||||
}
|
||||
|
||||
export interface MainThreadResourceProviderShape extends IDisposable {
|
||||
$registerResourceProvider(providerMetadata: azdata.ResourceProviderMetadata, handle: number): Thenable<any>;
|
||||
$unregisterResourceProvider(handle: number): Thenable<any>;
|
||||
}
|
||||
|
||||
export interface MainThreadDataProtocolShape extends IDisposable {
|
||||
$registerConnectionProvider(providerId: string, handle: number): Promise<any>;
|
||||
$registerBackupProvider(providerId: string, handle: number): Promise<any>;
|
||||
$registerRestoreProvider(providerId: string, handle: number): Promise<any>;
|
||||
$registerScriptingProvider(providerId: string, handle: number): Promise<any>;
|
||||
$registerQueryProvider(providerId: string, handle: number): Promise<any>;
|
||||
$registerProfilerProvider(providerId: string, handle: number): Promise<any>;
|
||||
$registerObjectExplorerProvider(providerId: string, handle: number): Promise<any>;
|
||||
$registerObjectExplorerNodeProvider(providerId: string, supportedProviderId: string, group: string, handle: number): Promise<any>;
|
||||
$registerIconProvider(providerId: string, handle: number): Promise<any>;
|
||||
$registerMetadataProvider(providerId: string, handle: number): Promise<any>;
|
||||
$registerTaskServicesProvider(providerId: string, handle: number): Promise<any>;
|
||||
$registerFileBrowserProvider(providerId: string, handle: number): Promise<any>;
|
||||
$registerCapabilitiesServiceProvider(providerId: string, handle: number): Promise<any>;
|
||||
$registerAdminServicesProvider(providerId: string, handle: number): Promise<any>;
|
||||
$registerAgentServicesProvider(providerId: string, handle: number): Promise<any>;
|
||||
$registerDacFxServicesProvider(providerId: string, handle: number): Promise<any>;
|
||||
$registerSchemaCompareServicesProvider(providerId: string, handle: number): Promise<any>;
|
||||
$unregisterProvider(handle: number): Promise<any>;
|
||||
$onConnectionComplete(handle: number, connectionInfoSummary: azdata.ConnectionInfoSummary): void;
|
||||
$onIntelliSenseCacheComplete(handle: number, connectionUri: string): void;
|
||||
$onConnectionChangeNotification(handle: number, changedConnInfo: azdata.ChangedConnectionInfo): void;
|
||||
$onQueryComplete(handle: number, result: azdata.QueryExecuteCompleteNotificationResult): void;
|
||||
$onBatchStart(handle: number, batchInfo: azdata.QueryExecuteBatchNotificationParams): void;
|
||||
$onBatchComplete(handle: number, batchInfo: azdata.QueryExecuteBatchNotificationParams): void;
|
||||
$onResultSetAvailable(handle: number, resultSetInfo: azdata.QueryExecuteResultSetNotificationParams): void;
|
||||
$onResultSetUpdated(handle: number, resultSetInfo: azdata.QueryExecuteResultSetNotificationParams): void;
|
||||
$onQueryMessage(handle: number, message: azdata.QueryExecuteMessageParams): void;
|
||||
$onObjectExplorerSessionCreated(handle: number, message: azdata.ObjectExplorerSession): void;
|
||||
$onObjectExplorerSessionDisconnected(handle: number, message: azdata.ObjectExplorerSession): void;
|
||||
$onObjectExplorerNodeExpanded(providerId: string, message: azdata.ObjectExplorerExpandInfo): void;
|
||||
$onTaskCreated(handle: number, sessionResponse: azdata.TaskInfo): void;
|
||||
$onTaskStatusChanged(handle: number, sessionResponse: azdata.TaskProgressInfo): void;
|
||||
$onFileBrowserOpened(handle: number, response: azdata.FileBrowserOpenedParams): void;
|
||||
$onFolderNodeExpanded(handle: number, response: azdata.FileBrowserExpandedParams): void;
|
||||
$onFilePathsValidated(handle: number, response: azdata.FileBrowserValidatedParams): void;
|
||||
$onScriptingComplete(handle: number, message: azdata.ScriptingCompleteResult): void;
|
||||
$onSessionEventsAvailable(handle: number, response: azdata.ProfilerSessionEvents): void;
|
||||
$onSessionStopped(handle: number, response: azdata.ProfilerSessionStoppedParams): void;
|
||||
$onProfilerSessionCreated(handle: number, response: azdata.ProfilerSessionCreatedParams): void;
|
||||
$onJobDataUpdated(handle: Number): void;
|
||||
|
||||
/**
|
||||
* Callback when a session has completed initialization
|
||||
*/
|
||||
$onEditSessionReady(handle: number, ownerUri: string, success: boolean, message: string);
|
||||
}
|
||||
|
||||
export interface MainThreadConnectionManagementShape extends IDisposable {
|
||||
$getConnections(activeConnectionsOnly?: boolean): Thenable<azdata.connection.ConnectionProfile[]>;
|
||||
$getActiveConnections(): Thenable<azdata.connection.Connection[]>;
|
||||
$getCurrentConnection(): Thenable<azdata.connection.Connection>;
|
||||
$getCurrentConnectionProfile(): Thenable<azdata.connection.ConnectionProfile>;
|
||||
$getCredentials(connectionId: string): Thenable<{ [name: string]: string }>;
|
||||
$getServerInfo(connectedId: string): Thenable<azdata.ServerInfo>;
|
||||
$openConnectionDialog(providers: string[], initialConnectionProfile?: azdata.IConnectionProfile, connectionCompletionOptions?: azdata.IConnectionCompletionOptions): Thenable<azdata.connection.Connection>;
|
||||
$listDatabases(connectionId: string): Thenable<string[]>;
|
||||
$getConnectionString(connectionId: string, includePassword: boolean): Thenable<string>;
|
||||
$getUriForConnection(connectionId: string): Thenable<string>;
|
||||
$connect(connectionProfile: azdata.IConnectionProfile, saveConnection: boolean, showDashboard: boolean): Thenable<azdata.ConnectionResult>;
|
||||
}
|
||||
|
||||
export interface MainThreadCredentialManagementShape extends IDisposable {
|
||||
$registerCredentialProvider(handle: number): Promise<any>;
|
||||
$unregisterCredentialProvider(handle: number): Promise<any>;
|
||||
}
|
||||
|
||||
export interface MainThreadSerializationProviderShape extends IDisposable {
|
||||
$registerSerializationProvider(handle: number): Promise<any>;
|
||||
$unregisterSerializationProvider(handle: number): Promise<any>;
|
||||
}
|
||||
|
||||
function ni() { return new Error('Not implemented'); }
|
||||
|
||||
// --- proxy identifiers
|
||||
|
||||
export const SqlMainContext = {
|
||||
// SQL entries
|
||||
MainThreadAccountManagement: createMainId<MainThreadAccountManagementShape>('MainThreadAccountManagement'),
|
||||
MainThreadConnectionManagement: createMainId<MainThreadConnectionManagementShape>('MainThreadConnectionManagement'),
|
||||
MainThreadCredentialManagement: createMainId<MainThreadCredentialManagementShape>('MainThreadCredentialManagement'),
|
||||
MainThreadDataProtocol: createMainId<MainThreadDataProtocolShape>('MainThreadDataProtocol'),
|
||||
MainThreadObjectExplorer: createMainId<MainThreadObjectExplorerShape>('MainThreadObjectExplorer'),
|
||||
MainThreadBackgroundTaskManagement: createMainId<MainThreadBackgroundTaskManagementShape>('MainThreadBackgroundTaskManagement'),
|
||||
MainThreadSerializationProvider: createMainId<MainThreadSerializationProviderShape>('MainThreadSerializationProvider'),
|
||||
MainThreadResourceProvider: createMainId<MainThreadResourceProviderShape>('MainThreadResourceProvider'),
|
||||
MainThreadModalDialog: createMainId<MainThreadModalDialogShape>('MainThreadModalDialog'),
|
||||
MainThreadTasks: createMainId<MainThreadTasksShape>('MainThreadTasks'),
|
||||
MainThreadDashboardWebview: createMainId<MainThreadDashboardWebviewShape>('MainThreadDashboardWebview'),
|
||||
MainThreadModelView: createMainId<MainThreadModelViewShape>('MainThreadModelView'),
|
||||
MainThreadDashboard: createMainId<MainThreadDashboardShape>('MainThreadDashboard'),
|
||||
MainThreadModelViewDialog: createMainId<MainThreadModelViewDialogShape>('MainThreadModelViewDialog'),
|
||||
MainThreadQueryEditor: createMainId<MainThreadQueryEditorShape>('MainThreadQueryEditor'),
|
||||
MainThreadNotebook: createMainId<MainThreadNotebookShape>('MainThreadNotebook'),
|
||||
MainThreadNotebookDocumentsAndEditors: createMainId<MainThreadNotebookDocumentsAndEditorsShape>('MainThreadNotebookDocumentsAndEditors'),
|
||||
MainThreadExtensionManagement: createMainId<MainThreadExtensionManagementShape>('MainThreadExtensionManagement')
|
||||
};
|
||||
|
||||
export const SqlExtHostContext = {
|
||||
ExtHostAccountManagement: createExtId<ExtHostAccountManagementShape>('ExtHostAccountManagement'),
|
||||
ExtHostConnectionManagement: createExtId<ExtHostConnectionManagementShape>('ExtHostConnectionManagement'),
|
||||
ExtHostCredentialManagement: createExtId<ExtHostCredentialManagementShape>('ExtHostCredentialManagement'),
|
||||
ExtHostDataProtocol: createExtId<ExtHostDataProtocolShape>('ExtHostDataProtocol'),
|
||||
ExtHostObjectExplorer: createExtId<ExtHostObjectExplorerShape>('ExtHostObjectExplorer'),
|
||||
ExtHostSerializationProvider: createExtId<ExtHostSerializationProviderShape>('ExtHostSerializationProvider'),
|
||||
ExtHostResourceProvider: createExtId<ExtHostResourceProviderShape>('ExtHostResourceProvider'),
|
||||
ExtHostModalDialogs: createExtId<ExtHostModalDialogsShape>('ExtHostModalDialogs'),
|
||||
ExtHostTasks: createExtId<ExtHostTasksShape>('ExtHostTasks'),
|
||||
ExtHostBackgroundTaskManagement: createExtId<ExtHostBackgroundTaskManagementShape>('ExtHostBackgroundTaskManagement'),
|
||||
ExtHostDashboardWebviews: createExtId<ExtHostDashboardWebviewsShape>('ExtHostDashboardWebviews'),
|
||||
ExtHostModelView: createExtId<ExtHostModelViewShape>('ExtHostModelView'),
|
||||
ExtHostModelViewTreeViews: createExtId<ExtHostModelViewTreeViewsShape>('ExtHostModelViewTreeViews'),
|
||||
ExtHostDashboard: createExtId<ExtHostDashboardShape>('ExtHostDashboard'),
|
||||
ExtHostModelViewDialog: createExtId<ExtHostModelViewDialogShape>('ExtHostModelViewDialog'),
|
||||
ExtHostQueryEditor: createExtId<ExtHostQueryEditorShape>('ExtHostQueryEditor'),
|
||||
ExtHostNotebook: createExtId<ExtHostNotebookShape>('ExtHostNotebook'),
|
||||
ExtHostNotebookDocumentsAndEditors: createExtId<ExtHostNotebookDocumentsAndEditorsShape>('ExtHostNotebookDocumentsAndEditors'),
|
||||
ExtHostExtensionManagement: createExtId<ExtHostExtensionManagementShape>('ExtHostExtensionManagement')
|
||||
};
|
||||
|
||||
export interface MainThreadDashboardShape extends IDisposable {
|
||||
|
||||
}
|
||||
|
||||
export interface ExtHostDashboardShape {
|
||||
$onDidOpenDashboard(dashboard: azdata.DashboardDocument): void;
|
||||
$onDidChangeToDashboard(dashboard: azdata.DashboardDocument): void;
|
||||
}
|
||||
|
||||
export interface MainThreadModalDialogShape extends IDisposable {
|
||||
$createDialog(handle: number): void;
|
||||
$disposeDialog(handle: number): void;
|
||||
$show(handle: number): void;
|
||||
$setTitle(handle: number, value: string): void;
|
||||
$setHtml(handle: number, value: string): void;
|
||||
$sendMessage(handle: number, value: any): Thenable<boolean>;
|
||||
}
|
||||
|
||||
export interface ExtHostModalDialogsShape {
|
||||
$onMessage(handle: number, message: any): void;
|
||||
$onClosed(handle: number): void;
|
||||
}
|
||||
|
||||
export interface ExtHostTasksShape {
|
||||
$executeContributedTask<T>(id: string, ...args: any[]): Thenable<T>;
|
||||
$getContributedTaskHandlerDescriptions(): Promise<{ [id: string]: string | ITaskHandlerDescription }>;
|
||||
}
|
||||
|
||||
export interface MainThreadTasksShape extends IDisposable {
|
||||
$registerTask(id: string): Promise<any>;
|
||||
$unregisterTask(id: string): Promise<any>;
|
||||
}
|
||||
|
||||
export interface ExtHostDashboardWebviewsShape {
|
||||
$registerProvider(widgetId: string, handler: (webview: azdata.DashboardWebview) => void): void;
|
||||
$onMessage(handle: number, message: any): void;
|
||||
$onClosed(handle: number): void;
|
||||
$registerWidget(handle: number, id: string, connection: azdata.connection.Connection, serverInfo: azdata.ServerInfo): void;
|
||||
}
|
||||
|
||||
export interface MainThreadDashboardWebviewShape extends IDisposable {
|
||||
$sendMessage(handle: number, message: string);
|
||||
$registerProvider(widgetId: string);
|
||||
$setHtml(handle: number, value: string);
|
||||
}
|
||||
|
||||
export interface ExtHostModelViewShape {
|
||||
$registerProvider(widgetId: string, handler: (webview: azdata.ModelView) => void, extension: IExtensionDescription): void;
|
||||
$onClosed(handle: number): void;
|
||||
$registerWidget(handle: number, id: string, connection: azdata.connection.Connection, serverInfo: azdata.ServerInfo): void;
|
||||
$handleEvent(handle: number, id: string, eventArgs: any);
|
||||
$runCustomValidations(handle: number, id: string): Thenable<boolean>;
|
||||
}
|
||||
|
||||
export interface ExtHostModelViewTreeViewsShape {
|
||||
$getChildren(treeViewId: string, treeItemHandle?: string): Promise<ITreeComponentItem[]>;
|
||||
$createTreeView(handle: number, componentId: string, options: { treeDataProvider: vscode.TreeDataProvider<any> }, extension: IExtensionDescription): azdata.TreeComponentView<any>;
|
||||
$onNodeCheckedChanged(treeViewId: string, treeItemHandle?: string, checked?: boolean): void;
|
||||
$onNodeSelected(treeViewId: string, nodes: string[]): void;
|
||||
|
||||
$setExpanded(treeViewId: string, treeItemHandle: string, expanded: boolean): void;
|
||||
$setSelection(treeViewId: string, treeItemHandles: string[]): void;
|
||||
$setVisible(treeViewId: string, visible: boolean): void;
|
||||
}
|
||||
|
||||
export interface ExtHostBackgroundTaskManagementShape {
|
||||
$onTaskRegistered(operationId: string): void;
|
||||
$onTaskCanceled(operationId: string): void;
|
||||
$registerTask(operationInfo: azdata.BackgroundOperationInfo): void;
|
||||
$removeTask(operationId: string): void;
|
||||
}
|
||||
|
||||
export interface MainThreadBackgroundTaskManagementShape extends IDisposable {
|
||||
$registerTask(taskInfo: azdata.TaskInfo): void;
|
||||
$updateTask(taskProgressInfo: azdata.TaskProgressInfo): void;
|
||||
}
|
||||
|
||||
export interface MainThreadModelViewShape extends IDisposable {
|
||||
$registerProvider(id: string): void;
|
||||
$initializeModel(handle: number, rootComponent: IComponentShape): Thenable<void>;
|
||||
$clearContainer(handle: number, componentId: string): Thenable<void>;
|
||||
$addToContainer(handle: number, containerId: string, item: IItemConfig, index?: number): Thenable<void>;
|
||||
$removeFromContainer(handle: number, containerId: string, item: IItemConfig): Thenable<void>;
|
||||
$setLayout(handle: number, componentId: string, layout: any): Thenable<void>;
|
||||
$setProperties(handle: number, componentId: string, properties: { [key: string]: any }): Thenable<void>;
|
||||
$registerEvent(handle: number, componentId: string): Thenable<void>;
|
||||
$validate(handle: number, componentId: string): Thenable<boolean>;
|
||||
$setDataProvider(handle: number, componentId: string): Thenable<void>;
|
||||
$refreshDataProvider(handle: number, componentId: string, item?: any): Thenable<void>;
|
||||
}
|
||||
|
||||
export interface ExtHostObjectExplorerShape {
|
||||
}
|
||||
|
||||
export interface MainThreadObjectExplorerShape extends IDisposable {
|
||||
$getNode(connectionId: string, nodePath?: string): Thenable<azdata.NodeInfo>;
|
||||
$getActiveConnectionNodes(): Thenable<{ nodeInfo: azdata.NodeInfo, connectionId: string }[]>;
|
||||
$setExpandedState(connectionId: string, nodePath: string, expandedState: vscode.TreeItemCollapsibleState): Thenable<void>;
|
||||
$setSelected(connectionId: string, nodePath: string, selected: boolean, clearOtherSelections?: boolean): Thenable<void>;
|
||||
$getChildren(connectionId: string, nodePath: string): Thenable<azdata.NodeInfo[]>;
|
||||
$isExpanded(connectionId: string, nodePath: string): Thenable<boolean>;
|
||||
$findNodes(connectionId: string, type: string, schema: string, name: string, database: string, parentObjectNames: string[]): Thenable<azdata.NodeInfo[]>;
|
||||
$refresh(connectionId: string, nodePath: string): Thenable<azdata.NodeInfo>;
|
||||
$getNodeActions(connectionId: string, nodePath: string): Thenable<string[]>;
|
||||
$getSessionConnectionProfile(sessionId: string): Thenable<azdata.IConnectionProfile>;
|
||||
}
|
||||
|
||||
export interface ExtHostModelViewDialogShape {
|
||||
$onButtonClick(handle: number): void;
|
||||
$onPanelValidityChanged(handle: number, valid: boolean): void;
|
||||
$onWizardPageChanged(handle: number, info: azdata.window.WizardPageChangeInfo): void;
|
||||
$updateWizardPageInfo(handle: number, pageHandles: number[], currentPageIndex: number): void;
|
||||
$validateNavigation(handle: number, info: azdata.window.WizardPageChangeInfo): Thenable<boolean>;
|
||||
$validateDialogClose(handle: number): Thenable<boolean>;
|
||||
$handleSave(handle: number): Thenable<boolean>;
|
||||
}
|
||||
|
||||
export interface MainThreadModelViewDialogShape extends IDisposable {
|
||||
$openEditor(handle: number, modelViewId: string, title: string, options?: azdata.ModelViewEditorOptions, position?: vscode.ViewColumn): Thenable<void>;
|
||||
$openDialog(handle: number, dialogName?: string): Thenable<void>;
|
||||
$closeDialog(handle: number): Thenable<void>;
|
||||
$setDialogDetails(handle: number, details: IModelViewDialogDetails): Thenable<void>;
|
||||
$setTabDetails(handle: number, details: IModelViewTabDetails): Thenable<void>;
|
||||
$setButtonDetails(handle: number, details: IModelViewButtonDetails): Thenable<void>;
|
||||
$openWizard(handle: number): Thenable<void>;
|
||||
$closeWizard(handle: number): Thenable<void>;
|
||||
$setWizardPageDetails(handle: number, details: IModelViewWizardPageDetails): Thenable<void>;
|
||||
$setWizardDetails(handle: number, details: IModelViewWizardDetails): Thenable<void>;
|
||||
$addWizardPage(wizardHandle: number, pageHandle: number, pageIndex: number): Thenable<void>;
|
||||
$removeWizardPage(wizardHandle: number, pageIndex: number): Thenable<void>;
|
||||
$setWizardPage(wizardHandle: number, pageIndex: number): Thenable<void>;
|
||||
$setDirty(handle: number, isDirty: boolean): void;
|
||||
}
|
||||
export interface ExtHostQueryEditorShape {
|
||||
$onQueryEvent(handle: number, fileUri: string, event: IQueryEvent): void;
|
||||
}
|
||||
|
||||
export interface MainThreadQueryEditorShape extends IDisposable {
|
||||
$connect(fileUri: string, connectionId: string): Thenable<void>;
|
||||
$runQuery(fileUri: string): void;
|
||||
$createQueryTab(fileUri: string, title: string, content: string): void;
|
||||
$setQueryExecutionOptions(fileUri: string, options: azdata.QueryExecutionOptions): Thenable<void>;
|
||||
$registerQueryInfoListener(handle: number, providerId: string): void;
|
||||
}
|
||||
|
||||
export interface ExtHostNotebookShape {
|
||||
|
||||
/**
|
||||
* Looks up a notebook manager for a given notebook URI
|
||||
* @returns handle of the manager to be used when sending
|
||||
*/
|
||||
$getNotebookManager(providerHandle: number, notebookUri: UriComponents): Thenable<INotebookManagerDetails>;
|
||||
$handleNotebookClosed(notebookUri: UriComponents): void;
|
||||
|
||||
// Server Manager APIs
|
||||
$doStartServer(managerHandle: number): Thenable<void>;
|
||||
$doStopServer(managerHandle: number): Thenable<void>;
|
||||
|
||||
// Content Manager APIs
|
||||
$getNotebookContents(managerHandle: number, notebookUri: UriComponents): Thenable<azdata.nb.INotebookContents>;
|
||||
$save(managerHandle: number, notebookUri: UriComponents, notebook: azdata.nb.INotebookContents): Thenable<azdata.nb.INotebookContents>;
|
||||
|
||||
// Session Manager APIs
|
||||
$refreshSpecs(managerHandle: number): Thenable<azdata.nb.IAllKernels>;
|
||||
$startNewSession(managerHandle: number, options: azdata.nb.ISessionOptions): Thenable<INotebookSessionDetails>;
|
||||
$shutdownSession(managerHandle: number, sessionId: string): Thenable<void>;
|
||||
|
||||
// Session APIs
|
||||
$changeKernel(sessionId: number, kernelInfo: azdata.nb.IKernelSpec): Thenable<INotebookKernelDetails>;
|
||||
$configureKernel(sessionId: number, kernelInfo: azdata.nb.IKernelSpec): Thenable<void>;
|
||||
$configureConnection(sessionId: number, connection: azdata.IConnectionProfile): Thenable<void>;
|
||||
|
||||
// Kernel APIs
|
||||
$getKernelReadyStatus(kernelId: number): Thenable<azdata.nb.IInfoReply>;
|
||||
$getKernelSpec(kernelId: number): Thenable<azdata.nb.IKernelSpec>;
|
||||
$requestComplete(kernelId: number, content: azdata.nb.ICompleteRequest): Thenable<azdata.nb.ICompleteReplyMsg>;
|
||||
$requestExecute(kernelId: number, content: azdata.nb.IExecuteRequest, disposeOnDone?: boolean): Thenable<INotebookFutureDetails>;
|
||||
$interruptKernel(kernelId: number): Thenable<void>;
|
||||
|
||||
// Future APIs
|
||||
$sendInputReply(futureId: number, content: azdata.nb.IInputReply): void;
|
||||
$disposeFuture(futureId: number): void;
|
||||
}
|
||||
|
||||
export interface MainThreadNotebookShape extends IDisposable {
|
||||
$registerNotebookProvider(providerId: string, handle: number): void;
|
||||
$unregisterNotebookProvider(handle: number): void;
|
||||
$onFutureMessage(futureId: number, type: FutureMessageType, payload: azdata.nb.IMessage): void;
|
||||
$onFutureDone(futureId: number, done: INotebookFutureDone): void;
|
||||
}
|
||||
|
||||
export interface INotebookDocumentsAndEditorsDelta {
|
||||
removedDocuments?: UriComponents[];
|
||||
addedDocuments?: INotebookModelAddedData[];
|
||||
removedEditors?: string[];
|
||||
addedEditors?: INotebookEditorAddData[];
|
||||
newActiveEditor?: string;
|
||||
}
|
||||
|
||||
export interface INotebookModelAddedData {
|
||||
uri: UriComponents;
|
||||
providerId: string;
|
||||
providers: string[];
|
||||
isDirty: boolean;
|
||||
cells: azdata.nb.NotebookCell[];
|
||||
}
|
||||
|
||||
export interface INotebookModelChangedData {
|
||||
uri: UriComponents;
|
||||
providerId: string;
|
||||
providers: string[];
|
||||
isDirty: boolean;
|
||||
cells: azdata.nb.NotebookCell[];
|
||||
kernelSpec: azdata.nb.IKernelSpec;
|
||||
changeKind: NotebookChangeKind;
|
||||
}
|
||||
|
||||
export interface INotebookEditorAddData {
|
||||
id: string;
|
||||
documentUri: UriComponents;
|
||||
editorPosition: EditorViewColumn | undefined;
|
||||
}
|
||||
|
||||
export interface INotebookShowOptions {
|
||||
position?: EditorViewColumn;
|
||||
preserveFocus?: boolean;
|
||||
preview?: boolean;
|
||||
providerId?: string;
|
||||
connectionProfile?: azdata.IConnectionProfile;
|
||||
defaultKernel?: azdata.nb.IKernelSpec;
|
||||
initialContent?: string;
|
||||
initialDirtyState?: boolean;
|
||||
}
|
||||
|
||||
export interface ExtHostNotebookDocumentsAndEditorsShape {
|
||||
$acceptDocumentsAndEditorsDelta(delta: INotebookDocumentsAndEditorsDelta): void;
|
||||
$acceptModelChanged(strURL: UriComponents, e: INotebookModelChangedData);
|
||||
$getNavigation(handle: number, uri: vscode.Uri): Thenable<azdata.nb.NavigationResult>;
|
||||
}
|
||||
|
||||
export interface MainThreadNotebookDocumentsAndEditorsShape extends IDisposable {
|
||||
$trySaveDocument(uri: UriComponents): Thenable<boolean>;
|
||||
$tryShowNotebookDocument(resource: UriComponents, options: INotebookShowOptions): Promise<string>;
|
||||
$tryApplyEdits(id: string, modelVersionId: number, edits: ISingleNotebookEditOperation[], opts: IUndoStopOptions): Promise<boolean>;
|
||||
$runCell(id: string, cellUri: UriComponents): Promise<boolean>;
|
||||
$runAllCells(id: string, startCellUri?: UriComponents, endCellUri?: UriComponents): Promise<boolean>;
|
||||
$clearOutput(id: string, cellUri: UriComponents): Promise<boolean>;
|
||||
$clearAllOutputs(id: string): Promise<boolean>;
|
||||
$changeKernel(id: string, kernel: azdata.nb.IKernelInfo): Promise<boolean>;
|
||||
$registerNavigationProvider(providerId: string, handle: number);
|
||||
}
|
||||
|
||||
export interface ExtHostExtensionManagementShape {
|
||||
$install(vsixPath: string): Thenable<string>;
|
||||
}
|
||||
|
||||
export interface MainThreadExtensionManagementShape extends IDisposable {
|
||||
$install(vsixPath: string): Thenable<string>;
|
||||
}
|
||||
Reference in New Issue
Block a user