mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-15 18:46:36 -05:00
SQL Operations Studio Public Preview 1 (0.23) release source code
This commit is contained in:
36
src/sql/parts/tasks/common/tasks.contribution.ts
Normal file
36
src/sql/parts/tasks/common/tasks.contribution.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
|
||||
import { EditorDescriptor } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
import { IEditorRegistry, Extensions as EditorExtensions } from 'vs/workbench/common/editor';
|
||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { TaskDialogEditor } from 'sql/parts/tasks/dialog/taskDialogEditor';
|
||||
import { TaskDialogInput } from 'sql/parts/tasks/dialog/taskDialogInput';
|
||||
import { CreateLoginEditor } from 'sql/parts/admin/security/createLoginEditor';
|
||||
import { CreateLoginInput } from 'sql/parts/admin/security/createLoginInput';
|
||||
|
||||
// Task Dialog registration
|
||||
const taskDialogEditorDescriptor = new EditorDescriptor(
|
||||
TaskDialogEditor.ID,
|
||||
'Task Dialog',
|
||||
'sql/parts/tasks/dialog/taskDialogEditor',
|
||||
'TaskDialogEditor'
|
||||
);
|
||||
|
||||
// Create Login registration
|
||||
const createLoginEditorDescriptor = new EditorDescriptor(
|
||||
CreateLoginEditor.ID,
|
||||
'CreateLogin',
|
||||
'sql/parts/admin/security/createLoginEditor',
|
||||
'CreateLoginEditor'
|
||||
);
|
||||
|
||||
Registry.as<IEditorRegistry>(EditorExtensions.Editors)
|
||||
.registerEditor(createLoginEditorDescriptor, [new SyncDescriptor(CreateLoginInput)]);
|
||||
|
||||
Registry.as<IEditorRegistry>(EditorExtensions.Editors)
|
||||
.registerEditor(taskDialogEditorDescriptor, [new SyncDescriptor(TaskDialogInput)]);
|
||||
18
src/sql/parts/tasks/common/tasks.ts
Normal file
18
src/sql/parts/tasks/common/tasks.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { TaskDialogComponentParams } from 'sql/services/bootstrap/bootstrapParams';
|
||||
/**
|
||||
* Interface for task dialog component events
|
||||
*/
|
||||
export interface ITaskDialogComponent {
|
||||
onOk(): void;
|
||||
|
||||
onGenerateScript(): void;
|
||||
|
||||
onCancel(): void;
|
||||
|
||||
injectBootstapper(parameters: TaskDialogComponentParams ): void;
|
||||
}
|
||||
10
src/sql/parts/tasks/dialog/taskDialog.component.html
Normal file
10
src/sql/parts/tasks/dialog/taskDialog.component.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!--
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
-->
|
||||
|
||||
<div style="width: 100%; height: 100%">
|
||||
<router-outlet (activate)='onActivate($event)' (deactivate)='onDeactivate($event)'></router-outlet>
|
||||
</div>
|
||||
50
src/sql/parts/tasks/dialog/taskDialog.component.ts
Normal file
50
src/sql/parts/tasks/dialog/taskDialog.component.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService';
|
||||
import { ConnectionManagementInfo } from 'sql/parts/connection/common/connectionManagementInfo';
|
||||
import { ITaskDialogComponent } from 'sql/parts/tasks/common/tasks';
|
||||
import { TaskDialogComponentParams } from 'sql/services/bootstrap/bootstrapParams';
|
||||
import { ElementRef, Component, Inject, forwardRef } from '@angular/core';
|
||||
|
||||
export const TASKDIALOG_SELECTOR: string = 'taskdialog-component';
|
||||
|
||||
@Component({
|
||||
selector: TASKDIALOG_SELECTOR,
|
||||
templateUrl: decodeURI(require.toUrl('sql/parts/tasks/dialog/taskDialog.component.html')),
|
||||
})
|
||||
export class TaskDialogComponent {
|
||||
|
||||
private _currentComponent: ITaskDialogComponent;
|
||||
|
||||
private _parameters: TaskDialogComponentParams;
|
||||
|
||||
public ownerUri: string;
|
||||
|
||||
public connection: ConnectionManagementInfo;
|
||||
|
||||
constructor(
|
||||
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef,
|
||||
@Inject(BOOTSTRAP_SERVICE_ID) private _bootstrapService: IBootstrapService
|
||||
) {
|
||||
this._parameters = this._bootstrapService.getBootstrapParams(this._el.nativeElement.tagName);
|
||||
this.ownerUri = this._parameters.ownerUri;
|
||||
|
||||
}
|
||||
|
||||
public onActivate(component: any) {
|
||||
// validate the component implements ITaskDialogComponent (or at least part of the interface)
|
||||
if ((<ITaskDialogComponent>component).onOk) {
|
||||
this._currentComponent = <ITaskDialogComponent>component;
|
||||
this._currentComponent.injectBootstapper(this._parameters);
|
||||
} else {
|
||||
this._currentComponent = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
public onDeactivate(component: any) {
|
||||
|
||||
}
|
||||
}
|
||||
57
src/sql/parts/tasks/dialog/taskDialog.module.ts
Normal file
57
src/sql/parts/tasks/dialog/taskDialog.module.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
import { ApplicationRef, ComponentFactoryResolver, ModuleWithProviders, NgModule,
|
||||
Inject, forwardRef } from '@angular/core';
|
||||
import { APP_BASE_HREF, CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService';
|
||||
|
||||
import { TaskDialogComponent, TASKDIALOG_SELECTOR } from 'sql/parts/tasks/dialog/taskDialog.component';
|
||||
import { CreateDatabaseComponent } from 'sql/parts/admin/database/create/createDatabase.component';
|
||||
|
||||
// Setup routes for various child components
|
||||
const appRoutes: Routes = [
|
||||
{ path: 'create-database', component: CreateDatabaseComponent },
|
||||
{
|
||||
path: '',
|
||||
redirectTo: '/create-database',
|
||||
pathMatch: 'full'
|
||||
},
|
||||
{ path: '**', component: CreateDatabaseComponent }
|
||||
];
|
||||
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
TaskDialogComponent,
|
||||
CreateDatabaseComponent
|
||||
],
|
||||
entryComponents: [TaskDialogComponent],
|
||||
imports: [
|
||||
FormsModule,
|
||||
CommonModule,
|
||||
BrowserModule,
|
||||
<ModuleWithProviders>RouterModule.forRoot(appRoutes)
|
||||
],
|
||||
providers: [{ provide: APP_BASE_HREF, useValue: '/' }]
|
||||
})
|
||||
export class TaskDialogModule {
|
||||
|
||||
constructor(
|
||||
@Inject(forwardRef(() => ComponentFactoryResolver)) private _resolver: ComponentFactoryResolver,
|
||||
@Inject(BOOTSTRAP_SERVICE_ID) private _bootstrapService: IBootstrapService
|
||||
) {
|
||||
}
|
||||
|
||||
ngDoBootstrap(appRef: ApplicationRef) {
|
||||
const factory = this._resolver.resolveComponentFactory(TaskDialogComponent);
|
||||
const uniqueSelector: string = this._bootstrapService.getUniqueSelector(TASKDIALOG_SELECTOR);
|
||||
(<any>factory).factory.selector = uniqueSelector;
|
||||
appRef.bootstrap(factory);
|
||||
}
|
||||
}
|
||||
105
src/sql/parts/tasks/dialog/taskDialogEditor.ts
Normal file
105
src/sql/parts/tasks/dialog/taskDialogEditor.ts
Normal file
@@ -0,0 +1,105 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import 'vs/css!sql/parts/query/editor/media/queryEditor';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { Dimension, Builder } from 'vs/base/browser/builder';
|
||||
import { EditorOptions } from 'vs/workbench/common/editor';
|
||||
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { TaskDialogInput } from './taskDialogInput';
|
||||
import { IBootstrapService } from 'sql/services/bootstrap/bootstrapService';
|
||||
import { TaskDialogComponentParams } from 'sql/services/bootstrap/bootstrapParams';
|
||||
import { TaskDialogModule } from 'sql/parts/tasks/dialog/taskDialog.module';
|
||||
import { TASKDIALOG_SELECTOR } from 'sql/parts/tasks/dialog/taskDialog.component';
|
||||
|
||||
export class TaskDialogEditor extends BaseEditor {
|
||||
|
||||
public static ID: string = 'workbench.editor.taskdialog';
|
||||
|
||||
constructor(
|
||||
@ITelemetryService telemetryService: ITelemetryService,
|
||||
@IThemeService themeService: IThemeService,
|
||||
@IInstantiationService private instantiationService: IInstantiationService,
|
||||
@IBootstrapService private _bootstrapService: IBootstrapService
|
||||
) {
|
||||
super(TaskDialogEditor.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 {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
}
|
||||
|
||||
public setInput(input: TaskDialogInput, options: EditorOptions): TPromise<void> {
|
||||
if (this.input instanceof TaskDialogInput && this.input.matches(input)) {
|
||||
return TPromise.as(undefined);
|
||||
}
|
||||
|
||||
if (!input.hasInitialized) {
|
||||
this.bootstrapAngular(input);
|
||||
}
|
||||
this.revealElementWithTagName(input.uniqueSelector, this.getContainer().getHTMLElement());
|
||||
|
||||
return super.setInput(input, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reveal the child element with the given tagName and hide all other elements.
|
||||
*/
|
||||
private revealElementWithTagName(tagName: string, parent: HTMLElement): void {
|
||||
let elementToReveal: HTMLElement;
|
||||
|
||||
for(let i = 0; i < parent.children.length; i++) {
|
||||
let child: HTMLElement = <HTMLElement>parent.children[i];
|
||||
if (child.tagName && child.tagName.toLowerCase() === tagName && !elementToReveal) {
|
||||
elementToReveal = child;
|
||||
} else {
|
||||
child.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
if (elementToReveal) {
|
||||
elementToReveal.style.display = '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the angular components and record for this input that we have done so
|
||||
*/
|
||||
private bootstrapAngular(input: TaskDialogInput): void {
|
||||
|
||||
// Get the bootstrap params and perform the bootstrap
|
||||
let params: TaskDialogComponentParams = {
|
||||
ownerUri: input.getUri()
|
||||
};
|
||||
let uniqueSelector = this._bootstrapService.bootstrap(
|
||||
TaskDialogModule,
|
||||
this.getContainer().getHTMLElement(),
|
||||
TASKDIALOG_SELECTOR,
|
||||
params);
|
||||
input.setUniqueSelector(uniqueSelector);
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
57
src/sql/parts/tasks/dialog/taskDialogInput.ts
Normal file
57
src/sql/parts/tasks/dialog/taskDialogInput.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { EditorInput, EditorModel } from 'vs/workbench/common/editor';
|
||||
import { UntitledEditorInput } from 'vs/workbench/common/editor/untitledEditorInput';
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
|
||||
export class TaskDialogInput extends EditorInput {
|
||||
|
||||
public static ID: string = 'workbench.editorinputs.taskdialoginputs';
|
||||
public static SCHEMA: string = 'taskdialog';
|
||||
|
||||
private _uniqueSelector: string;
|
||||
|
||||
constructor(private _uri: string, private _connection: IConnectionProfile) {
|
||||
super();
|
||||
}
|
||||
|
||||
public setUniqueSelector(uniqueSelector: string): void {
|
||||
this._uniqueSelector = uniqueSelector;
|
||||
}
|
||||
|
||||
public getTypeId(): string {
|
||||
return UntitledEditorInput.ID;
|
||||
}
|
||||
|
||||
public getName(): string {
|
||||
return this._connection.serverName + ':' + this._connection.databaseName;
|
||||
}
|
||||
|
||||
public getUri(): string {
|
||||
return this._uri;
|
||||
}
|
||||
|
||||
public supportsSplitEditor(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
public getConnectionProfile(): IConnectionProfile {
|
||||
return this._connection;
|
||||
}
|
||||
|
||||
public resolve(refresh?: boolean): TPromise<EditorModel> {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public get hasInitialized(): boolean {
|
||||
return !!this._uniqueSelector;
|
||||
}
|
||||
|
||||
public get uniqueSelector(): string {
|
||||
return this._uniqueSelector;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user