mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-17 09:35:37 -05:00
Task contribution (#742)
* work in progress * set up necessary code. need to work on getting it working * formatting * work in progress * work in progress * formatting * work in progress * work in progress * work in progress * formatting * needs a lot of work regarding how we do actions vs how extensions do actions * formatting * use connection profile for actions * change action to be
This commit is contained in:
65
src/sql/workbench/api/electron-browser/mainThreadTasks.ts
Normal file
65
src/sql/workbench/api/electron-browser/mainThreadTasks.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers';
|
||||
import { TaskRegistry, ITaskHandlerDescription } from 'sql/platform/tasks/common/tasks';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IExtHostContext } from 'vs/workbench/api/node/extHost.protocol';
|
||||
|
||||
import {
|
||||
ExtHostAccountManagementShape,
|
||||
MainThreadAccountManagementShape,
|
||||
SqlExtHostContext,
|
||||
SqlMainContext,
|
||||
ExtHostTasksShape,
|
||||
MainThreadTasksShape
|
||||
} from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
|
||||
import { IConnectionProfile } from 'sqlops';
|
||||
|
||||
import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile';
|
||||
|
||||
@extHostNamedCustomer(SqlMainContext.MainThreadTasks)
|
||||
export class MainThreadTasks implements MainThreadTasksShape {
|
||||
|
||||
private readonly _disposables = new Map<string, IDisposable>();
|
||||
private readonly _generateCommandsDocumentationRegistration: IDisposable;
|
||||
private readonly _proxy: ExtHostTasksShape;
|
||||
|
||||
constructor(
|
||||
extHostContext: IExtHostContext
|
||||
) {
|
||||
this._proxy = extHostContext.get(SqlExtHostContext.ExtHostTasks);
|
||||
}
|
||||
|
||||
dispose() {
|
||||
this._disposables.forEach(value => value.dispose());
|
||||
this._disposables.clear();
|
||||
|
||||
this._generateCommandsDocumentationRegistration.dispose();
|
||||
}
|
||||
|
||||
$registerTask(id: string): TPromise<any> {
|
||||
this._disposables.set(
|
||||
id,
|
||||
TaskRegistry.registerTask(id, (accessor, profile: IConnectionProfile, ...args) => {
|
||||
if (profile instanceof ConnectionProfile) {
|
||||
profile = profile.toIConnectionProfile();
|
||||
}
|
||||
this._proxy.$executeContributedTask(id, profile, ...args);
|
||||
})
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
$unregisterTask(id: string): TPromise<any> {
|
||||
if (this._disposables.has(id)) {
|
||||
this._disposables.get(id).dispose();
|
||||
this._disposables.delete(id);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user