mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-28 17:23:19 -05:00
initial PR for table designer feature (#17200)
* wip * wire up e2e * hook up styler and add as dataprotocal feature * designer child component rendering * table component updates * styler and selectbox column editor * fix editor size and dupe component creation issue * fix checkbox column and add more testing data * properties pane * only rerender when needed * properties pane update * update commands * cleanup for PR * revert unwanted changes * Adding a few tests for Add SQL binding (#17079) * initial changes * add a couple more tests * LEGO: check in for main to temporary branch. (#17089) * LEGO: check in for main to temporary branch. (#17091) Co-authored-by: kburtram <karlb@microsoft.com> * Adds autorest-based SQL Project generation to SQL Database Projects extension (#17078) * Initial changes * checkpoint * Constructing project with post deployment script * Correcting to intentionally read from cached list of projects * Adding activation event, fixing fresh workspace bug * Convert netcoreTool and autorestHelper to share a helper class for streamed command * Include npm package version to force update * test checkpoint * Unit tests * Added contextual quickpicks for autorest dialogs * Adding projectController test * Added projectController test, some refactoring for testability * Merge branch 'main' into benjin/autorest * Fixing 'which' import * PR feedback * Fixing tests * Adding additional information for when project provider tests fail * Hopefully fixing failing tests (unable to repro locally) * Adding Generate Project item to workspace menu * PR feedback * LEGO: check in for main to temporary branch. (#17097) * added sql database projects strings (#17100) * Set kernelAlias in startSession when isValidConnection is truthy (#17102) * PR follow-up comments (#17113) * Change recompare message after changing options to modal (#17103) * Change recompare message to modal * change options to yes and no * Remove commented code block in git extension (#17116) * Remove commented code block in git extension * Add SQL CARBON EDIT tag * [Loc] Small change to generatingProjectFailed (#17118) * Add Null Shortcut and added NULL text for default NULL value. (#17085) * added test key event * added null function to tryHandleKeyEvent * added null formatting * added working null insert. * added editDataGridPanel string null support * Bump nth-check from 2.0.0 to 2.0.1 in /build (#17115) Bumps [nth-check](https://github.com/fb55/nth-check) from 2.0.0 to 2.0.1. - [Release notes](https://github.com/fb55/nth-check/releases) - [Commits](https://github.com/fb55/nth-check/compare/v2.0.0...v2.0.1) --- updated-dependencies: - dependency-name: nth-check dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add excludeFlags to extenson marketplace query (#17121) * Add excludeFlags to extenson marketplace query * Remove dead code * Remove extraneous blank line * Address code review feedback * Adding Derived Columns to ADS Flatfile Import (#16795) * Adding derived column boilerplate * brandan preliminary frontend changes * empty commit * added new param * updating contracts, dialogue changes * utils changes, saving timeout attempt * pushing for aasim * Cleaning up code and fixing the issue in theory * changing button, did not solve independent scroll * Fixing the scroll bar issue * updating flat file service * adding override keyword to overrriden method * improving UI * pushing changes associated with resolved comments * localizing strings, editing comments * all comments resolved * Fixing a test * updating import package Updating azure MFA bug * Clearing navigation validator Fixing broken table name change * fixed prose test * removing unused code from tests * Fixed PR comments * Fixing some PR comments * WIP * Fixing transformation code and create derived column dialog styling * removing unused code * Adding comment for console log * fixed table styling * Adding some aria labels * Fixed some code cleanup issues * update import service Co-authored-by: Aasim Khan <aasimkhan30@gmail.com> Co-authored-by: bnhoule <t-bhoule@microsoft.com> * Change keybindings for copying query with Results (#17127) Co-authored-by: Monica Gupta <mogupt@microsoft.com> * sql proj - publish to docker improvements (#17124) * Add AAD token expiration handling for query runner (#17117) * Add AAD token refresh for notebook * move token refresh to query management and remove previous refresh calls * Add guids to RunAll and RunCell events (#17123) Add guids to RunAll and RunCell events * add error banner for failed migration cutover and cancel migration (#17106) * [Loc] update to sql migration, database projects and import extension strings (#17130) * Apply optional storage class settings in sql mi create command (#17129) * Make storage classes optional * Fix notebook to use storage class options Co-authored-by: Charmaine Chan <chachan@microsoft.com> * Add support for adding new setting in local.settings.json in add SQL binding quickpick (#17093) * be able to add new setting in local.settings.json * cleanup * addressing comments * remove todo comment * addressing comments * update some strings to uris * bump version of sqltoolsservice (#17133) * mark schema compare tests as unstable (#17140) * [Loc] Update for arc and sql-database-projects (#17148) * ML extension vbump (#17143) * Configure docker image and web smoke tests for ADSWeb. (#17136) * Adjusts timeout period * Revert "Adjusts timeout period" This reverts commit 0f372eae2a4611554093b6c09f1ff6c451132e19. * Adds firefox as browser option * Corrects yaml smoke test script * Resets args array to original values * Corrects build path * Resolves ignoring browser option error * continue even after writing to stderr * Adjusts smoke test (browser) script * More adjustments to smoke test script * Corrects server path * Uses build variable directly in build path * Specifies browser type since cannot be ignored error * Adds browser option * Updates web build image and corrects smoke test exe command * Removes commented out task * Updates dockerfile to support web smoketests * Removes failOnStderr flag * Use curl instead of wget in Dockerfile * Fixed a bug with cancling publish (#17160) * Save And Close Functionality (#17000) * save and close * wip * working save and close * cleanup * pr changes * pr changes * fix capitalization * fix build * pr fix * Added dynamic options for SQL MIAA Deployment Wizard and updated checkbox field (#17119) * Dynamic enablement * Added new package.json field for dynamic options and corresponding functions and classes. * Enabled dynamic options non-generalized and changed formatting of checkbox to have label on the left. * Added setOptions under InputComponentInfo for generalization, comments under checkbox component, and changed Replicas to High Availability to reflect parity in portal. * fix unit test Co-authored-by: Candice Ye <canye@microsoft.com> Co-authored-by: Alan Ren <alanren@microsoft.com> * LEGO: check in for main to temporary branch. (#17168) * [Loc] added new arc strings and fix for sql-database-projects lcl file for Japanese (#17171) * [Loc] added new arc strings and fix for sql-database-projects xlf * removed newline * Port of Vscode fix for colors too close (#17146) * default light colors list.focusHighlightForeground too close to list.activeSelectionBackground. Fixes #127597 * remove activeSelectionBackground from theme-carbon as it conflicts with vscode. * remove dark carbon background Co-authored-by: Martin Aeschlimann <martinae@microsoft.com> * Markdown Horizontal Scrollbar Fix (#17083) * dynamically change horizontal scrollbar * working horizontal scrollbar * created new event to handle both scrollbar and mouse wheel * only show scrollbar when needed * LEGO: check in for main to temporary branch. (#17181) * Bump axios to 0.21.4 (#17161) * Kusto version bump to 0.5.6 (#17114) * Bumped Kusto toolsservice version to 125 and bumped version to 0.5.6 * Changed netcoreapp3.1 to net5.0 in Kusto config.json * AzureMonitor bump ToolService version and extension version. (#17174) * Bump concat-with-sourcemaps from 1.0.4 to 1.1.0 (#17158) Bumps [concat-with-sourcemaps](https://github.com/floridoo/concat-with-sourcemaps) from 1.0.4 to 1.1.0. - [Release notes](https://github.com/floridoo/concat-with-sourcemaps/releases) - [Commits](https://github.com/floridoo/concat-with-sourcemaps/commits) --- updated-dependencies: - dependency-name: concat-with-sourcemaps dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Update service downloader to 0.2.3 (#17186) * Notebook Views grid fixes (#17170) * update data workspace restart ADS to open workspace message (#17188) * update message * update string * Add back "Remove Project" (#17178) * remove project working with full paths * use relative paths * const * addressing comments * Bump github-auth axios to 0.21.4 (#17189) * LEGO: check in for main to temporary branch. (#17192) * LEGO: check in for main to temporary branch. (#17190) Co-authored-by: kburtram <karlb@microsoft.com> * [Loc] Add a small change to dataworkspace (#17194) * added bump to sqltoolsservice version (#17195) * Check if file is dirty before adding sql binding (#17175) * check if file is dirty before adding sql binding * Addressing comments * Add vertical scroll bar to Preview in Split View (#17164) * reset max height * add editor height * set md editor height * Split up NotebookProvider into separate providers for handling file serialization and cell execution. (#17176) * fix floating promises * pr comments * reuse component definition * comments * fix error Co-authored-by: Kim Santiago <31145923+kisantia@users.noreply.github.com> Co-authored-by: csigs <csigs@users.noreply.github.com> Co-authored-by: kburtram <karlb@microsoft.com> Co-authored-by: Benjin Dubishar <benjin.dubishar@gmail.com> Co-authored-by: Alex Ma <alma1@microsoft.com> Co-authored-by: Justin M <63619224+JustinMDotNet@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: bnhoule <52506119+bnhoule@users.noreply.github.com> Co-authored-by: Aasim Khan <aasimkhan30@gmail.com> Co-authored-by: bnhoule <t-bhoule@microsoft.com> Co-authored-by: Monica Gupta <scorpio90m@gmail.com> Co-authored-by: Monica Gupta <mogupt@microsoft.com> Co-authored-by: Leila Lali <llali@microsoft.com> Co-authored-by: Hai Cao <hacao@microsoft.com> Co-authored-by: Daniel Grajeda <dagrajed@microsoft.com> Co-authored-by: brian-harris <61598682+brian-harris@users.noreply.github.com> Co-authored-by: Charmaine Chan <69230572+charmainewkchan@users.noreply.github.com> Co-authored-by: Charmaine Chan <chachan@microsoft.com> Co-authored-by: Lewis Sanchez <87730006+lewis-sanchez@users.noreply.github.com> Co-authored-by: Christopher Suh <chsuh@microsoft.com> Co-authored-by: Candice Ye <candiceye@berkeley.edu> Co-authored-by: Candice Ye <canye@microsoft.com> Co-authored-by: Martin Aeschlimann <martinae@microsoft.com> Co-authored-by: Vasu Bhog <vabhog@microsoft.com> Co-authored-by: Charles Gagnon <chgagnon@microsoft.com> Co-authored-by: Barbara Valdez <34872381+barbaravaldez@users.noreply.github.com> Co-authored-by: Cory Rivera <corivera@microsoft.com>
This commit is contained in:
@@ -30,6 +30,7 @@ import { IAssessmentService } from 'sql/workbench/services/assessment/common/int
|
||||
import { IDataGridProviderService } from 'sql/workbench/services/dataGridProvider/common/dataGridProviderService';
|
||||
import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry';
|
||||
import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys';
|
||||
import { ITableDesignerService } from 'sql/workbench/services/tableDesigner/common/interface';
|
||||
|
||||
/**
|
||||
* Main thread class for handling data protocol management registration.
|
||||
@@ -59,7 +60,8 @@ export class MainThreadDataProtocol extends Disposable implements MainThreadData
|
||||
@IFileBrowserService private _fileBrowserService: IFileBrowserService,
|
||||
@IAssessmentService private _assessmentService: IAssessmentService,
|
||||
@IDataGridProviderService private _dataGridProviderService: IDataGridProviderService,
|
||||
@IAdsTelemetryService private _telemetryService: IAdsTelemetryService
|
||||
@IAdsTelemetryService private _telemetryService: IAdsTelemetryService,
|
||||
@ITableDesignerService private _tableDesignerService: ITableDesignerService
|
||||
) {
|
||||
super();
|
||||
if (extHostContext) {
|
||||
@@ -507,6 +509,20 @@ export class MainThreadDataProtocol extends Disposable implements MainThreadData
|
||||
return undefined;
|
||||
}
|
||||
|
||||
$registerTableDesignerProvider(providerId: string, handle: number): Promise<any> {
|
||||
const self = this;
|
||||
this._tableDesignerService.registerProvider(providerId, <azdata.designers.TableDesignerProvider>{
|
||||
getTableDesignerInfo(tableInfo: azdata.designers.TableInfo): Thenable<azdata.designers.TableDesignerInfo> {
|
||||
return self._proxy.$getTableDesignerInfo(handle, tableInfo);
|
||||
},
|
||||
processTableEdit(table, data, edit): Thenable<azdata.designers.DesignerEditResult> {
|
||||
return self._proxy.$processTableDesignerEdit(handle, table, data, edit);
|
||||
}
|
||||
});
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public $registerSerializationProvider(providerId: string, handle: number): Promise<any> {
|
||||
const self = this;
|
||||
this._serializationService.registerProvider(providerId, <azdata.SerializationProvider>{
|
||||
@@ -616,6 +632,11 @@ export class MainThreadDataProtocol extends Disposable implements MainThreadData
|
||||
this._jobManagementService.fireOnDidChange();
|
||||
}
|
||||
|
||||
// Table Designer
|
||||
public $openTableDesigner(providerId: string, tableInfo: azdata.designers.TableInfo): void {
|
||||
this._tableDesignerService.openTableDesigner(providerId, tableInfo);
|
||||
}
|
||||
|
||||
public $unregisterProvider(handle: number): Promise<any> {
|
||||
let capabilitiesRegistration = this._capabilitiesRegistrations[handle];
|
||||
if (capabilitiesRegistration) {
|
||||
|
||||
@@ -194,6 +194,12 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
|
||||
return rt;
|
||||
}
|
||||
|
||||
$registerTableDesignerProvider(provider: azdata.designers.TableDesignerProvider): vscode.Disposable {
|
||||
let rt = this.registerProvider(provider, DataProviderType.TableDesignerProvider);
|
||||
this._proxy.$registerTableDesignerProvider(provider.providerId, provider.handle);
|
||||
return rt;
|
||||
}
|
||||
|
||||
// Capabilities Discovery handlers
|
||||
override $getServerCapabilities(handle: number, client: azdata.DataProtocolClientCapabilities): Thenable<azdata.DataProtocolServerCapabilities> {
|
||||
return this._resolveProvider<azdata.CapabilitiesProvider>(handle).getServerCapabilities(client);
|
||||
@@ -884,4 +890,18 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
|
||||
public override $getDataGridColumns(handle: number): Thenable<azdata.DataGridColumn[]> {
|
||||
return this._resolveProvider<azdata.DataGridProvider>(handle).getDataGridColumns();
|
||||
}
|
||||
|
||||
// Table Designer
|
||||
public override $getTableDesignerInfo(handle, table: azdata.designers.TableInfo): Thenable<azdata.designers.TableDesignerInfo> {
|
||||
return this._resolveProvider<azdata.designers.TableDesignerProvider>(handle).getTableDesignerInfo(table);
|
||||
}
|
||||
|
||||
public override $processTableDesignerEdit(handle, table: azdata.designers.TableInfo, data: azdata.designers.DesignerData, edit: azdata.designers.DesignerEdit): Thenable<azdata.designers.DesignerEditResult> {
|
||||
return this._resolveProvider<azdata.designers.TableDesignerProvider>(handle).processTableEdit(table, data, edit);
|
||||
}
|
||||
|
||||
public override $openTableDesigner(providerId: string, tableInfo: azdata.designers.TableInfo): Promise<void> {
|
||||
this._proxy.$openTableDesigner(providerId, tableInfo);
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -380,6 +380,10 @@ export function createAdsApiFactory(accessor: ServicesAccessor): IAdsExtensionAp
|
||||
return extHostDataProvider.$registerDataGridProvider(provider);
|
||||
};
|
||||
|
||||
let registerTableDesignerProvider = (provider: azdata.designers.TableDesignerProvider): vscode.Disposable => {
|
||||
return extHostDataProvider.$registerTableDesignerProvider(provider);
|
||||
};
|
||||
|
||||
// namespace: dataprotocol
|
||||
const dataprotocol: typeof azdata.dataprotocol = {
|
||||
registerBackupProvider,
|
||||
@@ -400,6 +404,7 @@ export function createAdsApiFactory(accessor: ServicesAccessor): IAdsExtensionAp
|
||||
registerSerializationProvider,
|
||||
registerSqlAssessmentServicesProvider,
|
||||
registerDataGridProvider,
|
||||
registerTableDesignerProvider,
|
||||
onDidChangeLanguageFlavor(listener: (e: azdata.DidChangeLanguageFlavorParams) => any, thisArgs?: any, disposables?: extHostTypes.Disposable[]) {
|
||||
return extHostDataProvider.onDidChangeLanguageFlavor(listener, thisArgs, disposables);
|
||||
},
|
||||
@@ -564,6 +569,15 @@ export function createAdsApiFactory(accessor: ServicesAccessor): IAdsExtensionAp
|
||||
SqlAssessmentTargetType: sqlExtHostTypes.SqlAssessmentTargetType
|
||||
};
|
||||
|
||||
const designers: typeof azdata.designers = {
|
||||
TableProperty: sqlExtHostTypes.designers.TableProperty,
|
||||
TableColumnProperty: sqlExtHostTypes.designers.TableColumnProperty,
|
||||
DesignerEditType: sqlExtHostTypes.designers.DesignerEditType,
|
||||
openTableDesigner(providerId, tableInfo: azdata.designers.TableInfo): Promise<void> {
|
||||
return extHostDataProvider.$openTableDesigner(providerId, tableInfo);
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
version: initData.version,
|
||||
accounts,
|
||||
@@ -614,7 +628,8 @@ export function createAdsApiFactory(accessor: ServicesAccessor): IAdsExtensionAp
|
||||
DatabaseEngineEdition: sqlExtHostTypes.DatabaseEngineEdition,
|
||||
TabOrientation: sqlExtHostTypes.TabOrientation,
|
||||
sqlAssessment,
|
||||
TextType: sqlExtHostTypes.TextType
|
||||
TextType: sqlExtHostTypes.TextType,
|
||||
designers: designers
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -526,6 +526,21 @@ export abstract class ExtHostDataProtocolShape {
|
||||
* Gets the list of columns for a data grid
|
||||
*/
|
||||
$getDataGridColumns(handle: number): Thenable<azdata.DataGridColumn[]> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Gets the table designer info for the specified table
|
||||
*/
|
||||
$getTableDesignerInfo(handle, table: azdata.designers.TableInfo): Thenable<azdata.designers.TableDesignerInfo> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Process the table edit.
|
||||
*/
|
||||
$processTableDesignerEdit(handle, table: azdata.designers.TableInfo, data: azdata.designers.DesignerData, edit: azdata.designers.DesignerEdit): Thenable<azdata.designers.DesignerEditResult> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Open a new instance of table designer.
|
||||
*/
|
||||
$openTableDesigner(providerId: string, tableInfo: azdata.designers.TableInfo, designerInfo: azdata.designers.TableDesignerInfo): void { throw ni(); }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -591,6 +606,7 @@ export interface MainThreadDataProtocolShape extends IDisposable {
|
||||
$registerSerializationProvider(providerId: string, handle: number): Promise<any>;
|
||||
$registerSqlAssessmentServicesProvider(providerId: string, handle: number): Promise<any>;
|
||||
$registerDataGridProvider(providerId: string, title: string, handle: number): void;
|
||||
$registerTableDesignerProvider(providerId: string, handle: number): Promise<any>;
|
||||
$unregisterProvider(handle: number): Promise<any>;
|
||||
$onConnectionComplete(handle: number, connectionInfoSummary: azdata.ConnectionInfoSummary): void;
|
||||
$onIntelliSenseCacheComplete(handle: number, connectionUri: string): void;
|
||||
@@ -614,6 +630,7 @@ export interface MainThreadDataProtocolShape extends IDisposable {
|
||||
$onSessionStopped(handle: number, response: azdata.ProfilerSessionStoppedParams): void;
|
||||
$onProfilerSessionCreated(handle: number, response: azdata.ProfilerSessionCreatedParams): void;
|
||||
$onJobDataUpdated(handle: Number): void;
|
||||
$openTableDesigner(providerId: string, tableInfo: azdata.designers.TableInfo): void;
|
||||
|
||||
/**
|
||||
* Callback when a session has completed initialization
|
||||
|
||||
@@ -381,7 +381,8 @@ export enum DataProviderType {
|
||||
SerializationProvider = 'SerializationProvider',
|
||||
IconProvider = 'IconProvider',
|
||||
SqlAssessmentServicesProvider = 'SqlAssessmentServicesProvider',
|
||||
DataGridProvider = 'DataGridProvider'
|
||||
DataGridProvider = 'DataGridProvider',
|
||||
TableDesignerProvider = 'TableDesignerProvider'
|
||||
}
|
||||
|
||||
export enum DeclarativeDataType {
|
||||
@@ -905,3 +906,27 @@ export enum TextType {
|
||||
UnorderedList = 'UnorderedList',
|
||||
OrderedList = 'OrderedList'
|
||||
}
|
||||
|
||||
export namespace designers {
|
||||
export enum TableProperty {
|
||||
Schema = 'schema',
|
||||
Name = 'name',
|
||||
Description = 'description',
|
||||
Columns = 'columns',
|
||||
Script = 'script'
|
||||
}
|
||||
|
||||
export enum TableColumnProperty {
|
||||
Name = 'name',
|
||||
Type = 'type',
|
||||
AllowNulls = 'allowNulls',
|
||||
DefaultValue = 'defaultValue',
|
||||
Length = 'length'
|
||||
}
|
||||
|
||||
export enum DesignerEditType {
|
||||
Add = 0,
|
||||
Remove = 1,
|
||||
Update = 2
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { localize } from 'vs/nls';
|
||||
import { EditorInput } from 'vs/workbench/common/editor/editorInput';
|
||||
import { URI } from 'vs/workbench/workbench.web.api';
|
||||
import { TableDesignerComponentInput } from 'sql/workbench/services/tableDesigner/browser/tableDesignerComponentInput';
|
||||
import { TableDesignerProvider } from 'sql/workbench/services/tableDesigner/common/interface';
|
||||
import * as azdata from 'azdata';
|
||||
|
||||
const NewTable: string = localize('tableDesigner.newTable', "New Table");
|
||||
|
||||
export class TableDesignerInput extends EditorInput {
|
||||
public static ID: string = 'workbench.editorinputs.tableDesignerInput';
|
||||
private _designerComponentInput: TableDesignerComponentInput;
|
||||
constructor(provider: TableDesignerProvider,
|
||||
private _tableInfo: azdata.designers.TableInfo) {
|
||||
super();
|
||||
this._designerComponentInput = new TableDesignerComponentInput(provider, this._tableInfo);
|
||||
}
|
||||
|
||||
get typeId(): string {
|
||||
return TableDesignerInput.ID;
|
||||
}
|
||||
|
||||
get resource(): URI {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public getComponentInput(): TableDesignerComponentInput {
|
||||
return this._designerComponentInput;
|
||||
}
|
||||
|
||||
override getName(): string {
|
||||
const tableName = this._tableInfo.isNewTable ? NewTable : `${this._tableInfo.schema}.${this._tableInfo.name}`;
|
||||
return `${this._tableInfo.server}.${this._tableInfo.database} - ${tableName}`;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { TableDesignerInput } from 'sql/workbench/browser/editor/tableDesigner/tableDesignerInput';
|
||||
import { TableDesignerEditor } from 'sql/workbench/contrib/tableDesigner/browser/tableDesignerEditor';
|
||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { EditorDescriptor, IEditorRegistry } from 'vs/workbench/browser/editor';
|
||||
import { EditorExtensions } from 'vs/workbench/common/editor';
|
||||
|
||||
const tableDesignerDescriptor = EditorDescriptor.create(
|
||||
TableDesignerEditor,
|
||||
TableDesignerEditor.ID,
|
||||
'TableDesignerEditor'
|
||||
);
|
||||
|
||||
Registry.as<IEditorRegistry>(EditorExtensions.Editors)
|
||||
.registerEditor(tableDesignerDescriptor, [new SyncDescriptor(TableDesignerInput)]);
|
||||
@@ -0,0 +1,51 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Designer } from 'sql/base/browser/ui/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';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { IEditorOptions } from 'vs/platform/editor/common/editor';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { EditorPane } from 'vs/workbench/browser/parts/editor/editorPane';
|
||||
import { IEditorOpenContext } from 'vs/workbench/common/editor';
|
||||
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
|
||||
|
||||
export class TableDesignerEditor extends EditorPane {
|
||||
public static readonly ID: string = 'workbench.editor.tableDesigner';
|
||||
|
||||
private _designer: Designer;
|
||||
|
||||
constructor(
|
||||
@ITelemetryService telemetryService: ITelemetryService,
|
||||
@IWorkbenchThemeService themeService: IWorkbenchThemeService,
|
||||
@IStorageService storageService: IStorageService,
|
||||
@IContextViewService private _contextViewService: IContextViewService
|
||||
) {
|
||||
super(TableDesignerEditor.ID, telemetryService, themeService, storageService);
|
||||
}
|
||||
|
||||
public override get input(): TableDesignerInput | undefined {
|
||||
return this._input as TableDesignerInput;
|
||||
}
|
||||
|
||||
override async setInput(input: TableDesignerInput, options: IEditorOptions | undefined, context: IEditorOpenContext, token: CancellationToken): Promise<void> {
|
||||
await super.setInput(input, options, context, token);
|
||||
this._designer.setInput(input.getComponentInput());
|
||||
}
|
||||
|
||||
protected createEditor(parent: HTMLElement): void {
|
||||
// The editor is only created once per editor group.
|
||||
this._designer = new Designer(parent, this._contextViewService);
|
||||
this._register(attachDesignerStyler(this._designer, this.themeService));
|
||||
}
|
||||
|
||||
layout(dimension: DOM.Dimension): void {
|
||||
this._designer.layout(dimension);
|
||||
}
|
||||
}
|
||||
@@ -13,12 +13,14 @@ export class TreeNodeContextKey implements IContextKey<TreeNode> {
|
||||
static Status = new RawContextKey<string>('nodeStatus', undefined);
|
||||
static TreeNode = new RawContextKey<TreeNode>('treeNode', undefined);
|
||||
static NodeLabel = new RawContextKey<string>('nodeLabel', undefined);
|
||||
static NodePath = new RawContextKey<string>('nodePath', undefined);
|
||||
|
||||
private _nodeTypeKey: IContextKey<string>;
|
||||
private _subTypeKey: IContextKey<string>;
|
||||
private _statusKey: IContextKey<string>;
|
||||
private _treeNodeKey: IContextKey<TreeNode>;
|
||||
private _nodeLabelKey: IContextKey<string>;
|
||||
private _nodePathKey: IContextKey<string>;
|
||||
|
||||
constructor(
|
||||
@IContextKeyService contextKeyService: IContextKeyService
|
||||
@@ -28,6 +30,7 @@ export class TreeNodeContextKey implements IContextKey<TreeNode> {
|
||||
this._statusKey = TreeNodeContextKey.Status.bindTo(contextKeyService);
|
||||
this._treeNodeKey = TreeNodeContextKey.TreeNode.bindTo(contextKeyService);
|
||||
this._nodeLabelKey = TreeNodeContextKey.NodeLabel.bindTo(contextKeyService);
|
||||
this._nodePathKey = TreeNodeContextKey.NodePath.bindTo(contextKeyService);
|
||||
}
|
||||
|
||||
set(value: TreeNode) {
|
||||
@@ -38,6 +41,7 @@ export class TreeNodeContextKey implements IContextKey<TreeNode> {
|
||||
this._statusKey.set(value && value.nodeStatus);
|
||||
}
|
||||
this._nodeLabelKey.set(value && value.label);
|
||||
this._nodePathKey.set(value && value.nodePath);
|
||||
}
|
||||
|
||||
reset(): void {
|
||||
@@ -46,6 +50,7 @@ export class TreeNodeContextKey implements IContextKey<TreeNode> {
|
||||
this._statusKey.reset();
|
||||
this._treeNodeKey.reset();
|
||||
this._nodeLabelKey.reset();
|
||||
this._nodePathKey.reset();
|
||||
}
|
||||
|
||||
public get(): TreeNode | undefined {
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import { DesignerData, DesignerEdit, DesignerEditResult, DesignerComponentInput, DesignerView, DesignerTab, DesignerDataPropertyInfo, DropDownProperties, DesignerTableProperties } from 'sql/base/browser/ui/designer/interfaces';
|
||||
import { TableDesignerProvider } from 'sql/workbench/services/tableDesigner/common/interface';
|
||||
import { localize } from 'vs/nls';
|
||||
import { designers } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
|
||||
export class TableDesignerComponentInput implements DesignerComponentInput {
|
||||
|
||||
private _data: DesignerData;
|
||||
private _view: DesignerView;
|
||||
|
||||
constructor(private readonly _provider: TableDesignerProvider,
|
||||
private _tableInfo: azdata.designers.TableInfo) {
|
||||
}
|
||||
|
||||
get objectTypeDisplayName(): string {
|
||||
return localize('tableDesigner.tableObjectType', "Table");
|
||||
}
|
||||
|
||||
async getView(): Promise<DesignerView> {
|
||||
if (!this._view) {
|
||||
await this.initialize();
|
||||
}
|
||||
return this._view;
|
||||
}
|
||||
|
||||
async getData(): Promise<DesignerData> {
|
||||
if (!this._data) {
|
||||
await this.initialize();
|
||||
}
|
||||
return this._data;
|
||||
}
|
||||
|
||||
async processEdit(edit: DesignerEdit): Promise<DesignerEditResult> {
|
||||
const result = await this._provider.processTableEdit(this._tableInfo, this._data!, edit);
|
||||
if (result.isValid) {
|
||||
this._data = result.data;
|
||||
}
|
||||
return {
|
||||
isValid: result.isValid,
|
||||
errors: result.errors
|
||||
};
|
||||
}
|
||||
|
||||
private async initialize(): Promise<void> {
|
||||
const designerInfo = await this._provider.getTableDesignerInfo(this._tableInfo);
|
||||
|
||||
this._data = designerInfo.data;
|
||||
this.setDefaultData();
|
||||
|
||||
const advancedTabComponents: DesignerDataPropertyInfo[] = [
|
||||
{
|
||||
componentType: 'dropdown',
|
||||
propertyName: designers.TableProperty.Schema,
|
||||
componentProperties: <DropDownProperties>{
|
||||
title: localize('tableDesigner.schemaTitle', "Schema"),
|
||||
values: designerInfo.schemas
|
||||
}
|
||||
}, {
|
||||
componentType: 'input',
|
||||
propertyName: designers.TableProperty.Description,
|
||||
componentProperties: {
|
||||
title: localize('tableDesigner.descriptionTitle', "Description")
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
if (designerInfo.view.additionalTableProperties) {
|
||||
advancedTabComponents.push(...designerInfo.view.additionalTableProperties);
|
||||
}
|
||||
|
||||
const advancedTab = <DesignerTab>{
|
||||
title: localize('tableDesigner.advancedTab', "Advanced"),
|
||||
components: advancedTabComponents
|
||||
};
|
||||
|
||||
const columnProperties: DesignerDataPropertyInfo[] = [
|
||||
{
|
||||
componentType: 'input',
|
||||
propertyName: designers.TableColumnProperty.Name,
|
||||
componentProperties: {
|
||||
title: localize('tableDesigner.columnNameTitle', "Name"),
|
||||
width: 150
|
||||
}
|
||||
}, {
|
||||
componentType: 'dropdown',
|
||||
propertyName: designers.TableColumnProperty.Type,
|
||||
componentProperties: {
|
||||
title: localize('tableDesigner.columnTypeTitle', "Type"),
|
||||
width: 100,
|
||||
values: designerInfo.columnTypes
|
||||
}
|
||||
}, {
|
||||
componentType: 'input',
|
||||
propertyName: designers.TableColumnProperty.Length,
|
||||
componentProperties: {
|
||||
title: localize('tableDesigner.columnLengthTitle', "Length"),
|
||||
width: 75
|
||||
}
|
||||
}, {
|
||||
componentType: 'input',
|
||||
propertyName: designers.TableColumnProperty.DefaultValue,
|
||||
componentProperties: {
|
||||
title: localize('tableDesigner.columnDefaultValueTitle', "Default Value"),
|
||||
width: 150
|
||||
}
|
||||
}, {
|
||||
componentType: 'checkbox',
|
||||
propertyName: designers.TableColumnProperty.AllowNulls,
|
||||
componentProperties: {
|
||||
title: localize('tableDesigner.columnAllowNullTitle', "Allow Nulls"),
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
if (designerInfo.view.addtionalTableColumnProperties) {
|
||||
columnProperties.push(...designerInfo.view.addtionalTableColumnProperties);
|
||||
}
|
||||
|
||||
const columnsTab = <DesignerTab>{
|
||||
title: localize('tableDesigner.columnsTabTitle', "Columns"),
|
||||
components: [
|
||||
{
|
||||
componentType: 'table',
|
||||
propertyName: designers.TableProperty.Columns,
|
||||
componentProperties: <DesignerTableProperties>{
|
||||
ariaLabel: localize('tableDesigner.columnsTabTitle', "Columns"),
|
||||
columns: [
|
||||
designers.TableColumnProperty.Name,
|
||||
designers.TableColumnProperty.Type,
|
||||
designers.TableColumnProperty.Length,
|
||||
designers.TableColumnProperty.DefaultValue,
|
||||
designers.TableColumnProperty.AllowNulls
|
||||
],
|
||||
itemProperties: columnProperties,
|
||||
objectTypeDisplayName: localize('tableDesigner.columnTypeName', "Column")
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
const tabs = [columnsTab, advancedTab];
|
||||
if (designerInfo.view.addtionalTabs) {
|
||||
tabs.push(...tabs);
|
||||
}
|
||||
|
||||
this._view = {
|
||||
components: [{
|
||||
componentType: 'input',
|
||||
propertyName: designers.TableColumnProperty.Name,
|
||||
componentProperties: {
|
||||
title: localize('tableDesigner.nameTitle', "Table name"),
|
||||
width: 200
|
||||
}
|
||||
}],
|
||||
tabs: tabs
|
||||
};
|
||||
}
|
||||
|
||||
private setDefaultData(): void {
|
||||
const properties = Object.keys(this._data);
|
||||
this.setDefaultInputData(properties, designers.TableProperty.Name);
|
||||
this.setDefaultInputData(properties, designers.TableProperty.Schema);
|
||||
this.setDefaultInputData(properties, designers.TableProperty.Description);
|
||||
}
|
||||
|
||||
private setDefaultInputData(allProperties: string[], property: string): void {
|
||||
if (allProperties.indexOf(property) === -1) {
|
||||
this._data[property] = {};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { TableDesignerProvider, ITableDesignerService } from 'sql/workbench/services/tableDesigner/common/interface';
|
||||
import { invalidProvider } from 'sql/base/common/errors';
|
||||
import * as azdata from 'azdata';
|
||||
import { ACTIVE_GROUP, IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { TableDesignerInput } from 'sql/workbench/browser/editor/tableDesigner/tableDesignerInput';
|
||||
|
||||
export class TableDesignerService implements ITableDesignerService {
|
||||
|
||||
constructor(@IEditorService private _editorService: IEditorService) { }
|
||||
|
||||
public _serviceBrand: undefined;
|
||||
private _providers = new Map<string, TableDesignerProvider>();
|
||||
|
||||
/**
|
||||
* Register a data grid provider
|
||||
*/
|
||||
public registerProvider(providerId: string, provider: TableDesignerProvider): void {
|
||||
if (this._providers.has(providerId)) {
|
||||
throw new Error(`A table designer provider with id "${providerId}" is already registered`);
|
||||
}
|
||||
this._providers.set(providerId, provider);
|
||||
}
|
||||
|
||||
public unregisterProvider(providerId: string): void {
|
||||
this._providers.delete(providerId);
|
||||
}
|
||||
|
||||
public getProvider(providerId: string): TableDesignerProvider {
|
||||
const provider = this._providers.get(providerId);
|
||||
if (provider) {
|
||||
return provider;
|
||||
}
|
||||
throw invalidProvider(providerId);
|
||||
}
|
||||
|
||||
public async openTableDesigner(providerId: string, tableInfo: azdata.designers.TableInfo): Promise<void> {
|
||||
const provider = this.getProvider(providerId);
|
||||
const tableDesignerInput = new TableDesignerInput(provider, tableInfo);
|
||||
await this._editorService.openEditor(tableDesignerInput, { pinned: true }, ACTIVE_GROUP);
|
||||
}
|
||||
}
|
||||
40
src/sql/workbench/services/tableDesigner/common/interface.ts
Normal file
40
src/sql/workbench/services/tableDesigner/common/interface.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
|
||||
export const SERVICE_ID = 'tableDesignerService';
|
||||
export const ITableDesignerService = createDecorator<ITableDesignerService>(SERVICE_ID);
|
||||
|
||||
export interface TableDesignerProvider extends azdata.designers.TableDesignerProvider { }
|
||||
|
||||
export interface ITableDesignerService {
|
||||
_serviceBrand: undefined;
|
||||
|
||||
/**
|
||||
* Register a table designer provider
|
||||
*/
|
||||
registerProvider(providerId: string, provider: TableDesignerProvider): void;
|
||||
|
||||
/**
|
||||
* Unregister a table designer provider
|
||||
*/
|
||||
unregisterProvider(providerId: string): void;
|
||||
|
||||
/**
|
||||
* Gets a registered table designer provider, throwing if none are registered with the specified ID
|
||||
* @param providerId The id of the registered provider
|
||||
*/
|
||||
getProvider(providerId: string): TableDesignerProvider;
|
||||
|
||||
/**
|
||||
* Open a table designer for the given table
|
||||
* @param providerId The provider id
|
||||
* @param tableInfo The table information
|
||||
*/
|
||||
openTableDesigner(providerId: string, tableInfo: azdata.designers.TableInfo): Promise<void>;
|
||||
}
|
||||
Reference in New Issue
Block a user