mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-18 09:35:39 -05:00
SQL Operations Studio Public Preview 1 (0.23) release source code
This commit is contained in:
78
src/vs/workbench/api/node/extHostOutputService.ts
Normal file
78
src/vs/workbench/api/node/extHostOutputService.ts
Normal file
@@ -0,0 +1,78 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 { MainContext, MainThreadOutputServiceShape, IMainContext } from './extHost.protocol';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
export class ExtHostOutputChannel implements vscode.OutputChannel {
|
||||
|
||||
private static _idPool = 1;
|
||||
|
||||
private _proxy: MainThreadOutputServiceShape;
|
||||
private _name: string;
|
||||
private _id: string;
|
||||
private _disposed: boolean;
|
||||
|
||||
constructor(name: string, proxy: MainThreadOutputServiceShape) {
|
||||
this._name = name;
|
||||
this._id = 'extension-output-#' + (ExtHostOutputChannel._idPool++);
|
||||
this._proxy = proxy;
|
||||
}
|
||||
|
||||
get name(): string {
|
||||
return this._name;
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
if (!this._disposed) {
|
||||
this._proxy.$dispose(this._id, this._name).then(() => {
|
||||
this._disposed = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
append(value: string): void {
|
||||
this._proxy.$append(this._id, this._name, value);
|
||||
}
|
||||
|
||||
appendLine(value: string): void {
|
||||
this.append(value + '\n');
|
||||
}
|
||||
|
||||
clear(): void {
|
||||
this._proxy.$clear(this._id, this._name);
|
||||
}
|
||||
|
||||
show(columnOrPreserveFocus?: vscode.ViewColumn | boolean, preserveFocus?: boolean): void {
|
||||
if (typeof columnOrPreserveFocus === 'boolean') {
|
||||
preserveFocus = columnOrPreserveFocus;
|
||||
}
|
||||
|
||||
this._proxy.$reveal(this._id, this._name, preserveFocus);
|
||||
}
|
||||
|
||||
hide(): void {
|
||||
this._proxy.$close(this._id);
|
||||
}
|
||||
}
|
||||
|
||||
export class ExtHostOutputService {
|
||||
|
||||
private _proxy: MainThreadOutputServiceShape;
|
||||
|
||||
constructor(mainContext: IMainContext) {
|
||||
this._proxy = mainContext.get(MainContext.MainThreadOutputService);
|
||||
}
|
||||
|
||||
createOutputChannel(name: string): vscode.OutputChannel {
|
||||
name = name.trim();
|
||||
if (!name) {
|
||||
throw new Error('illegal argument `name`. must not be falsy');
|
||||
} else {
|
||||
return new ExtHostOutputChannel(name, this._proxy);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user