Add support for model view editor (#1442)

* Add proposed API for model view editors

* Initial working model view editor

* Add extension demo

* Revert "Add extension demo"

This reverts commit 10d3b720ad347919dd5668a339da8e96e26b2b82.

* view model editor and add the support for register content

* clean up the code

* fix editor issues where you register more than one content

* formating

* remove unused imports

* addressed comments

* address comments2

* address comment3
This commit is contained in:
Abbie Petchtes
2018-05-21 12:46:13 -07:00
committed by GitHub
parent ba264d8311
commit 70819252a9
14 changed files with 722 additions and 34 deletions

View File

@@ -0,0 +1,72 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Builder, $ } from 'vs/base/browser/builder';
import { TPromise } from 'vs/base/common/winjs.base';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
import { Dimension } from 'vs/workbench/services/part/common/partService';
import { EditorOptions } from 'vs/workbench/common/editor';
import * as DOM from 'vs/base/browser/dom';
import { ModelViewInput } from 'sql/parts/modelComponents/modelEditor/modelViewInput';
import { IBootstrapService } from 'sql/services/bootstrap/bootstrapService';
import { Dialog } from 'sql/platform/dialog/dialogTypes';
import { DialogPane } from 'sql/platform/dialog/dialogPane';
export class ModelViewEditor extends BaseEditor {
public static ID: string = 'workbench.editor.modelViewEditor';
private _modelViewMap = new Map<string, HTMLElement>();
constructor(
@ITelemetryService telemetryService: ITelemetryService,
@IThemeService themeService: IThemeService,
@IBootstrapService private _bootstrapService: IBootstrapService
) {
super(ModelViewEditor.ID, telemetryService, themeService);
}
/**
* Called to create the editor in the parent builder.
*/
public createEditor(parent: Builder): void {
}
/**
* Sets focus on this editor. Specifically, it sets the focus on the hosted text editor.
*/
public focus(): void {
}
public setInput(input: ModelViewInput, options?: EditorOptions): TPromise<void, any> {
if (this.input && this.input.matches(input)) {
return TPromise.as(undefined);
}
const parentElement = this.getContainer().getHTMLElement();
$(parentElement).clearChildren();
if (!this._modelViewMap.get(input.modelViewId)) {
let modelViewContainer = DOM.$('div.model-view-container');
let dialog = new Dialog(input.title, input.modelViewId);
let dialogPane = new DialogPane(dialog, this._bootstrapService);
dialogPane.createBody(modelViewContainer);
this._modelViewMap.set(input.modelViewId, modelViewContainer);
}
let element = this._modelViewMap.get(input.modelViewId);
DOM.append(parentElement, element);
return super.setInput(input, options);
}
/**
* Updates the internal variable keeping track of the editor's size, and re-calculates the sash position.
* To be called when the container of this editor changes size.
*/
public layout(dimension: Dimension): void {
}
}