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:
Anthony Dresser
2019-09-13 12:28:33 -07:00
committed by GitHub
parent c9128d56c0
commit d9c5b7ea9e
12 changed files with 86 additions and 144 deletions

View File

@@ -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);
}