mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
clean up some disposable use (#6832)
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import { IAccountManagementService } from 'sql/platform/accounts/common/interfaces';
|
||||
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import {
|
||||
ExtHostAccountManagementShape,
|
||||
MainThreadAccountManagementShape,
|
||||
@@ -17,20 +17,19 @@ import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
|
||||
import { UpdateAccountListEventParams } from 'sql/platform/accounts/common/eventTypes';
|
||||
|
||||
@extHostNamedCustomer(SqlMainContext.MainThreadAccountManagement)
|
||||
export class MainThreadAccountManagement implements MainThreadAccountManagementShape {
|
||||
export class MainThreadAccountManagement extends Disposable implements MainThreadAccountManagementShape {
|
||||
private _providerMetadata: { [handle: number]: azdata.AccountProviderMetadata };
|
||||
private _proxy: ExtHostAccountManagementShape;
|
||||
private _toDispose: IDisposable[];
|
||||
|
||||
constructor(
|
||||
extHostContext: IExtHostContext,
|
||||
@IAccountManagementService private _accountManagementService: IAccountManagementService
|
||||
) {
|
||||
super();
|
||||
this._providerMetadata = {};
|
||||
if (extHostContext) {
|
||||
this._proxy = extHostContext.getProxy(SqlExtHostContext.ExtHostAccountManagement);
|
||||
}
|
||||
this._toDispose = [];
|
||||
|
||||
this._accountManagementService.updateAccountListEvent((e: UpdateAccountListEventParams) => {
|
||||
if (!e) {
|
||||
@@ -97,8 +96,4 @@ export class MainThreadAccountManagement implements MainThreadAccountManagementS
|
||||
this._accountManagementService.unregisterProvider(this._providerMetadata[handle]);
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this._toDispose = dispose(this._toDispose);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/co
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import * as TaskUtilities from 'sql/workbench/browser/taskUtilities';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { isUndefinedOrNull } from 'vs/base/common/types';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
@@ -21,10 +21,9 @@ import { IConnectionDialogService } from 'sql/workbench/services/connection/comm
|
||||
import { deepClone } from 'vs/base/common/objects';
|
||||
|
||||
@extHostNamedCustomer(SqlMainContext.MainThreadConnectionManagement)
|
||||
export class MainThreadConnectionManagement implements MainThreadConnectionManagementShape {
|
||||
export class MainThreadConnectionManagement extends Disposable implements MainThreadConnectionManagementShape {
|
||||
|
||||
private _proxy: ExtHostConnectionManagementShape;
|
||||
private _toDispose: IDisposable[];
|
||||
|
||||
constructor(
|
||||
extHostContext: IExtHostContext,
|
||||
@@ -34,14 +33,10 @@ export class MainThreadConnectionManagement implements MainThreadConnectionManag
|
||||
@IConnectionDialogService private _connectionDialogService: IConnectionDialogService,
|
||||
@ICapabilitiesService private _capabilitiesService: ICapabilitiesService
|
||||
) {
|
||||
super();
|
||||
if (extHostContext) {
|
||||
this._proxy = extHostContext.getProxy(SqlExtHostContext.ExtHostConnectionManagement);
|
||||
}
|
||||
this._toDispose = [];
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this._toDispose = dispose(this._toDispose);
|
||||
}
|
||||
|
||||
public $registerConnectionEventListener(handle: number, providerId: string): void {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { IDisposable, Disposable } from 'vs/base/common/lifecycle';
|
||||
import {
|
||||
SqlExtHostContext, ExtHostCredentialManagementShape,
|
||||
MainThreadCredentialManagementShape, SqlMainContext
|
||||
@@ -14,27 +14,22 @@ import { IExtHostContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
|
||||
|
||||
@extHostNamedCustomer(SqlMainContext.MainThreadCredentialManagement)
|
||||
export class MainThreadCredentialManagement implements MainThreadCredentialManagementShape {
|
||||
export class MainThreadCredentialManagement extends Disposable implements MainThreadCredentialManagementShape {
|
||||
|
||||
private _proxy: ExtHostCredentialManagementShape;
|
||||
|
||||
private _toDispose: IDisposable[];
|
||||
|
||||
private _registrations: { [handle: number]: IDisposable; } = Object.create(null);
|
||||
private _registrations: { [handle: number]: IDisposable; } = Object.create(null); // should we be registering these disposables?
|
||||
|
||||
constructor(
|
||||
extHostContext: IExtHostContext,
|
||||
@ICredentialsService private credentialService: ICredentialsService
|
||||
) {
|
||||
super();
|
||||
if (extHostContext) {
|
||||
this._proxy = extHostContext.getProxy(SqlExtHostContext.ExtHostCredentialManagement);
|
||||
}
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this._toDispose = dispose(this._toDispose);
|
||||
}
|
||||
|
||||
public $registerCredentialProvider(handle: number): Promise<any> {
|
||||
let self = this;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { IDisposable, Disposable } from 'vs/base/common/lifecycle';
|
||||
import {
|
||||
SqlExtHostContext, ExtHostDataProtocolShape,
|
||||
MainThreadDataProtocolShape, SqlMainContext
|
||||
@@ -30,13 +30,11 @@ import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
|
||||
* Main thread class for handling data protocol management registration.
|
||||
*/
|
||||
@extHostNamedCustomer(SqlMainContext.MainThreadDataProtocol)
|
||||
export class MainThreadDataProtocol implements MainThreadDataProtocolShape {
|
||||
export class MainThreadDataProtocol extends Disposable implements MainThreadDataProtocolShape {
|
||||
|
||||
private _proxy: ExtHostDataProtocolShape;
|
||||
|
||||
private _toDispose: IDisposable[];
|
||||
|
||||
private _capabilitiesRegistrations: { [handle: number]: IDisposable; } = Object.create(null);
|
||||
private _capabilitiesRegistrations: { [handle: number]: IDisposable; } = Object.create(null); // should we be registering these?
|
||||
|
||||
constructor(
|
||||
extHostContext: IExtHostContext,
|
||||
@@ -55,18 +53,15 @@ export class MainThreadDataProtocol implements MainThreadDataProtocolShape {
|
||||
@ISerializationService private _serializationService: ISerializationService,
|
||||
@IFileBrowserService private _fileBrowserService: IFileBrowserService
|
||||
) {
|
||||
super();
|
||||
if (extHostContext) {
|
||||
this._proxy = extHostContext.getProxy(SqlExtHostContext.ExtHostDataProtocol);
|
||||
}
|
||||
if (this._connectionManagementService) {
|
||||
this._connectionManagementService.onLanguageFlavorChanged(e => this._proxy.$languageFlavorChanged(e), this, this._toDispose);
|
||||
this._register(this._connectionManagementService.onLanguageFlavorChanged(e => this._proxy.$languageFlavorChanged(e)));
|
||||
}
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this._toDispose = dispose(this._toDispose);
|
||||
}
|
||||
|
||||
public $registerConnectionProvider(providerId: string, handle: number): Promise<any> {
|
||||
const self = this;
|
||||
this._connectionManagementService.registerProvider(providerId, <azdata.ConnectionProvider>{
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import { SqlMainContext, MainThreadExtensionManagementShape } from 'sql/workbench/api/common/sqlExtHost.protocol';
|
||||
import { IExtHostContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
|
||||
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IExtensionManagementService, ILocalExtension } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IConfigurationService, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
|
||||
@@ -15,9 +15,8 @@ import { localize } from 'vs/nls';
|
||||
import { IWindowService } from 'vs/platform/windows/common/windows';
|
||||
|
||||
@extHostNamedCustomer(SqlMainContext.MainThreadExtensionManagement)
|
||||
export class MainThreadExtensionManagement implements MainThreadExtensionManagementShape {
|
||||
export class MainThreadExtensionManagement extends Disposable implements MainThreadExtensionManagementShape {
|
||||
|
||||
private _toDispose: IDisposable[];
|
||||
private _obsoleteExtensionApiUsageNotificationShown: boolean = false;
|
||||
|
||||
constructor(
|
||||
@@ -27,11 +26,7 @@ export class MainThreadExtensionManagement implements MainThreadExtensionManagem
|
||||
@INotificationService private _notificationService: INotificationService,
|
||||
@IWindowService protected readonly _windowService: IWindowService
|
||||
) {
|
||||
this._toDispose = [];
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this._toDispose = dispose(this._toDispose);
|
||||
super();
|
||||
}
|
||||
|
||||
public $install(vsixPath: string): Thenable<string> {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import * as azdata from 'azdata';
|
||||
import * as path from 'vs/base/common/path';
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
|
||||
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { IExtHostContext, IUndoStopOptions } from 'vs/workbench/api/common/extHost.protocol';
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
INotebookDocumentsAndEditorsDelta, INotebookEditorAddData, INotebookShowOptions, INotebookModelAddedData, INotebookModelChangedData
|
||||
} from 'sql/workbench/api/common/sqlExtHost.protocol';
|
||||
import { NotebookInput } from 'sql/workbench/parts/notebook/common/models/notebookInput';
|
||||
import { INotebookService, INotebookEditor, IProviderInfo } from 'sql/workbench/services/notebook/common/notebookService';
|
||||
import { INotebookService, INotebookEditor } from 'sql/workbench/services/notebook/common/notebookService';
|
||||
import { ISingleNotebookEditOperation, NotebookChangeKind } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { disposed } from 'vs/base/common/errors';
|
||||
import { ICellModel, NotebookContentChange, INotebookModel } from 'sql/workbench/parts/notebook/common/models/modelInterfaces';
|
||||
@@ -320,7 +320,7 @@ class MainThreadNotebookDocumentAndEditorStateComputer extends Disposable {
|
||||
export class MainThreadNotebookDocumentsAndEditors extends Disposable implements MainThreadNotebookDocumentsAndEditorsShape {
|
||||
private _proxy: ExtHostNotebookDocumentsAndEditorsShape;
|
||||
private _notebookEditors = new Map<string, MainThreadNotebookEditor>();
|
||||
private _modelToDisposeMap = new Map<string, IDisposable[]>();
|
||||
private _modelToDisposeMap = new Map<string, DisposableStore>();
|
||||
constructor(
|
||||
extHostContext: IExtHostContext,
|
||||
@IUntitledEditorService private _untitledEditorService: IUntitledEditorService,
|
||||
@@ -558,11 +558,9 @@ export class MainThreadNotebookDocumentsAndEditors extends Disposable implements
|
||||
return;
|
||||
}
|
||||
removedDocuments.forEach(removedDoc => {
|
||||
let listeners = this._modelToDisposeMap.get(removedDoc.toString());
|
||||
if (listeners && listeners.length) {
|
||||
listeners.forEach(listener => {
|
||||
listener.dispose();
|
||||
});
|
||||
const store = this._modelToDisposeMap.get(removedDoc.toString());
|
||||
if (store) {
|
||||
store.dispose();
|
||||
this._modelToDisposeMap.delete(removedDoc.toString());
|
||||
}
|
||||
});
|
||||
@@ -574,9 +572,9 @@ export class MainThreadNotebookDocumentsAndEditors extends Disposable implements
|
||||
}
|
||||
addedEditors.forEach(editor => {
|
||||
let modelUrl = editor.uri;
|
||||
this._modelToDisposeMap.set(editor.uri.toString(), [editor.contentChanged((e) => {
|
||||
this._proxy.$acceptModelChanged(modelUrl, this._toNotebookChangeData(e, editor));
|
||||
})]);
|
||||
const store = new DisposableStore();
|
||||
store.add(editor.contentChanged((e) => this._proxy.$acceptModelChanged(modelUrl, this._toNotebookChangeData(e, editor))));
|
||||
this._modelToDisposeMap.set(editor.uri.toString(), store);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -680,13 +678,13 @@ export class MainThreadNotebookDocumentsAndEditors extends Disposable implements
|
||||
}
|
||||
|
||||
private async doChangeKernel(editor: MainThreadNotebookEditor, displayName: string): Promise<boolean> {
|
||||
let listeners = this._modelToDisposeMap.get(editor.id);
|
||||
const store = this._modelToDisposeMap.get(editor.id);
|
||||
editor.model.changeKernel(displayName);
|
||||
return new Promise((resolve) => {
|
||||
listeners.push(editor.model.kernelChanged((kernel) => {
|
||||
store.add(editor.model.kernelChanged((kernel) => {
|
||||
resolve(true);
|
||||
}));
|
||||
this._modelToDisposeMap.set(editor.id, listeners);
|
||||
this._modelToDisposeMap.set(editor.id, store);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -3,32 +3,22 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { SqlExtHostContext, SqlMainContext, ExtHostObjectExplorerShape, MainThreadObjectExplorerShape } from 'sql/workbench/api/common/sqlExtHost.protocol';
|
||||
import { SqlMainContext, MainThreadObjectExplorerShape } from 'sql/workbench/api/common/sqlExtHost.protocol';
|
||||
import * as azdata from 'azdata';
|
||||
import * as vscode from 'vscode';
|
||||
import { IExtHostContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
|
||||
import { IObjectExplorerService, NodeInfoWithConnection } from 'sql/workbench/services/objectExplorer/common/objectExplorerService';
|
||||
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
|
||||
@extHostNamedCustomer(SqlMainContext.MainThreadObjectExplorer)
|
||||
export class MainThreadObjectExplorer implements MainThreadObjectExplorerShape {
|
||||
|
||||
private _proxy: ExtHostObjectExplorerShape;
|
||||
private _toDispose: IDisposable[];
|
||||
export class MainThreadObjectExplorer extends Disposable implements MainThreadObjectExplorerShape {
|
||||
|
||||
constructor(
|
||||
extHostContext: IExtHostContext,
|
||||
@IObjectExplorerService private _objectExplorerService: IObjectExplorerService,
|
||||
) {
|
||||
if (extHostContext) {
|
||||
this._proxy = extHostContext.getProxy(SqlExtHostContext.ExtHostObjectExplorer);
|
||||
}
|
||||
this._toDispose = [];
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this._toDispose = dispose(this._toDispose);
|
||||
super();
|
||||
}
|
||||
|
||||
public $getNode(connectionId: string, nodePath?: string): Thenable<azdata.NodeInfo> {
|
||||
|
||||
@@ -9,16 +9,15 @@ import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
|
||||
import { IConnectionManagementService, IConnectionCompletionOptions, ConnectionType, RunQueryOnConnectionMode } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { QueryEditor } from 'sql/workbench/parts/query/browser/queryEditor';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IQueryModelService } from 'sql/platform/query/common/queryModel';
|
||||
import * as azdata from 'azdata';
|
||||
import { IQueryManagementService } from 'sql/platform/query/common/queryManagement';
|
||||
|
||||
@extHostNamedCustomer(SqlMainContext.MainThreadQueryEditor)
|
||||
export class MainThreadQueryEditor implements MainThreadQueryEditorShape {
|
||||
export class MainThreadQueryEditor extends Disposable implements MainThreadQueryEditorShape {
|
||||
|
||||
private _proxy: ExtHostQueryEditorShape;
|
||||
private _toDispose: IDisposable[];
|
||||
|
||||
constructor(
|
||||
extHostContext: IExtHostContext,
|
||||
@@ -27,14 +26,10 @@ export class MainThreadQueryEditor implements MainThreadQueryEditorShape {
|
||||
@IEditorService private _editorService: IEditorService,
|
||||
@IQueryManagementService private _queryManagementService: IQueryManagementService
|
||||
) {
|
||||
super();
|
||||
if (extHostContext) {
|
||||
this._proxy = extHostContext.getProxy(SqlExtHostContext.ExtHostQueryEditor);
|
||||
}
|
||||
this._toDispose = [];
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this._toDispose = dispose(this._toDispose);
|
||||
}
|
||||
|
||||
public $connect(fileUri: string, connectionId: string): Thenable<void> {
|
||||
@@ -83,7 +78,7 @@ export class MainThreadQueryEditor implements MainThreadQueryEditorShape {
|
||||
}
|
||||
|
||||
public $registerQueryInfoListener(handle: number, providerId: string): void {
|
||||
this._toDispose.push(this._queryModelService.onQueryEvent(event => {
|
||||
this._register(this._queryModelService.onQueryEvent(event => {
|
||||
this._proxy.$onQueryEvent(handle, event.uri, event);
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import { IResourceProviderService } from 'sql/workbench/services/resourceProvider/common/resourceProviderService';
|
||||
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import {
|
||||
ExtHostResourceProviderShape,
|
||||
MainThreadResourceProviderShape,
|
||||
@@ -17,20 +17,19 @@ import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
|
||||
|
||||
|
||||
@extHostNamedCustomer(SqlMainContext.MainThreadResourceProvider)
|
||||
export class MainThreadResourceProvider implements MainThreadResourceProviderShape {
|
||||
export class MainThreadResourceProvider extends Disposable implements MainThreadResourceProviderShape {
|
||||
private _providerMetadata: { [handle: number]: azdata.AccountProviderMetadata };
|
||||
private _proxy: ExtHostResourceProviderShape;
|
||||
private _toDispose: IDisposable[];
|
||||
|
||||
constructor(
|
||||
extHostContext: IExtHostContext,
|
||||
@IResourceProviderService private _resourceProviderService: IResourceProviderService
|
||||
) {
|
||||
super();
|
||||
this._providerMetadata = {};
|
||||
if (extHostContext) {
|
||||
this._proxy = extHostContext.getProxy(SqlExtHostContext.ExtHostResourceProvider);
|
||||
}
|
||||
this._toDispose = [];
|
||||
}
|
||||
|
||||
public $registerResourceProvider(providerMetadata: azdata.ResourceProviderMetadata, handle: number): Thenable<any> {
|
||||
@@ -55,8 +54,4 @@ export class MainThreadResourceProvider implements MainThreadResourceProviderSha
|
||||
this._resourceProviderService.unregisterProvider(this._providerMetadata[handle].id);
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this._toDispose = dispose(this._toDispose);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import { IBackupUiService } from 'sql/workbench/services/backup/common/backupUiS
|
||||
import * as cr from 'vs/platform/theme/common/colorRegistry';
|
||||
|
||||
import { MessageType } from 'vs/base/browser/ui/inputbox/inputBox';
|
||||
import * as lifecycle from 'vs/base/common/lifecycle';
|
||||
import { localize } from 'vs/nls';
|
||||
import * as types from 'vs/base/common/types';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
@@ -33,6 +32,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
|
||||
import { ISelectOptionItem } from 'vs/base/browser/ui/selectBox/selectBox';
|
||||
import { KeyCode } from 'vs/base/common/keyCodes';
|
||||
import { ITheme } from 'vs/platform/theme/common/themeService';
|
||||
import { AngularDisposable } from 'sql/base/browser/lifecycle';
|
||||
|
||||
export const BACKUP_SELECTOR: string = 'backup-component';
|
||||
|
||||
@@ -115,7 +115,7 @@ const LocalizedStrings = {
|
||||
selector: BACKUP_SELECTOR,
|
||||
templateUrl: decodeURI(require.toUrl('./backup.component.html'))
|
||||
})
|
||||
export class BackupComponent {
|
||||
export class BackupComponent extends AngularDisposable {
|
||||
@ViewChild('pathContainer', { read: ElementRef }) pathElement;
|
||||
@ViewChild('backupTypeContainer', { read: ElementRef }) backupTypeElement;
|
||||
@ViewChild('backupsetName', { read: ElementRef }) backupNameElement;
|
||||
@@ -147,7 +147,6 @@ export class BackupComponent {
|
||||
private localizedStrings = LocalizedStrings;
|
||||
|
||||
private _uri: string;
|
||||
private _toDispose: lifecycle.IDisposable[] = [];
|
||||
private _advancedHeaderSize = 32;
|
||||
|
||||
private connection: IConnectionProfile;
|
||||
@@ -209,6 +208,7 @@ export class BackupComponent {
|
||||
@Inject(IConnectionManagementService) private connectionManagementService: IConnectionManagementService,
|
||||
@Inject(IInstantiationService) private instantiationService: IInstantiationService
|
||||
) {
|
||||
super();
|
||||
this._backupUiService.onShowBackupEvent((param) => this.onGetBackupConfigInfo(param));
|
||||
}
|
||||
|
||||
@@ -293,26 +293,26 @@ export class BackupComponent {
|
||||
this.pathListBox.render(this.pathElement.nativeElement);
|
||||
|
||||
// Set backup path add/remove buttons
|
||||
this.addPathButton = new Button(this.addPathElement.nativeElement);
|
||||
this.addPathButton = this._register(new Button(this.addPathElement.nativeElement));
|
||||
this.addPathButton.label = '+';
|
||||
this.addPathButton.title = localize('addFile', "Add a file");
|
||||
|
||||
this.removePathButton = new Button(this.removePathElement.nativeElement);
|
||||
this.removePathButton = this._register(new Button(this.removePathElement.nativeElement));
|
||||
this.removePathButton.label = '-';
|
||||
this.removePathButton.title = localize('removeFile', "Remove files");
|
||||
|
||||
// Set compression
|
||||
this.compressionSelectBox = new SelectBox(this.compressionOptions, this.compressionOptions[0], this.contextViewService, undefined, { ariaLabel: this.localizedStrings.SET_BACKUP_COMPRESSION });
|
||||
this.compressionSelectBox = this._register(new SelectBox(this.compressionOptions, this.compressionOptions[0], this.contextViewService, undefined, { ariaLabel: this.localizedStrings.SET_BACKUP_COMPRESSION }));
|
||||
this.compressionSelectBox.render(this.compressionElement.nativeElement);
|
||||
|
||||
// Set encryption
|
||||
this.algorithmSelectBox = new SelectBox(this.encryptionAlgorithms, this.encryptionAlgorithms[0], this.contextViewService, undefined, { ariaLabel: this.localizedStrings.ALGORITHM });
|
||||
this.algorithmSelectBox = this._register(new SelectBox(this.encryptionAlgorithms, this.encryptionAlgorithms[0], this.contextViewService, undefined, { ariaLabel: this.localizedStrings.ALGORITHM }));
|
||||
this.algorithmSelectBox.render(this.encryptionAlgorithmElement.nativeElement);
|
||||
this.encryptorSelectBox = new SelectBox([], '', this.contextViewService, undefined, { ariaLabel: this.localizedStrings.CERTIFICATE_OR_ASYMMETRIC_KEY });
|
||||
this.encryptorSelectBox = this._register(new SelectBox([], '', this.contextViewService, undefined, { ariaLabel: this.localizedStrings.CERTIFICATE_OR_ASYMMETRIC_KEY }));
|
||||
this.encryptorSelectBox.render(this.encryptorElement.nativeElement);
|
||||
|
||||
// Set media
|
||||
this.mediaNameBox = new InputBox(this.mediaNameElement.nativeElement,
|
||||
this.mediaNameBox = this._register(new InputBox(this.mediaNameElement.nativeElement,
|
||||
this.contextViewService,
|
||||
{
|
||||
validationOptions: {
|
||||
@@ -320,15 +320,15 @@ export class BackupComponent {
|
||||
},
|
||||
ariaLabel: LocalizedStrings.NEW_MEDIA_SET_NAME
|
||||
}
|
||||
);
|
||||
));
|
||||
|
||||
this.mediaDescriptionBox = new InputBox(this.mediaDescriptionElement.nativeElement, this.contextViewService, {
|
||||
this.mediaDescriptionBox = this._register(new InputBox(this.mediaDescriptionElement.nativeElement, this.contextViewService, {
|
||||
ariaLabel: LocalizedStrings.NEW_MEDIA_SET_DESCRIPTION
|
||||
});
|
||||
}));
|
||||
|
||||
// Set backup retain days
|
||||
let invalidInputMessage = localize('backupComponent.invalidInput', "Invalid input. Value must be greater than or equal 0.");
|
||||
this.backupRetainDaysBox = new InputBox(this.backupDaysElement.nativeElement,
|
||||
this.backupRetainDaysBox = this._register(new InputBox(this.backupDaysElement.nativeElement,
|
||||
this.contextViewService,
|
||||
{
|
||||
placeholder: '0',
|
||||
@@ -344,7 +344,7 @@ export class BackupComponent {
|
||||
}
|
||||
},
|
||||
ariaLabel: LocalizedStrings.SET_BACKUP_RETAIN_DAYS
|
||||
});
|
||||
}));
|
||||
|
||||
// Disable elements
|
||||
this.recoveryBox.disable();
|
||||
@@ -402,24 +402,24 @@ export class BackupComponent {
|
||||
|
||||
private addFooterButtons(): void {
|
||||
// Set script footer button
|
||||
this.scriptButton = new Button(this.scriptButtonElement.nativeElement);
|
||||
this.scriptButton = this._register(new Button(this.scriptButtonElement.nativeElement));
|
||||
this.scriptButton.label = localize('backupComponent.script', "Script");
|
||||
this.addButtonClickHandler(this.scriptButton, () => this.onScript());
|
||||
this._toDispose.push(attachButtonStyler(this.scriptButton, this.themeService));
|
||||
this._register(attachButtonStyler(this.scriptButton, this.themeService));
|
||||
this.scriptButton.enabled = false;
|
||||
|
||||
// Set backup footer button
|
||||
this.backupButton = new Button(this.backupButtonElement.nativeElement);
|
||||
this.backupButton = this._register(new Button(this.backupButtonElement.nativeElement));
|
||||
this.backupButton.label = localize('backupComponent.backup', "Backup");
|
||||
this.addButtonClickHandler(this.backupButton, () => this.onOk());
|
||||
this._toDispose.push(attachButtonStyler(this.backupButton, this.themeService));
|
||||
this._register(attachButtonStyler(this.backupButton, this.themeService));
|
||||
this.backupEnabled = false;
|
||||
|
||||
// Set cancel footer button
|
||||
this.cancelButton = new Button(this.cancelButtonElement.nativeElement);
|
||||
this.cancelButton = this._register(new Button(this.cancelButtonElement.nativeElement));
|
||||
this.cancelButton.label = localize('backupComponent.cancel', "Cancel");
|
||||
this.addButtonClickHandler(this.cancelButton, () => this.onCancel());
|
||||
this._toDispose.push(attachButtonStyler(this.cancelButton, this.themeService));
|
||||
this._register(attachButtonStyler(this.cancelButton, this.themeService));
|
||||
}
|
||||
|
||||
private initialize(isMetadataPopulated: boolean): void {
|
||||
@@ -523,35 +523,35 @@ export class BackupComponent {
|
||||
|
||||
private registerListeners(): void {
|
||||
// Theme styler
|
||||
this._toDispose.push(attachInputBoxStyler(this.backupNameBox, this.themeService));
|
||||
this._toDispose.push(attachInputBoxStyler(this.recoveryBox, this.themeService));
|
||||
this._toDispose.push(attachSelectBoxStyler(this.backupTypeSelectBox, this.themeService));
|
||||
this._toDispose.push(attachListBoxStyler(this.pathListBox, this.themeService));
|
||||
this._toDispose.push(attachButtonStyler(this.addPathButton, this.themeService));
|
||||
this._toDispose.push(attachButtonStyler(this.removePathButton, this.themeService));
|
||||
this._toDispose.push(attachSelectBoxStyler(this.compressionSelectBox, this.themeService));
|
||||
this._toDispose.push(attachSelectBoxStyler(this.algorithmSelectBox, this.themeService));
|
||||
this._toDispose.push(attachSelectBoxStyler(this.encryptorSelectBox, this.themeService));
|
||||
this._toDispose.push(attachInputBoxStyler(this.mediaNameBox, this.themeService));
|
||||
this._toDispose.push(attachInputBoxStyler(this.mediaDescriptionBox, this.themeService));
|
||||
this._toDispose.push(attachInputBoxStyler(this.backupRetainDaysBox, this.themeService));
|
||||
this._toDispose.push(attachCheckboxStyler(this.copyOnlyCheckBox, this.themeService));
|
||||
this._toDispose.push(attachCheckboxStyler(this.encryptCheckBox, this.themeService));
|
||||
this._toDispose.push(attachCheckboxStyler(this.verifyCheckBox, this.themeService));
|
||||
this._toDispose.push(attachCheckboxStyler(this.checksumCheckBox, this.themeService));
|
||||
this._toDispose.push(attachCheckboxStyler(this.continueOnErrorCheckBox, this.themeService));
|
||||
this._register(attachInputBoxStyler(this.backupNameBox, this.themeService));
|
||||
this._register(attachInputBoxStyler(this.recoveryBox, this.themeService));
|
||||
this._register(attachSelectBoxStyler(this.backupTypeSelectBox, this.themeService));
|
||||
this._register(attachListBoxStyler(this.pathListBox, this.themeService));
|
||||
this._register(attachButtonStyler(this.addPathButton, this.themeService));
|
||||
this._register(attachButtonStyler(this.removePathButton, this.themeService));
|
||||
this._register(attachSelectBoxStyler(this.compressionSelectBox, this.themeService));
|
||||
this._register(attachSelectBoxStyler(this.algorithmSelectBox, this.themeService));
|
||||
this._register(attachSelectBoxStyler(this.encryptorSelectBox, this.themeService));
|
||||
this._register(attachInputBoxStyler(this.mediaNameBox, this.themeService));
|
||||
this._register(attachInputBoxStyler(this.mediaDescriptionBox, this.themeService));
|
||||
this._register(attachInputBoxStyler(this.backupRetainDaysBox, this.themeService));
|
||||
this._register(attachCheckboxStyler(this.copyOnlyCheckBox, this.themeService));
|
||||
this._register(attachCheckboxStyler(this.encryptCheckBox, this.themeService));
|
||||
this._register(attachCheckboxStyler(this.verifyCheckBox, this.themeService));
|
||||
this._register(attachCheckboxStyler(this.checksumCheckBox, this.themeService));
|
||||
this._register(attachCheckboxStyler(this.continueOnErrorCheckBox, this.themeService));
|
||||
|
||||
this._toDispose.push(this.backupTypeSelectBox.onDidSelect(selected => this.onBackupTypeChanged()));
|
||||
this._register(this.backupTypeSelectBox.onDidSelect(selected => this.onBackupTypeChanged()));
|
||||
this.addButtonClickHandler(this.addPathButton, () => this.onAddClick());
|
||||
this.addButtonClickHandler(this.removePathButton, () => this.onRemoveClick());
|
||||
this._toDispose.push(this.mediaNameBox.onDidChange(mediaName => {
|
||||
this._register(this.mediaNameBox.onDidChange(mediaName => {
|
||||
this.mediaNameChanged(mediaName);
|
||||
}));
|
||||
this._toDispose.push(this.backupRetainDaysBox.onDidChange(days => {
|
||||
this._register(this.backupRetainDaysBox.onDidChange(days => {
|
||||
this.backupRetainDaysChanged(days);
|
||||
}));
|
||||
|
||||
this._toDispose.push(this.themeService.onDidColorThemeChange(e => this.updateTheme(e)));
|
||||
this._register(this.themeService.onDidColorThemeChange(e => this.updateTheme(e)));
|
||||
}
|
||||
|
||||
// Update theming that is specific to backup dialog
|
||||
|
||||
@@ -200,7 +200,7 @@ export class ChartView extends Disposable implements IPanelView {
|
||||
private buildOptions() {
|
||||
// The first element in the disposables list is for the chart type: the master dropdown that controls other option controls.
|
||||
// whiling rebuilding the options we should not dispose it, otherwise it would react to the theme change event
|
||||
if (this.optionDisposables.length > 1) {
|
||||
if (this.optionDisposables.length > 1) { // this logic needs to be rewritten
|
||||
dispose(this.optionDisposables.slice(1));
|
||||
this.optionDisposables.splice(1);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import { Action, IAction } from 'vs/base/common/actions';
|
||||
import * as nls from 'vs/nls';
|
||||
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
|
||||
import { IAngularEventingService, AngularEventType, IAngularEvent } from 'sql/platform/angularEventing/common/angularEventingService';
|
||||
import { INewDashboardTabDialogService } from 'sql/workbench/services/dashboard/browser/newDashboardTabDialog';
|
||||
@@ -157,8 +156,6 @@ export class AddFeatureTabAction extends Action {
|
||||
private static readonly LABEL = nls.localize('addFeatureAction.openInstalledFeatures', "Open installed features");
|
||||
private static readonly ICON = 'new';
|
||||
|
||||
private _disposables: IDisposable[] = [];
|
||||
|
||||
constructor(
|
||||
private _dashboardTabs: Array<IDashboardTab>,
|
||||
private _openedTabs: Array<IDashboardTab>,
|
||||
@@ -167,7 +164,7 @@ export class AddFeatureTabAction extends Action {
|
||||
@IAngularEventingService private _angularEventService: IAngularEventingService
|
||||
) {
|
||||
super(AddFeatureTabAction.ID, AddFeatureTabAction.LABEL, AddFeatureTabAction.ICON);
|
||||
this._disposables.push(subscriptionToDisposable(this._angularEventService.onAngularEvent(this._uri, (event) => this.handleDashboardEvent(event))));
|
||||
this._register(subscriptionToDisposable(this._angularEventService.onAngularEvent(this._uri, (event) => this.handleDashboardEvent(event))));
|
||||
}
|
||||
|
||||
run(): Promise<boolean> {
|
||||
@@ -175,11 +172,6 @@ export class AddFeatureTabAction extends Action {
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
dispose() {
|
||||
super.dispose();
|
||||
this._disposables.forEach((item) => item.dispose());
|
||||
}
|
||||
|
||||
private handleDashboardEvent(event: IAngularEvent): void {
|
||||
switch (event.event) {
|
||||
case AngularEventType.NEW_TABS:
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
import { localize } from 'vs/nls';
|
||||
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { IAction } from 'vs/base/common/actions';
|
||||
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
|
||||
import { append, $, addClass, toggleClass, Dimension } from 'vs/base/browser/dom';
|
||||
@@ -74,13 +73,11 @@ export class DataExplorerViewlet extends ViewContainerViewlet {
|
||||
private root: HTMLElement;
|
||||
|
||||
private dataSourcesBox: HTMLElement;
|
||||
private disposables: IDisposable[] = [];
|
||||
|
||||
constructor(
|
||||
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService,
|
||||
@ITelemetryService telemetryService: ITelemetryService,
|
||||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
@IViewletService private viewletService: IViewletService,
|
||||
@IThemeService themeService: IThemeService,
|
||||
@IStorageService storageService: IStorageService,
|
||||
@IWorkspaceContextService contextService: IWorkspaceContextService,
|
||||
@@ -144,9 +141,4 @@ export class DataExplorerViewlet extends ViewContainerViewlet {
|
||||
this._register(viewletPanel);
|
||||
return viewletPanel;
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this.disposables = dispose(this.disposables);
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Action, IActionViewItem, IActionRunner } from 'vs/base/common/actions';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { DisposableStore, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IQueryModelService } from 'sql/platform/query/common/queryModel';
|
||||
import { SelectBox } from 'sql/base/browser/ui/selectBox/selectBox';
|
||||
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||
@@ -150,14 +150,13 @@ export class ChangeMaxRowsAction extends EditDataAction {
|
||||
* Action item that handles the dropdown (combobox) that lists the avaliable number of row selections
|
||||
* for an edit data session
|
||||
*/
|
||||
export class ChangeMaxRowsActionItem implements IActionViewItem {
|
||||
export class ChangeMaxRowsActionItem extends Disposable implements IActionViewItem {
|
||||
|
||||
public actionRunner: IActionRunner;
|
||||
public defaultRowCount: number;
|
||||
private container: HTMLElement;
|
||||
private start: HTMLElement;
|
||||
private selectBox: SelectBox;
|
||||
private toDispose: IDisposable[];
|
||||
private context: any;
|
||||
private _options: string[];
|
||||
private _currentOptionsIndex: number;
|
||||
@@ -166,15 +165,15 @@ export class ChangeMaxRowsActionItem implements IActionViewItem {
|
||||
private _editor: EditDataEditor,
|
||||
@IContextViewService contextViewService: IContextViewService,
|
||||
@IThemeService private _themeService: IThemeService) {
|
||||
super();
|
||||
this._options = ['200', '1000', '10000'];
|
||||
this._currentOptionsIndex = 0;
|
||||
this.toDispose = [];
|
||||
this.selectBox = new SelectBox(this._options, this._options[this._currentOptionsIndex], contextViewService);
|
||||
this._registerListeners();
|
||||
this._refreshOptions();
|
||||
this.defaultRowCount = Number(this._options[this._currentOptionsIndex]);
|
||||
|
||||
this.toDispose.push(attachSelectBoxStyler(this.selectBox, _themeService));
|
||||
this._register(attachSelectBoxStyler(this.selectBox, _themeService));
|
||||
}
|
||||
|
||||
public render(container: HTMLElement): void {
|
||||
@@ -211,20 +210,16 @@ export class ChangeMaxRowsActionItem implements IActionViewItem {
|
||||
this.container.blur();
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this.toDispose = dispose(this.toDispose);
|
||||
}
|
||||
|
||||
private _refreshOptions(databaseIndex?: number): void {
|
||||
this.selectBox.setOptions(this._options, this._currentOptionsIndex);
|
||||
}
|
||||
|
||||
private _registerListeners(): void {
|
||||
this.toDispose.push(this.selectBox.onDidSelect(selection => {
|
||||
this._register(this.selectBox.onDidSelect(selection => {
|
||||
this._currentOptionsIndex = this._options.findIndex(x => x === selection.selected);
|
||||
this._editor.editDataInput.onRowDropDownSet(Number(selection.selected));
|
||||
}));
|
||||
this.toDispose.push(attachSelectBoxStyler(this.selectBox, this._themeService));
|
||||
this._register(attachSelectBoxStyler(this.selectBox, this._themeService));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,4 +258,4 @@ export class ShowQueryPaneAction extends EditDataAction {
|
||||
this.updateLabel(this.editor.queryPaneEnabled());
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import { ResolvedKeybinding } from 'vs/base/common/keyCodes';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
||||
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
@@ -54,7 +54,7 @@ export abstract class GridParentComponent {
|
||||
protected dataService: DataService;
|
||||
protected actionProvider: actions.GridActionProvider;
|
||||
|
||||
protected toDispose: IDisposable[];
|
||||
protected toDispose = new DisposableStore();
|
||||
|
||||
|
||||
// Context keys to set when keybindings are available
|
||||
@@ -97,7 +97,6 @@ export abstract class GridParentComponent {
|
||||
protected queryEditorService: IQueryEditorService,
|
||||
protected logService: ILogService
|
||||
) {
|
||||
this.toDispose = [];
|
||||
}
|
||||
|
||||
protected baseInit(): void {
|
||||
@@ -177,7 +176,7 @@ export abstract class GridParentComponent {
|
||||
*/
|
||||
protected subscribeWithDispose<T>(subject: Subject<T>, event: (value: any) => void): void {
|
||||
let sub: Subscription = subject.subscribe(event);
|
||||
this.toDispose.push(subscriptionToDisposable(sub));
|
||||
this.toDispose.add(subscriptionToDisposable(sub));
|
||||
}
|
||||
|
||||
private bindKeys(contextKeyService: IContextKeyService): void {
|
||||
@@ -186,7 +185,7 @@ export abstract class GridParentComponent {
|
||||
this.queryEditorVisible.set(true);
|
||||
|
||||
let gridContextKeyService = this.contextKeyService.createScoped(this._el.nativeElement);
|
||||
this.toDispose.push(gridContextKeyService);
|
||||
this.toDispose.add(gridContextKeyService);
|
||||
this.resultsVisibleContextKey = ResultsVisibleContext.bindTo(gridContextKeyService);
|
||||
this.resultsVisibleContextKey.set(true);
|
||||
|
||||
@@ -196,7 +195,7 @@ export abstract class GridParentComponent {
|
||||
}
|
||||
|
||||
protected baseDestroy(): void {
|
||||
this.toDispose = dispose(this.toDispose);
|
||||
this.toDispose.dispose();
|
||||
}
|
||||
|
||||
protected toggleResultPane(): void {
|
||||
|
||||
@@ -7,7 +7,7 @@ import { nb, connection } from 'azdata';
|
||||
|
||||
import { localize } from 'vs/nls';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
|
||||
import { IClientSession, INotebookModel, IDefaultConnection, INotebookModelOptions, ICellModel, NotebookContentChange, notebookConstants } from 'sql/workbench/parts/notebook/common/models/modelInterfaces';
|
||||
import { NotebookChangeType, CellType, CellTypes } from 'sql/workbench/parts/notebook/common/models/contracts';
|
||||
@@ -73,7 +73,7 @@ export class NotebookModel extends Disposable implements INotebookModel {
|
||||
private _kernelDisplayNameToNotebookProviderIds: Map<string, string> = new Map<string, string>();
|
||||
private _onValidConnectionSelected = new Emitter<boolean>();
|
||||
private _oldKernel: nb.IKernel;
|
||||
private _clientSessionListeners: IDisposable[] = [];
|
||||
private _clientSessionListeners = new DisposableStore(); // should this be registered?
|
||||
private _connectionUrisToDispose: string[] = [];
|
||||
private _textCellsLoading: number = 0;
|
||||
private _standardKernels: notebookUtils.IStandardKernelWithProvider[];
|
||||
@@ -486,12 +486,11 @@ export class NotebookModel extends Disposable implements INotebookModel {
|
||||
private updateActiveClientSession(clientSession: IClientSession) {
|
||||
this.clearClientSessionListeners();
|
||||
this._activeClientSession = clientSession;
|
||||
this._clientSessionListeners.push(this._activeClientSession.kernelChanged(e => this._kernelChangedEmitter.fire(e)));
|
||||
this._clientSessionListeners.add(this._activeClientSession.kernelChanged(e => this._kernelChangedEmitter.fire(e)));
|
||||
}
|
||||
|
||||
private clearClientSessionListeners() {
|
||||
this._clientSessionListeners.forEach(listener => listener.dispose());
|
||||
this._clientSessionListeners = [];
|
||||
this._clientSessionListeners.clear();
|
||||
}
|
||||
|
||||
public setDefaultKernelAndProviderId() {
|
||||
|
||||
@@ -10,7 +10,7 @@ import Severity from 'vs/base/common/severity';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { attachListStyler } from 'vs/platform/theme/common/styler';
|
||||
import { ITree } from 'vs/base/parts/tree/browser/tree';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { IDisposable, dispose, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { localize } from 'vs/nls';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
@@ -39,14 +39,13 @@ import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
/**
|
||||
* ServerTreeview implements the dynamic tree view.
|
||||
*/
|
||||
export class ServerTreeView {
|
||||
export class ServerTreeView extends Disposable {
|
||||
|
||||
public messages: HTMLElement;
|
||||
private _buttonSection: HTMLElement;
|
||||
private _treeSelectionHandler: TreeSelectionHandler;
|
||||
private _activeConnectionsFilterAction: ActiveConnectionsFilterAction;
|
||||
private _tree: ITree;
|
||||
private _toDispose: IDisposable[] = [];
|
||||
private _onSelectionOrFocusChange: Emitter<void>;
|
||||
private _actionProvider: ServerTreeActionProvider;
|
||||
|
||||
@@ -59,6 +58,7 @@ export class ServerTreeView {
|
||||
@IConfigurationService private _configurationService: IConfigurationService,
|
||||
@ICapabilitiesService capabilitiesService: ICapabilitiesService
|
||||
) {
|
||||
super();
|
||||
this._activeConnectionsFilterAction = this._instantiationService.createInstance(
|
||||
ActiveConnectionsFilterAction,
|
||||
ActiveConnectionsFilterAction.ID,
|
||||
@@ -133,35 +133,35 @@ export class ServerTreeView {
|
||||
this._buttonSection = append(container, $('.button-section'));
|
||||
const connectButton = new Button(this._buttonSection);
|
||||
connectButton.label = localize('serverTree.addConnection', "Add Connection");
|
||||
this._toDispose.push(attachButtonStyler(connectButton, this._themeService));
|
||||
this._toDispose.push(connectButton.onDidClick(() => {
|
||||
this._register(attachButtonStyler(connectButton, this._themeService));
|
||||
this._register(connectButton.onDidClick(() => {
|
||||
this._connectionManagementService.showConnectionDialog();
|
||||
}));
|
||||
}
|
||||
this._tree = TreeCreationUtils.createRegisteredServersTree(container, this._instantiationService);
|
||||
this._tree = this._register(TreeCreationUtils.createRegisteredServersTree(container, this._instantiationService));
|
||||
//this._tree.setInput(undefined);
|
||||
this._toDispose.push(this._tree.onDidChangeSelection((event) => this.onSelected(event)));
|
||||
this._toDispose.push(this._tree.onDidBlur(() => this._onSelectionOrFocusChange.fire()));
|
||||
this._toDispose.push(this._tree.onDidChangeFocus(() => this._onSelectionOrFocusChange.fire()));
|
||||
this._register(this._tree.onDidChangeSelection((event) => this.onSelected(event)));
|
||||
this._register(this._tree.onDidBlur(() => this._onSelectionOrFocusChange.fire()));
|
||||
this._register(this._tree.onDidChangeFocus(() => this._onSelectionOrFocusChange.fire()));
|
||||
|
||||
// Theme styler
|
||||
this._toDispose.push(attachListStyler(this._tree, this._themeService));
|
||||
this._register(attachListStyler(this._tree, this._themeService));
|
||||
|
||||
// Refresh Tree when these events are emitted
|
||||
this._toDispose.push(this._connectionManagementService.onAddConnectionProfile((newProfile: IConnectionProfile) => {
|
||||
this._register(this._connectionManagementService.onAddConnectionProfile((newProfile: IConnectionProfile) => {
|
||||
this.handleAddConnectionProfile(newProfile);
|
||||
}));
|
||||
this._toDispose.push(this._connectionManagementService.onDeleteConnectionProfile(() => {
|
||||
this._register(this._connectionManagementService.onDeleteConnectionProfile(() => {
|
||||
this.refreshTree();
|
||||
}));
|
||||
this._toDispose.push(this._connectionManagementService.onDisconnect((connectionParams) => {
|
||||
this._register(this._connectionManagementService.onDisconnect((connectionParams) => {
|
||||
if (this.isObjectExplorerConnectionUri(connectionParams.connectionUri)) {
|
||||
this.deleteObjectExplorerNodeAndRefreshTree(connectionParams.connectionProfile);
|
||||
}
|
||||
}));
|
||||
|
||||
if (this._objectExplorerService && this._objectExplorerService.onUpdateObjectExplorerNodes) {
|
||||
this._toDispose.push(this._objectExplorerService.onUpdateObjectExplorerNodes(args => {
|
||||
this._register(this._objectExplorerService.onUpdateObjectExplorerNodes(args => {
|
||||
if (args.errorMessage) {
|
||||
this.showError(args.errorMessage);
|
||||
}
|
||||
@@ -511,12 +511,4 @@ export class ServerTreeView {
|
||||
public isExpanded(element: TreeNode | ConnectionProfile): boolean {
|
||||
return this._tree.isExpanded(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* dispose the server tree view
|
||||
*/
|
||||
public dispose(): void {
|
||||
this._tree.dispose();
|
||||
this._toDispose = dispose(this._toDispose);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user