SQL Operations Studio Public Preview 1 (0.23) release source code

This commit is contained in:
Karl Burtram
2017-11-09 14:30:27 -08:00
parent b88ecb8d93
commit 3cdac41339
8829 changed files with 759707 additions and 286 deletions

View File

@@ -0,0 +1,8 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
.context-view .monaco-menu {
min-width: 130px;
}

View File

@@ -0,0 +1,148 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import 'vs/css!./contextMenuHandler';
import { $, Builder } from 'vs/base/browser/builder';
import { combinedDisposable, IDisposable } from 'vs/base/common/lifecycle';
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
import { IActionRunner, ActionRunner, IAction } from 'vs/base/common/actions';
import { Menu } from 'vs/base/browser/ui/menu/menu';
import { EventType } from 'vs/base/common/events';
import Severity from 'vs/base/common/severity';
import { IContextViewService, IContextMenuDelegate } from 'vs/platform/contextview/browser/contextView';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IMessageService } from 'vs/platform/message/common/message';
export class ContextMenuHandler {
private contextViewService: IContextViewService;
private messageService: IMessageService;
private telemetryService: ITelemetryService;
private actionRunner: IActionRunner;
private $el: Builder;
private menuContainerElement: HTMLElement;
private toDispose: IDisposable[];
constructor(element: HTMLElement, contextViewService: IContextViewService, telemetryService: ITelemetryService, messageService: IMessageService) {
this.setContainer(element);
this.contextViewService = contextViewService;
this.telemetryService = telemetryService;
this.messageService = messageService;
this.actionRunner = new ActionRunner();
this.menuContainerElement = null;
this.toDispose = [];
let hideViewOnRun = false;
this.toDispose.push(this.actionRunner.addListener(EventType.BEFORE_RUN, (e: any) => {
if (this.telemetryService) {
this.telemetryService.publicLog('workbenchActionExecuted', { id: e.action.id, from: 'contextMenu' });
}
hideViewOnRun = !!e.retainActionItem;
if (!hideViewOnRun) {
this.contextViewService.hideContextView(false);
}
}));
this.toDispose.push(this.actionRunner.addListener(EventType.RUN, (e: any) => {
if (hideViewOnRun) {
this.contextViewService.hideContextView(false);
}
hideViewOnRun = false;
if (e.error && this.messageService) {
this.messageService.show(Severity.Error, e.error);
}
}));
}
public setContainer(container: HTMLElement): void {
if (this.$el) {
this.$el.off(['click', 'mousedown']);
this.$el = null;
}
if (container) {
this.$el = $(container);
this.$el.on('mousedown', (e: MouseEvent) => this.onMouseDown(e));
}
}
public showContextMenu(delegate: IContextMenuDelegate): void {
delegate.getActions().done((actions: IAction[]) => {
this.contextViewService.showContextView({
getAnchor: () => delegate.getAnchor(),
canRelayout: false,
render: (container) => {
this.menuContainerElement = container;
let className = delegate.getMenuClassName ? delegate.getMenuClassName() : '';
if (className) {
container.className += ' ' + className;
}
let menu = new Menu(container, actions, {
actionItemProvider: delegate.getActionItem,
context: delegate.getActionsContext ? delegate.getActionsContext() : null,
actionRunner: this.actionRunner
});
let listener1 = menu.addListener(EventType.CANCEL, (e: any) => {
this.contextViewService.hideContextView(true);
});
let listener2 = menu.addListener(EventType.BLUR, (e: any) => {
this.contextViewService.hideContextView(true);
});
menu.focus();
return combinedDisposable([listener1, listener2, menu]);
},
onHide: (didCancel?: boolean) => {
if (delegate.onHide) {
delegate.onHide(didCancel);
}
this.menuContainerElement = null;
}
});
});
}
private onMouseDown(e: MouseEvent): void {
if (!this.menuContainerElement) {
return;
}
let event = new StandardMouseEvent(e);
let element = event.target;
while (element) {
if (element === this.menuContainerElement) {
return;
}
element = element.parentElement;
}
this.contextViewService.hideContextView();
}
public dispose(): void {
this.setContainer(null);
}
}

