mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-21 01:25:37 -05:00
move the designer component to workbench layer (#17620)
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import 'vs/css!./media/tableDesignerEditor';
|
||||
import { Designer } from 'sql/base/browser/ui/designer/designer';
|
||||
import { Designer } from 'sql/workbench/browser/designer/designer';
|
||||
import { attachDesignerStyler } from 'sql/platform/theme/common/styler';
|
||||
import { TableDesignerInput } from 'sql/workbench/browser/editor/tableDesigner/tableDesignerInput';
|
||||
import * as DOM from 'vs/base/browser/dom';
|
||||
@@ -21,13 +21,11 @@ import { SaveTableChangesAction } from 'sql/workbench/contrib/tableDesigner/brow
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IColorTheme, ICssStyleCollector, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
|
||||
import { DesignerPaneSeparator } from 'sql/platform/theme/common/colorRegistry';
|
||||
import { TableDesignerTextEditor } from 'sql/workbench/contrib/tableDesigner/browser/tableDesignerTextEditor';
|
||||
|
||||
export class TableDesignerEditor extends EditorPane {
|
||||
public static readonly ID: string = 'workbench.editor.tableDesigner';
|
||||
|
||||
private _designer: Designer;
|
||||
private _designerTextEditor: TableDesignerTextEditor;
|
||||
private _saveChangesAction: SaveTableChangesAction;
|
||||
|
||||
constructor(
|
||||
@@ -62,10 +60,7 @@ export class TableDesignerEditor extends EditorPane {
|
||||
this._saveChangesAction.enabled = false;
|
||||
actionbar.push(this._saveChangesAction, { icon: true, label: false });
|
||||
|
||||
this._designer = new Designer(designerContainer, (editorContainer) => {
|
||||
this._designerTextEditor = this._instantiationService.createInstance(TableDesignerTextEditor, editorContainer);
|
||||
return this._designerTextEditor;
|
||||
}, this._contextViewService);
|
||||
this._designer = new Designer(designerContainer, this._instantiationService, this._contextViewService);
|
||||
this._register(attachDesignerStyler(this._designer, this.themeService));
|
||||
this._register(registerThemingParticipant((theme: IColorTheme, collector: ICssStyleCollector) => {
|
||||
const border = theme.getColor(DesignerPaneSeparator);
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { DesignerTextEditor } from 'sql/base/browser/ui/designer/interfaces';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { UntitledTextEditorInput } from 'vs/workbench/services/untitled/common/untitledTextEditorInput';
|
||||
import { UntitledTextEditorModel } from 'vs/workbench/services/untitled/common/untitledTextEditorModel';
|
||||
import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
|
||||
import * as nls from 'vs/nls';
|
||||
import * as DOM from 'vs/base/browser/dom';
|
||||
import { TextResourceEditorModel } from 'vs/workbench/common/editor/textResourceEditorModel';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import { BaseTextEditor } from 'vs/workbench/browser/parts/editor/textEditor';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { ITextResourceConfigurationService } from 'vs/editor/common/services/textResourceConfigurationService';
|
||||
import { IEditorOpenContext } from 'vs/workbench/common/editor';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget';
|
||||
import { ITextEditorOptions } from 'vs/platform/editor/common/editor';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
|
||||
class TableDesignerCodeEditor extends CodeEditorWidget {
|
||||
}
|
||||
|
||||
export class TableDesignerTextEditor extends BaseTextEditor implements DesignerTextEditor {
|
||||
private _content: string;
|
||||
private _contentChangeEventEmitter: Emitter<string> = new Emitter<string>();
|
||||
readonly onDidContentChange: Event<string> = this._contentChangeEventEmitter.event;
|
||||
|
||||
private _untitledTextEditorModel: UntitledTextEditorModel;
|
||||
private _editorInput: UntitledTextEditorInput;
|
||||
private _editorModel: ITextModel;
|
||||
|
||||
public static ID = 'designer.editors.textEditor';
|
||||
constructor(
|
||||
private _container: HTMLElement,
|
||||
@IModelService private _modelService: IModelService,
|
||||
@ITelemetryService telemetryService: ITelemetryService,
|
||||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
@IStorageService storageService: IStorageService,
|
||||
@ITextResourceConfigurationService configurationService: ITextResourceConfigurationService,
|
||||
@IThemeService themeService: IThemeService,
|
||||
@IEditorService editorService: IEditorService,
|
||||
@IEditorGroupsService editorGroupService: IEditorGroupsService
|
||||
) {
|
||||
super(TableDesignerTextEditor.ID, telemetryService, instantiationService, storageService, configurationService, themeService, editorService, editorGroupService);
|
||||
this.create(this._container);
|
||||
this.setVisible(true);
|
||||
this._untitledTextEditorModel = this.instantiationService.createInstance(UntitledTextEditorModel, URI.from({ scheme: Schemas.untitled }), false, undefined, 'sql', undefined);
|
||||
this._editorInput = this.instantiationService.createInstance(UntitledTextEditorInput, this._untitledTextEditorModel);
|
||||
this.setInput(this._editorInput, undefined, undefined).catch(onUnexpectedError);
|
||||
this._editorInput.resolve().then((model) => {
|
||||
this._editorModel = model.textEditorModel;
|
||||
});
|
||||
}
|
||||
|
||||
public override createEditorControl(parent: HTMLElement, configuration: IEditorOptions): editorCommon.IEditor {
|
||||
return this.instantiationService.createInstance(TableDesignerCodeEditor, parent, configuration, {});
|
||||
}
|
||||
|
||||
protected override getConfigurationOverrides(): IEditorOptions {
|
||||
const options = super.getConfigurationOverrides();
|
||||
options.readOnly = true;
|
||||
if (this.input) {
|
||||
options.inDiffEditor = false;
|
||||
options.scrollBeyondLastLine = false;
|
||||
options.folding = false;
|
||||
options.renderWhitespace = 'all';
|
||||
options.wordWrap = 'off';
|
||||
options.renderIndentGuides = false;
|
||||
options.rulers = [];
|
||||
options.glyphMargin = true;
|
||||
options.minimap = {
|
||||
enabled: true
|
||||
};
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
override async setInput(input: UntitledTextEditorInput, options: ITextEditorOptions, context: IEditorOpenContext): Promise<void> {
|
||||
await super.setInput(input, options, context, CancellationToken.None);
|
||||
const editorModel = await this.input.resolve() as TextResourceEditorModel;
|
||||
await editorModel.resolve();
|
||||
this.getControl().setModel(editorModel.textEditorModel);
|
||||
}
|
||||
|
||||
protected getAriaLabel(): string {
|
||||
return nls.localize('designer.textEditorAriaLabel', "Designer text editor.");
|
||||
}
|
||||
|
||||
public override layout(dimension: DOM.Dimension) {
|
||||
this.getControl().layout(dimension);
|
||||
}
|
||||
|
||||
get content(): string {
|
||||
return this._content;
|
||||
}
|
||||
|
||||
set content(val: string) {
|
||||
this._content = val;
|
||||
this._modelService.updateModel(this._editorModel, this._content);
|
||||
this._untitledTextEditorModel.setDirty(false);
|
||||
this.layout(new DOM.Dimension(this._container.clientWidth, this._container.clientHeight));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user