mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-20 01:25:37 -05:00
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:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user