View File

@@ -0,0 +1,34 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import { ContextMenuHandler } from './contextMenuHandler';
import { IContextViewService, IContextMenuService, IContextMenuDelegate } from './contextView';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IMessageService } from 'vs/platform/message/common/message';
export class ContextMenuService implements IContextMenuService {
public _serviceBrand: any;
private contextMenuHandler: ContextMenuHandler;
constructor(container: HTMLElement, telemetryService: ITelemetryService, messageService: IMessageService, contextViewService: IContextViewService) {
this.contextMenuHandler = new ContextMenuHandler(container, contextViewService, telemetryService, messageService);
}
public dispose(): void {
this.contextMenuHandler.dispose();
}
public setContainer(container: HTMLElement): void {
this.contextMenuHandler.setContainer(container);
}
// ContextMenu
public showContextMenu(delegate: IContextMenuDelegate): void {
this.contextMenuHandler.showContextMenu(delegate);
}
}

View File

@@ -0,0 +1,60 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import { IDisposable } from 'vs/base/common/lifecycle';
import { IAction, IActionRunner, Action } from 'vs/base/common/actions';
import { IActionItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { TPromise } from 'vs/base/common/winjs.base';
import { ResolvedKeybinding } from 'vs/base/common/keyCodes';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
export const IContextViewService = createDecorator<IContextViewService>('contextViewService');
export interface IContextViewService {
_serviceBrand: any;
showContextView(delegate: IContextViewDelegate): void;
hideContextView(data?: any): void;
layout(): void;
}
export interface IContextViewDelegate {
getAnchor(): HTMLElement | { x: number; y: number; };
render(container: HTMLElement): IDisposable;
canRelayout?: boolean; // Default: true
onDOMEvent?(e: Event, activeElement: HTMLElement): void;
onHide?(data?: any): void;
}
export const IContextMenuService = createDecorator<IContextMenuService>('contextMenuService');
export interface IContextMenuService {
_serviceBrand: any;
showContextMenu(delegate: IContextMenuDelegate): void;
}
export interface IEvent {
shiftKey?: boolean;
ctrlKey?: boolean;
altKey?: boolean;
metaKey?: boolean;
}
export interface IContextMenuDelegate {
getAnchor(): HTMLElement | { x: number; y: number; };
getActions(): TPromise<(IAction | ContextSubMenu)[]>;
getActionItem?(action: IAction): IActionItem;
getActionsContext?(event?: IEvent): any;
getKeyBinding?(action: IAction): ResolvedKeybinding;
getMenuClassName?(): string;
onHide?(didCancel: boolean): void;
actionRunner?: IActionRunner;
}
export class ContextSubMenu extends Action {
constructor(label: string, public entries: (ContextSubMenu | IAction)[]) {
super('contextsubmenu', label, '', true);
}
}

View File

@@ -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.
*--------------------------------------------------------------------------------------------*/
'use strict';
import { IContextViewService, IContextViewDelegate } from './contextView';
import { ContextView } from 'vs/base/browser/ui/contextview/contextview';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IMessageService } from 'vs/platform/message/common/message';
export class ContextViewService implements IContextViewService {
public _serviceBrand: any;
private contextView: ContextView;
constructor(
container: HTMLElement,
@ITelemetryService telemetryService: ITelemetryService,
@IMessageService messageService: IMessageService
) {
this.contextView = new ContextView(container);
}
public dispose(): void {
this.contextView.dispose();
}
// ContextView
public setContainer(container: HTMLElement): void {
this.contextView.setContainer(container);
}
public showContextView(delegate: IContextViewDelegate): void {
this.contextView.show(delegate);
}
public layout(): void {
this.contextView.layout();
}
public hideContextView(data?: any): void {
this.contextView.hide(data);
}
}