Fix model view editor where switching between different type of editors remove the dom (#1546)

* fix model view editor where switching between different type of editors destroy the dom

* address comments
This commit is contained in:
Abbie Petchtes
2018-06-04 14:41:17 -07:00
committed by GitHub
parent f70bf590cd
commit e3baf5c443
3 changed files with 55 additions and 13 deletions

View File

@@ -8,6 +8,7 @@ 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 { IPartService, Parts } from 'vs/workbench/services/part/common/partService';
import { DialogPane } from 'sql/platform/dialog/dialogPane';
@@ -16,13 +17,19 @@ export class ModelViewInput extends EditorInput {
public static ID: string = 'workbench.editorinputs.ModelViewEditorInput';
private _container: HTMLElement;
private _dialogPaneContainer: HTMLElement;
private _dialogPane: DialogPane;
constructor(private _title: string, private _modelViewId: string,
private _options: sqlops.ModelViewEditorOptions,
@IInstantiationService private _instantiationService: IInstantiationService,
@IPartService private readonly _partService: IPartService
) {
super();
this._container = document.createElement('div');
this._container.id = `modelView-${_modelViewId}`;
this._partService.getContainer(Parts.EDITOR_PART).appendChild(this._container);
}
public get title(): string {
@@ -46,14 +53,30 @@ export class ModelViewInput extends EditorInput {
}
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 appendModelViewContainer(): void {
if (!this._dialogPane) {
this.createDialogPane();
}
if (!this._container.contains(this._dialogPaneContainer)) {
this._container.appendChild(this._dialogPaneContainer);
}
}
public removeModelViewContainer(): void {
if (this._dialogPaneContainer) {
this._container.removeChild(this._dialogPaneContainer);
}
}
private createDialogPane(): void {
this._dialogPaneContainer = DOM.$('div.model-view-container');
this._dialogPane = new DialogPane(this.title, this.modelViewId, () => undefined, this._instantiationService);
this._dialogPane.createBody(this._dialogPaneContainer);
}
public get dialogPane(): DialogPane {
return this._dialogPane;
}