mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-22 09:35:37 -05:00
Clean up some more disposable usage (#7190)
* clean up some more disposable usage * fix a bug * add more to register
This commit is contained in:
@@ -30,7 +30,7 @@ import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { isUndefinedOrNull } from 'vs/base/common/types';
|
||||
import { range } from 'vs/base/common/arrays';
|
||||
import { Orientation } from 'vs/base/browser/ui/splitview/splitview';
|
||||
import { Disposable, IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { Disposable, dispose, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { Separator, ActionBar, ActionsOrientation } from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
import { isInDOM, Dimension } from 'vs/base/browser/dom';
|
||||
@@ -59,12 +59,12 @@ const ACTIONBAR_HEIGHT = 120;
|
||||
// this handles min size if rows is greater than the min grid visible rows
|
||||
const MIN_GRID_HEIGHT = (MIN_GRID_HEIGHT_ROWS * ROW_HEIGHT) + HEADER_HEIGHT + ESTIMATED_SCROLL_BAR_HEIGHT;
|
||||
|
||||
export class GridPanel {
|
||||
export class GridPanel extends Disposable {
|
||||
private container = document.createElement('div');
|
||||
private splitView: ScrollableSplitView;
|
||||
private tables: GridTable<any>[] = [];
|
||||
private tableDisposable: IDisposable[] = [];
|
||||
private queryRunnerDisposables: IDisposable[] = [];
|
||||
private tableDisposable = this._register(new DisposableStore());
|
||||
private queryRunnerDisposables = this._register(new DisposableStore());
|
||||
private currentHeight: number;
|
||||
|
||||
private runner: QueryRunner;
|
||||
@@ -78,6 +78,7 @@ export class GridPanel {
|
||||
@IInstantiationService private readonly instantiationService: IInstantiationService,
|
||||
@ILogService private readonly logService: ILogService
|
||||
) {
|
||||
super();
|
||||
this.splitView = new ScrollableSplitView(this.container, { enableResizing: false, verticalScrollbarVisibility: ScrollbarVisibility.Visible });
|
||||
this.splitView.onScroll(e => {
|
||||
if (this.state && this.splitView.length !== 0) {
|
||||
@@ -107,13 +108,12 @@ export class GridPanel {
|
||||
}
|
||||
|
||||
public set queryRunner(runner: QueryRunner) {
|
||||
dispose(this.queryRunnerDisposables);
|
||||
this.queryRunnerDisposables.clear();
|
||||
this.reset();
|
||||
this.queryRunnerDisposables = [];
|
||||
this.runner = runner;
|
||||
this.queryRunnerDisposables.push(this.runner.onResultSet(this.onResultSet, this));
|
||||
this.queryRunnerDisposables.push(this.runner.onResultSetUpdate(this.updateResultSet, this));
|
||||
this.queryRunnerDisposables.push(this.runner.onQueryStart(() => {
|
||||
this.queryRunnerDisposables.add(this.runner.onResultSet(this.onResultSet, this));
|
||||
this.queryRunnerDisposables.add(this.runner.onResultSetUpdate(this.updateResultSet, this));
|
||||
this.queryRunnerDisposables.add(this.runner.onQueryStart(() => {
|
||||
if (this.state) {
|
||||
this.state.tableStates = [];
|
||||
}
|
||||
@@ -218,14 +218,14 @@ export class GridPanel {
|
||||
}
|
||||
}
|
||||
let table = this.instantiationService.createInstance(GridTable, this.runner, set, tableState);
|
||||
this.tableDisposable.push(tableState.onMaximizedChange(e => {
|
||||
this.tableDisposable.add(tableState.onMaximizedChange(e => {
|
||||
if (e) {
|
||||
this.maximizeTable(table.id);
|
||||
} else {
|
||||
this.minimizeTables();
|
||||
}
|
||||
}));
|
||||
this.tableDisposable.push(attachTableStyler(table, this.themeService));
|
||||
this.tableDisposable.add(attachTableStyler(table, this.themeService));
|
||||
|
||||
tables.push(table);
|
||||
}
|
||||
@@ -254,8 +254,7 @@ export class GridPanel {
|
||||
this.splitView.removeView(i);
|
||||
}
|
||||
dispose(this.tables);
|
||||
dispose(this.tableDisposable);
|
||||
this.tableDisposable = [];
|
||||
this.tableDisposable.clear();
|
||||
this.tables = [];
|
||||
this.maximizedGrid = undefined;
|
||||
}
|
||||
@@ -305,11 +304,9 @@ export class GridPanel {
|
||||
}
|
||||
|
||||
public dispose() {
|
||||
dispose(this.queryRunnerDisposables);
|
||||
dispose(this.tableDisposable);
|
||||
dispose(this.tables);
|
||||
this.tableDisposable = undefined;
|
||||
this.tables = undefined;
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
|
||||
import { OpenMode, ClickBehavior, ICancelableEvent, IControllerOptions } from 'vs/base/parts/tree/browser/treeDefaults';
|
||||
import { WorkbenchTreeController } from 'vs/platform/list/browser/listService';
|
||||
import { isArray } from 'vs/base/common/types';
|
||||
import { IDisposable, dispose, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { ScrollbarVisibility } from 'vs/base/common/scrollable';
|
||||
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
||||
@@ -68,7 +68,7 @@ export class MessagePanel extends Disposable {
|
||||
private container = $('.message-tree');
|
||||
private styleElement = createStyleSheet(this.container);
|
||||
|
||||
private queryRunnerDisposables: IDisposable[] = [];
|
||||
private queryRunnerDisposables = this._register(new DisposableStore());
|
||||
private _state: MessagePanelState | undefined;
|
||||
|
||||
private tree: ITree;
|
||||
@@ -175,11 +175,10 @@ export class MessagePanel extends Disposable {
|
||||
}
|
||||
|
||||
public set queryRunner(runner: QueryRunner) {
|
||||
dispose(this.queryRunnerDisposables);
|
||||
this.queryRunnerDisposables = [];
|
||||
this.queryRunnerDisposables.clear();
|
||||
this.reset();
|
||||
this.queryRunnerDisposables.push(runner.onQueryStart(() => this.reset()));
|
||||
this.queryRunnerDisposables.push(runner.onMessage(e => this.onMessage(e)));
|
||||
this.queryRunnerDisposables.add(runner.onQueryStart(() => this.reset()));
|
||||
this.queryRunnerDisposables.add(runner.onMessage(e => this.onMessage(e)));
|
||||
this.onMessage(runner.messages);
|
||||
}
|
||||
|
||||
@@ -246,7 +245,6 @@ export class MessagePanel extends Disposable {
|
||||
}
|
||||
|
||||
public dispose() {
|
||||
dispose(this.queryRunnerDisposables);
|
||||
if (this.container) {
|
||||
this.container.remove();
|
||||
this.container = undefined;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import 'vs/css!./media/queryActions';
|
||||
import * as nls from 'vs/nls';
|
||||
import { Action, IActionViewItem, IActionRunner } from 'vs/base/common/actions';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { IDisposable, dispose, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
@@ -566,11 +566,10 @@ export class ToggleSqlCmdModeAction extends QueryTaskbarAction {
|
||||
* Action item that handles the dropdown (combobox) that lists the available databases.
|
||||
* Based off StartDebugActionItem.
|
||||
*/
|
||||
export class ListDatabasesActionItem implements IActionViewItem {
|
||||
export class ListDatabasesActionItem extends Disposable implements IActionViewItem {
|
||||
public static ID = 'listDatabaseQueryActionItem';
|
||||
|
||||
public actionRunner: IActionRunner;
|
||||
private _toDispose: IDisposable[];
|
||||
private _currentDatabaseName: string;
|
||||
private _isConnected: boolean;
|
||||
private _databaseListDropdown: HTMLElement;
|
||||
@@ -587,7 +586,7 @@ export class ListDatabasesActionItem implements IActionViewItem {
|
||||
@INotificationService private readonly notificationService: INotificationService,
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService
|
||||
) {
|
||||
this._toDispose = [];
|
||||
super();
|
||||
this._databaseListDropdown = $('.databaseListDropdown');
|
||||
this._isInAccessibilityMode = this.configurationService.getValue('editor.accessibilitySupport') === 'on';
|
||||
|
||||
@@ -604,12 +603,12 @@ export class ListDatabasesActionItem implements IActionViewItem {
|
||||
ariaLabel: this._selectDatabaseString,
|
||||
actionLabel: nls.localize('listDatabases.toggleDatabaseNameDropdown', "Select Database Toggle Dropdown")
|
||||
});
|
||||
this._dropdown.onValueChange(s => this.databaseSelected(s));
|
||||
this._toDispose.push(this._dropdown.onFocus(() => this.onDropdownFocus()));
|
||||
this._register(this._dropdown.onValueChange(s => this.databaseSelected(s)));
|
||||
this._register(this._dropdown.onFocus(() => this.onDropdownFocus()));
|
||||
}
|
||||
|
||||
// Register event handlers
|
||||
this._toDispose.push(this.connectionManagementService.onConnectionChanged(params => this.onConnectionChanged(params)));
|
||||
this._register(this.connectionManagementService.onConnectionChanged(params => this.onConnectionChanged(params)));
|
||||
}
|
||||
|
||||
// PUBLIC METHODS //////////////////////////////////////////////////////
|
||||
@@ -657,10 +656,6 @@ export class ListDatabasesActionItem implements IActionViewItem {
|
||||
}
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this._toDispose = dispose(this._toDispose);
|
||||
}
|
||||
|
||||
// EVENT HANDLERS FROM EDITOR //////////////////////////////////////////
|
||||
public onConnected(): void {
|
||||
let dbName = this.getCurrentDatabaseName();
|
||||
|
||||
@@ -22,7 +22,7 @@ import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { IEditorGroup, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { SplitView, Sizing } from 'vs/base/browser/ui/splitview/splitview';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { dispose, IDisposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { ISelectionData } from 'azdata';
|
||||
import { Action, IActionViewItem } from 'vs/base/common/actions';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
@@ -68,7 +68,7 @@ export class QueryEditor extends BaseEditor {
|
||||
private splitviewContainer: HTMLElement;
|
||||
private splitview: SplitView;
|
||||
|
||||
private inputDisposables: IDisposable[] = [];
|
||||
private inputDisposables = this._register(new DisposableStore());
|
||||
|
||||
private resultsVisible = false;
|
||||
|
||||
@@ -313,9 +313,8 @@ export class QueryEditor extends BaseEditor {
|
||||
this.resultsEditor.setInput(newInput.results, options)
|
||||
]);
|
||||
|
||||
dispose(this.inputDisposables);
|
||||
this.inputDisposables = [];
|
||||
this.inputDisposables.push(this.input.state.onChange(c => this.updateState(c)));
|
||||
this.inputDisposables.clear();
|
||||
this.inputDisposables.add(this.input.state.onChange(c => this.updateState(c)));
|
||||
this.updateState({ connectingChange: true, connectedChange: true, executingChange: true, resultsVisibleChange: true, sqlCmdModeChanged: true });
|
||||
|
||||
const editorViewState = this.loadTextEditorViewState(this.input.getResource());
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import { Dimension } from 'vs/base/browser/dom';
|
||||
import { localize } from 'vs/nls';
|
||||
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
|
||||
import { Table } from 'sql/base/browser/ui/table/table';
|
||||
import { PlanXmlParser } from 'sql/workbench/parts/queryPlan/common/planXmlParser';
|
||||
@@ -34,17 +34,14 @@ const topOperationColumns: Array<Slick.Column<any>> = [
|
||||
{ name: localize('topOperations.partitioned', "Partitioned"), field: 'partitioned', sortable: true }
|
||||
];
|
||||
|
||||
export class TopOperationsTab implements IPanelTab {
|
||||
export class TopOperationsTab extends Disposable implements IPanelTab {
|
||||
public readonly title = localize('topOperationsTitle', "Top Operations");
|
||||
public readonly identifier = 'TopOperationsTab';
|
||||
public readonly view: TopOperationsView;
|
||||
|
||||
constructor(@IInstantiationService instantiationService: IInstantiationService) {
|
||||
this.view = instantiationService.createInstance(TopOperationsView);
|
||||
}
|
||||
|
||||
public dispose() {
|
||||
dispose(this.view);
|
||||
super();
|
||||
this.view = this._register(instantiationService.createInstance(TopOperationsView));
|
||||
}
|
||||
|
||||
public clear() {
|
||||
@@ -52,14 +49,14 @@ export class TopOperationsTab implements IPanelTab {
|
||||
}
|
||||
}
|
||||
|
||||
export class TopOperationsView implements IPanelView {
|
||||
export class TopOperationsView extends Disposable implements IPanelView {
|
||||
private _state: TopOperationsState;
|
||||
private table: Table<any>;
|
||||
private disposables: IDisposable[] = [];
|
||||
private container = document.createElement('div');
|
||||
private dataView = new TableDataView();
|
||||
|
||||
constructor(@IThemeService private themeService: IThemeService) {
|
||||
super();
|
||||
this.table = new Table(this.container, {
|
||||
columns: topOperationColumns,
|
||||
dataProvider: this.dataView,
|
||||
@@ -67,18 +64,14 @@ export class TopOperationsView implements IPanelView {
|
||||
this.dataView.sort(args);
|
||||
}
|
||||
});
|
||||
this.disposables.push(this.table);
|
||||
this.disposables.push(attachTableStyler(this.table, this.themeService));
|
||||
this._register(this.table);
|
||||
this._register(attachTableStyler(this.table, this.themeService));
|
||||
}
|
||||
|
||||
public render(container: HTMLElement): void {
|
||||
container.appendChild(this.container);
|
||||
}
|
||||
|
||||
dispose() {
|
||||
dispose(this.disposables);
|
||||
}
|
||||
|
||||
public layout(dimension: Dimension): void {
|
||||
this.table.layout(dimension);
|
||||
}
|
||||
|
||||
@@ -19,25 +19,24 @@ import { TASKS_PANEL_ID } from 'sql/workbench/parts/tasks/common/tasks';
|
||||
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
|
||||
import { ToggleTasksAction } from 'sql/workbench/parts/tasks/browser/tasksActions';
|
||||
|
||||
export class StatusUpdater implements ext.IWorkbenchContribution {
|
||||
export class StatusUpdater extends lifecycle.Disposable implements ext.IWorkbenchContribution {
|
||||
static ID = 'data.taskhistory.statusUpdater';
|
||||
|
||||
private badgeHandle: lifecycle.IDisposable;
|
||||
private toDispose: lifecycle.IDisposable[];
|
||||
|
||||
constructor(
|
||||
@IActivityService private readonly activityBarService: IActivityService,
|
||||
@ITaskService private readonly taskService: ITaskService,
|
||||
@IPanelService private readonly panelService: IPanelService
|
||||
) {
|
||||
this.toDispose = [];
|
||||
super();
|
||||
|
||||
this.toDispose.push(this.taskService.onAddNewTask(args => {
|
||||
this._register(this.taskService.onAddNewTask(args => {
|
||||
this.panelService.openPanel(TASKS_PANEL_ID, true);
|
||||
this.onServiceChange();
|
||||
}));
|
||||
|
||||
this.toDispose.push(this.taskService.onTaskComplete(task => {
|
||||
this._register(this.taskService.onTaskComplete(task => {
|
||||
this.onServiceChange();
|
||||
}));
|
||||
|
||||
@@ -55,8 +54,8 @@ export class StatusUpdater implements ext.IWorkbenchContribution {
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this.toDispose = lifecycle.dispose(this.toDispose);
|
||||
lifecycle.dispose(this.badgeHandle);
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import { Tree } from 'vs/base/parts/tree/browser/treeImpl';
|
||||
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 { dispose, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { DefaultFilter, DefaultDragAndDrop, DefaultAccessibilityProvider } from 'vs/base/parts/tree/browser/treeDefaults';
|
||||
import { localize } from 'vs/nls';
|
||||
import { hide, $, append } from 'vs/base/browser/dom';
|
||||
@@ -27,10 +27,9 @@ import { IExpandableTree } from 'sql/workbench/parts/objectExplorer/browser/tree
|
||||
/**
|
||||
* TaskHistoryView implements the dynamic tree view.
|
||||
*/
|
||||
export class TaskHistoryView {
|
||||
export class TaskHistoryView extends Disposable {
|
||||
private _messages: HTMLElement;
|
||||
private _tree: ITree;
|
||||
private _toDispose: IDisposable[] = [];
|
||||
|
||||
constructor(
|
||||
@IInstantiationService private _instantiationService: IInstantiationService,
|
||||
@@ -38,6 +37,7 @@ export class TaskHistoryView {
|
||||
@IErrorMessageService private _errorMessageService: IErrorMessageService,
|
||||
@IThemeService private _themeService: IThemeService
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,17 +56,17 @@ export class TaskHistoryView {
|
||||
let noTaskMessage = localize('noTaskMessage', "No task history to display.");
|
||||
append(this._messages, $('span')).innerText = noTaskMessage;
|
||||
|
||||
this._tree = this.createTaskHistoryTree(container, this._instantiationService);
|
||||
this._toDispose.push(this._tree.onDidChangeSelection((event) => this.onSelected(event)));
|
||||
this._tree = this._register(this.createTaskHistoryTree(container, this._instantiationService));
|
||||
this._register(this._tree.onDidChangeSelection((event) => this.onSelected(event)));
|
||||
|
||||
// Theme styler
|
||||
this._toDispose.push(attachListStyler(this._tree, this._themeService));
|
||||
this._register(attachListStyler(this._tree, this._themeService));
|
||||
|
||||
this._toDispose.push(this._taskService.onAddNewTask(args => {
|
||||
this._register(this._taskService.onAddNewTask(args => {
|
||||
hide(this._messages);
|
||||
this.refreshTree();
|
||||
}));
|
||||
this._toDispose.push(this._taskService.onTaskComplete(task => {
|
||||
this._register(this._taskService.onTaskComplete(task => {
|
||||
this.updateTask(task);
|
||||
}));
|
||||
|
||||
@@ -166,12 +166,4 @@ export class TaskHistoryView {
|
||||
this._tree.onHidden();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* dispose the server tree view
|
||||
*/
|
||||
public dispose(): void {
|
||||
this._tree.dispose();
|
||||
this._toDispose = dispose(this._toDispose);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
||||
import { localize } from 'vs/nls';
|
||||
import { IDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
|
||||
import * as DOM from 'vs/base/browser/dom';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
@@ -36,7 +36,6 @@ export class WebViewDialog extends Modal {
|
||||
public onOk: Event<void> = this._onOk.event;
|
||||
private _onClosed = new Emitter<void>();
|
||||
public onClosed: Event<void> = this._onClosed.event;
|
||||
private contentDisposables: IDisposable[] = [];
|
||||
private _onMessage = new Emitter<any>();
|
||||
|
||||
private readonly id = generateUuid();
|
||||
@@ -99,12 +98,10 @@ export class WebViewDialog extends Modal {
|
||||
|
||||
this._webview.mountTo(this._body);
|
||||
|
||||
this._webview.onMessage(message => {
|
||||
this._onMessage.fire(message);
|
||||
}, null, this.contentDisposables);
|
||||
this._register(this._webview.onMessage(message => this._onMessage.fire(message)));
|
||||
|
||||
this.contentDisposables.push(this._webview);
|
||||
this.contentDisposables.push(toDisposable(() => this._webview = null));
|
||||
this._register(this._webview);
|
||||
this._register(toDisposable(() => this._webview = null));
|
||||
}
|
||||
|
||||
get onMessage(): Event<any> {
|
||||
@@ -157,10 +154,4 @@ export class WebViewDialog extends Modal {
|
||||
this.show();
|
||||
this._okButton.focus();
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this.contentDisposables.forEach(element => {
|
||||
element.dispose();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ export class CmsConnectionWidget extends ConnectionWidget {
|
||||
protected registerListeners(): void {
|
||||
super.registerListeners();
|
||||
if (this._serverDescriptionInputBox) {
|
||||
this._toDispose.push(styler.attachInputBoxStyler(this._serverDescriptionInputBox, this._themeService));
|
||||
this._register(styler.attachInputBoxStyler(this._serverDescriptionInputBox, this._themeService));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ import { endsWith, startsWith } from 'vs/base/common/strings';
|
||||
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
|
||||
export class ConnectionWidget {
|
||||
export class ConnectionWidget extends lifecycle.Disposable {
|
||||
private _previousGroupOption: string;
|
||||
private _serverGroupOptions: IConnectionProfileGroup[];
|
||||
private _serverNameInputBox: InputBox;
|
||||
@@ -60,7 +60,6 @@ export class ConnectionWidget {
|
||||
protected _container: HTMLElement;
|
||||
protected _serverGroupSelectBox: SelectBox;
|
||||
protected _authTypeSelectBox: SelectBox;
|
||||
protected _toDispose: lifecycle.IDisposable[];
|
||||
protected _optionsMaps: { [optionType: number]: azdata.ConnectionOption };
|
||||
protected _tableContainer: HTMLElement;
|
||||
protected _providerName: string;
|
||||
@@ -103,8 +102,8 @@ export class ConnectionWidget {
|
||||
@IConfigurationService private _configurationService: IConfigurationService,
|
||||
@IAccountManagementService private _accountManagementService: IAccountManagementService
|
||||
) {
|
||||
super();
|
||||
this._callbacks = callbacks;
|
||||
this._toDispose = [];
|
||||
this._optionsMaps = {};
|
||||
for (let i = 0; i < options.length; i++) {
|
||||
let option = options[i];
|
||||
@@ -313,22 +312,22 @@ export class ConnectionWidget {
|
||||
|
||||
protected registerListeners(): void {
|
||||
// Theme styler
|
||||
this._toDispose.push(styler.attachInputBoxStyler(this._serverNameInputBox, this._themeService));
|
||||
this._toDispose.push(styler.attachInputBoxStyler(this._connectionNameInputBox, this._themeService));
|
||||
this._toDispose.push(styler.attachInputBoxStyler(this._userNameInputBox, this._themeService));
|
||||
this._toDispose.push(styler.attachInputBoxStyler(this._passwordInputBox, this._themeService));
|
||||
this._toDispose.push(styler.attachButtonStyler(this._advancedButton, this._themeService));
|
||||
this._toDispose.push(styler.attachCheckboxStyler(this._rememberPasswordCheckBox, this._themeService));
|
||||
this._toDispose.push(styler.attachSelectBoxStyler(this._azureAccountDropdown, this._themeService));
|
||||
this._register(styler.attachInputBoxStyler(this._serverNameInputBox, this._themeService));
|
||||
this._register(styler.attachInputBoxStyler(this._connectionNameInputBox, this._themeService));
|
||||
this._register(styler.attachInputBoxStyler(this._userNameInputBox, this._themeService));
|
||||
this._register(styler.attachInputBoxStyler(this._passwordInputBox, this._themeService));
|
||||
this._register(styler.attachButtonStyler(this._advancedButton, this._themeService));
|
||||
this._register(styler.attachCheckboxStyler(this._rememberPasswordCheckBox, this._themeService));
|
||||
this._register(styler.attachSelectBoxStyler(this._azureAccountDropdown, this._themeService));
|
||||
if (this._serverGroupSelectBox) {
|
||||
this._toDispose.push(styler.attachSelectBoxStyler(this._serverGroupSelectBox, this._themeService));
|
||||
this._toDispose.push(this._serverGroupSelectBox.onDidSelect(selectedGroup => {
|
||||
this._register(styler.attachSelectBoxStyler(this._serverGroupSelectBox, this._themeService));
|
||||
this._register(this._serverGroupSelectBox.onDidSelect(selectedGroup => {
|
||||
this.onGroupSelected(selectedGroup.selected);
|
||||
}));
|
||||
}
|
||||
if (this._databaseNameInputBox) {
|
||||
this._toDispose.push(styler.attachEditableDropdownStyler(this._databaseNameInputBox, this._themeService));
|
||||
this._toDispose.push(this._databaseNameInputBox.onFocus(() => {
|
||||
this._register(styler.attachEditableDropdownStyler(this._databaseNameInputBox, this._themeService));
|
||||
this._register(this._databaseNameInputBox.onFocus(() => {
|
||||
this._databaseDropdownExpanded = true;
|
||||
if (this.serverName) {
|
||||
this._databaseNameInputBox.values = [this._loadingDatabaseName];
|
||||
@@ -346,7 +345,7 @@ export class ConnectionWidget {
|
||||
}
|
||||
}));
|
||||
|
||||
this._toDispose.push(this._databaseNameInputBox.onValueChange(s => {
|
||||
this._register(this._databaseNameInputBox.onValueChange(s => {
|
||||
if (s === this._defaultDatabaseName || s === this._loadingDatabaseName) {
|
||||
this._databaseNameInputBox.value = '';
|
||||
} else {
|
||||
@@ -357,29 +356,29 @@ export class ConnectionWidget {
|
||||
|
||||
if (this._authTypeSelectBox) {
|
||||
// Theme styler
|
||||
this._toDispose.push(styler.attachSelectBoxStyler(this._authTypeSelectBox, this._themeService));
|
||||
this._toDispose.push(this._authTypeSelectBox.onDidSelect(selectedAuthType => {
|
||||
this._register(styler.attachSelectBoxStyler(this._authTypeSelectBox, this._themeService));
|
||||
this._register(this._authTypeSelectBox.onDidSelect(selectedAuthType => {
|
||||
this.onAuthTypeSelected(selectedAuthType.selected);
|
||||
this.setConnectButton();
|
||||
}));
|
||||
}
|
||||
|
||||
if (this._azureAccountDropdown) {
|
||||
this._toDispose.push(styler.attachSelectBoxStyler(this._azureAccountDropdown, this._themeService));
|
||||
this._toDispose.push(this._azureAccountDropdown.onDidSelect(() => {
|
||||
this._register(styler.attachSelectBoxStyler(this._azureAccountDropdown, this._themeService));
|
||||
this._register(this._azureAccountDropdown.onDidSelect(() => {
|
||||
this.onAzureAccountSelected();
|
||||
}));
|
||||
}
|
||||
|
||||
if (this._azureTenantDropdown) {
|
||||
this._toDispose.push(styler.attachSelectBoxStyler(this._azureTenantDropdown, this._themeService));
|
||||
this._toDispose.push(this._azureTenantDropdown.onDidSelect((selectInfo) => {
|
||||
this._register(styler.attachSelectBoxStyler(this._azureTenantDropdown, this._themeService));
|
||||
this._register(this._azureTenantDropdown.onDidSelect((selectInfo) => {
|
||||
this.onAzureTenantSelected(selectInfo.index);
|
||||
}));
|
||||
}
|
||||
|
||||
if (this._refreshCredentialsLink) {
|
||||
this._toDispose.push(DOM.addDisposableListener(this._refreshCredentialsLink, DOM.EventType.CLICK, async () => {
|
||||
this._register(DOM.addDisposableListener(this._refreshCredentialsLink, DOM.EventType.CLICK, async () => {
|
||||
let account = this._azureAccountList.find(account => account.key.accountId === this._azureAccountDropdown.value);
|
||||
if (account) {
|
||||
await this._accountManagementService.refreshAccount(account);
|
||||
@@ -388,15 +387,15 @@ export class ConnectionWidget {
|
||||
}));
|
||||
}
|
||||
|
||||
this._toDispose.push(this._serverNameInputBox.onDidChange(serverName => {
|
||||
this._register(this._serverNameInputBox.onDidChange(serverName => {
|
||||
this.serverNameChanged(serverName);
|
||||
}));
|
||||
|
||||
this._toDispose.push(this._userNameInputBox.onDidChange(userName => {
|
||||
this._register(this._userNameInputBox.onDidChange(userName => {
|
||||
this.setConnectButton();
|
||||
}));
|
||||
|
||||
this._toDispose.push(this._passwordInputBox.onDidChange(passwordInput => {
|
||||
this._register(this._passwordInputBox.onDidChange(passwordInput => {
|
||||
this._password = passwordInput;
|
||||
}));
|
||||
}
|
||||
@@ -835,10 +834,6 @@ export class ConnectionWidget {
|
||||
return group ? group.id : undefined;
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this._toDispose = lifecycle.dispose(this._toDispose);
|
||||
}
|
||||
|
||||
private getMatchingAuthType(displayName: string): AuthenticationType {
|
||||
const authType = this._authTypeMap[this._providerName];
|
||||
return authType ? authType.find(authType => this.getAuthTypeDisplayName(authType) === displayName) : undefined;
|
||||
|
||||
@@ -9,7 +9,7 @@ import { FileBrowserRenderer } from 'sql/workbench/services/fileBrowser/browser/
|
||||
import { IFileBrowserService } from 'sql/platform/fileBrowser/common/interfaces';
|
||||
import { FileNode } from 'sql/workbench/services/fileBrowser/common/fileNode';
|
||||
import errors = require('vs/base/common/errors');
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { IDisposable, dispose, Disposable } from 'vs/base/common/lifecycle';
|
||||
import * as DOM from 'vs/base/browser/dom';
|
||||
import nls = require('vs/nls');
|
||||
import { DefaultFilter, DefaultAccessibilityProvider, DefaultDragAndDrop } from 'vs/base/parts/tree/browser/treeDefaults';
|
||||
@@ -23,15 +23,15 @@ import { IExpandableTree } from 'sql/workbench/parts/objectExplorer/browser/tree
|
||||
/**
|
||||
* Implements tree view for file browser
|
||||
*/
|
||||
export class FileBrowserTreeView implements IDisposable {
|
||||
export class FileBrowserTreeView extends Disposable implements IDisposable {
|
||||
private _tree: ITree;
|
||||
private _toDispose: IDisposable[] = [];
|
||||
|
||||
constructor(
|
||||
@IInstantiationService private _instantiationService: IInstantiationService,
|
||||
@IFileBrowserService private _fileBrowserService: IFileBrowserService,
|
||||
@IThemeService private _themeService: IThemeService
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,10 +40,10 @@ export class FileBrowserTreeView implements IDisposable {
|
||||
public renderBody(container: HTMLElement, rootNode: FileNode, selectedNode: FileNode, expandedNodes: FileNode[]): void {
|
||||
if (!this._tree) {
|
||||
DOM.addClass(container, 'show-file-icons');
|
||||
this._tree = this.createFileBrowserTree(container, this._instantiationService);
|
||||
this._toDispose.push(this._tree.onDidChangeSelection((event) => this.onSelected(event)));
|
||||
this._toDispose.push(this._fileBrowserService.onExpandFolder(fileNode => this._tree.refresh(fileNode)));
|
||||
this._toDispose.push(attachListStyler(this._tree, this._themeService));
|
||||
this._tree = this._register(this.createFileBrowserTree(container, this._instantiationService));
|
||||
this._register(this._tree.onDidChangeSelection((event) => this.onSelected(event)));
|
||||
this._register(this._fileBrowserService.onExpandFolder(fileNode => this._tree.refresh(fileNode)));
|
||||
this._register(attachListStyler(this._tree, this._themeService));
|
||||
this._tree.domFocus();
|
||||
}
|
||||
|
||||
@@ -159,14 +159,4 @@ export class FileBrowserTreeView implements IDisposable {
|
||||
this._tree.onHidden();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* dispose the file browser tree view
|
||||
*/
|
||||
public dispose(): void {
|
||||
if (this._tree) {
|
||||
this._tree.dispose();
|
||||
}
|
||||
this._toDispose = dispose(this._toDispose);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
import { NodeType } from 'sql/workbench/parts/objectExplorer/common/nodeType';
|
||||
import { TreeNode, TreeItemCollapsibleState } from 'sql/workbench/parts/objectExplorer/common/treeNode';
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
@@ -130,8 +129,6 @@ export class ObjectExplorerService implements IObjectExplorerService {
|
||||
|
||||
public _serviceBrand: any;
|
||||
|
||||
private _disposables: IDisposable[] = [];
|
||||
|
||||
private _providers: { [handle: string]: azdata.ObjectExplorerProvider; } = Object.create(null);
|
||||
|
||||
private _nodeProviders: { [handle: string]: azdata.ObjectExplorerNodeProvider[]; } = Object.create(null);
|
||||
@@ -541,10 +538,6 @@ export class ObjectExplorerService implements IObjectExplorerService {
|
||||
this._nodeProviders[nodeProvider.supportedProviderId] = nodeProviders;
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this._disposables = dispose(this._disposables);
|
||||
}
|
||||
|
||||
public resolveTreeNodeChildren(session: azdata.ObjectExplorerSession, parentTree: TreeNode): Thenable<TreeNode[]> {
|
||||
// Always refresh the node if it has an error, otherwise expand it normally
|
||||
let needsRefresh = !!parentTree.errorStateMessage;
|
||||
|
||||
Reference in New Issue
Block a user