Fix view model editor and webview component (#1483)

* destroy viewmodel when editor is closed and add example

* support retainContextWhenHidden option for webview component

* fix breaking change from master

* dispose html element during dispose

* add more comments
This commit is contained in:
Abbie Petchtes
2018-05-24 13:54:41 -07:00
committed by GitHub
parent 1359354387
commit c208abf0c5
11 changed files with 176 additions and 147 deletions

View File

@@ -6,12 +6,22 @@
import { TPromise } from 'vs/base/common/winjs.base';
import { IEditorModel } from 'vs/platform/editor/common/editor';
import { EditorInput } from 'vs/workbench/common/editor';
import * as DOM from 'vs/base/browser/dom';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { DialogPane } from 'sql/platform/dialog/dialogPane';
import * as sqlops from 'sqlops';
export class ModelViewInput extends EditorInput {
public static ID: string = 'workbench.editorinputs.ModelViewEditorInput';
private _container: HTMLElement;
private _dialogPane: DialogPane;
constructor(private _title: string, private _modelViewId: string) {
constructor(private _title: string, private _modelViewId: string,
private _options: sqlops.ModelViewEditorOptions,
@IInstantiationService private _instantiationService: IInstantiationService,
) {
super();
}
@@ -34,4 +44,32 @@ export class ModelViewInput extends EditorInput {
public getName(): string {
return this._title;
}
public get container(): HTMLElement {
if (!this._container && !this._dialogPane) {
this._container = DOM.$('div.model-view-container');
this._dialogPane = new DialogPane(this.title, this.modelViewId, () => undefined, this._instantiationService);
this._dialogPane.createBody(this._container);
}
return this._container;
}
public get dialogPane(): DialogPane {
return this._dialogPane;
}
public get options(): sqlops.ModelViewEditorOptions {
return this._options;
}
public dispose(): void {
if (this._dialogPane) {
this._dialogPane.dispose();
}
if (this._container) {
this._container.remove();
this._container = undefined;
}
super.dispose();
}
}