mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Small strict null checking pass on a few files (#4293)
* fix some null checking * fix various null strict checks * move location fo sql files in json * fix compile and more unused properties * formatting * small formatting changes * readd types * add comments for angular components * formatting * remove any decl
This commit is contained in:
@@ -30,7 +30,7 @@ import { IDisposable } from 'vs/base/common/lifecycle';
|
|||||||
`
|
`
|
||||||
})
|
})
|
||||||
export class BreadcrumbComponent implements OnInit, OnDestroy {
|
export class BreadcrumbComponent implements OnInit, OnDestroy {
|
||||||
private menuItems: MenuItem[] = [];
|
protected menuItems: MenuItem[] = []; // used by angular template
|
||||||
private disposables: Array<IDisposable> = new Array();
|
private disposables: Array<IDisposable> = new Array();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
|||||||
@@ -13,11 +13,10 @@ export interface IButtonStyles extends vsIButtonStyles {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Button extends vsButton {
|
export class Button extends vsButton {
|
||||||
private buttonFocusOutline: Color;
|
private buttonFocusOutline?: Color;
|
||||||
|
|
||||||
constructor(container: HTMLElement, options?: IButtonOptions) {
|
constructor(container: HTMLElement, options?: IButtonOptions) {
|
||||||
super(container, options);
|
super(container, options);
|
||||||
this.buttonFocusOutline = null;
|
|
||||||
|
|
||||||
this._register(DOM.addDisposableListener(this.element, DOM.EventType.FOCUS, () => {
|
this._register(DOM.addDisposableListener(this.element, DOM.EventType.FOCUS, () => {
|
||||||
this.element.style.outlineColor = this.buttonFocusOutline ? this.buttonFocusOutline.toString() : null;
|
this.element.style.outlineColor = this.buttonFocusOutline ? this.buttonFocusOutline.toString() : null;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export interface ICheckboxStyles {
|
|||||||
export class Checkbox extends Widget {
|
export class Checkbox extends Widget {
|
||||||
private _el: HTMLInputElement;
|
private _el: HTMLInputElement;
|
||||||
private _label: HTMLSpanElement;
|
private _label: HTMLSpanElement;
|
||||||
private disabledCheckboxForeground: Color;
|
private disabledCheckboxForeground?: Color;
|
||||||
|
|
||||||
private _onChange = new Emitter<boolean>();
|
private _onChange = new Emitter<boolean>();
|
||||||
public readonly onChange: Event<boolean> = this._onChange.event;
|
public readonly onChange: Event<boolean> = this._onChange.event;
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
import 'vs/css!./media/dropdownList';
|
import 'vs/css!./media/dropdownList';
|
||||||
import * as DOM from 'vs/base/browser/dom';
|
import * as DOM from 'vs/base/browser/dom';
|
||||||
import { Dropdown, IDropdownOptions } from 'vs/base/browser/ui/dropdown/dropdown';
|
import { Dropdown, IDropdownOptions } from 'vs/base/browser/ui/dropdown/dropdown';
|
||||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
|
||||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||||
import { Color } from 'vs/base/common/color';
|
import { Color } from 'vs/base/common/color';
|
||||||
import { IAction } from 'vs/base/common/actions';
|
import { IAction } from 'vs/base/common/actions';
|
||||||
@@ -15,10 +14,8 @@ import { EventType as GestureEventType } from 'vs/base/browser/touch';
|
|||||||
import { List } from 'vs/base/browser/ui/list/listWidget';
|
import { List } from 'vs/base/browser/ui/list/listWidget';
|
||||||
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||||
import { KeyCode } from 'vs/base/common/keyCodes';
|
import { KeyCode } from 'vs/base/common/keyCodes';
|
||||||
import { Builder } from 'sql/base/browser/builder';
|
|
||||||
|
|
||||||
import { Button } from 'sql/base/browser/ui/button/button';
|
import { Button, IButtonStyles } from 'sql/base/browser/ui/button/button';
|
||||||
import { attachButtonStyler } from 'sql/platform/theme/common/styler';
|
|
||||||
|
|
||||||
export interface IDropdownStyles {
|
export interface IDropdownStyles {
|
||||||
backgroundColor?: Color;
|
backgroundColor?: Color;
|
||||||
@@ -28,51 +25,49 @@ export interface IDropdownStyles {
|
|||||||
|
|
||||||
export class DropdownList extends Dropdown {
|
export class DropdownList extends Dropdown {
|
||||||
|
|
||||||
protected backgroundColor: Color;
|
protected backgroundColor?: Color;
|
||||||
protected foregroundColor: Color;
|
protected foregroundColor?: Color;
|
||||||
protected borderColor: Color;
|
protected borderColor?: Color;
|
||||||
|
|
||||||
|
private button?: Button;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
container: HTMLElement,
|
container: HTMLElement,
|
||||||
private _options: IDropdownOptions,
|
private _options: IDropdownOptions,
|
||||||
private _contentContainer: HTMLElement,
|
private _contentContainer: HTMLElement,
|
||||||
private _list: List<any>,
|
private _list: List<any>,
|
||||||
private _themeService: IThemeService,
|
action?: IAction,
|
||||||
private _action?: IAction,
|
|
||||||
) {
|
) {
|
||||||
super(container, _options);
|
super(container, _options);
|
||||||
if (_action) {
|
if (action) {
|
||||||
let button = new Button(_contentContainer);
|
this.button = new Button(_contentContainer);
|
||||||
button.label = _action.label;
|
this.button.label = action.label;
|
||||||
this.toDispose.push(DOM.addDisposableListener(button.element, DOM.EventType.CLICK, () => {
|
this.toDispose.push(DOM.addDisposableListener(this.button.element, DOM.EventType.CLICK, () => {
|
||||||
this._action.run();
|
action.run();
|
||||||
this.hide();
|
this.hide();
|
||||||
}));
|
}));
|
||||||
this.toDispose.push(DOM.addDisposableListener(button.element, DOM.EventType.KEY_DOWN, (e: KeyboardEvent) => {
|
this.toDispose.push(DOM.addDisposableListener(this.button.element, DOM.EventType.KEY_DOWN, (e: KeyboardEvent) => {
|
||||||
let event = new StandardKeyboardEvent(e);
|
let event = new StandardKeyboardEvent(e);
|
||||||
if (event.equals(KeyCode.Enter)) {
|
if (event.equals(KeyCode.Enter)) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
this._action.run();
|
action.run();
|
||||||
this.hide();
|
this.hide();
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
attachButtonStyler(button, this._themeService);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DOM.append(this.element, DOM.$('div.dropdown-icon'));
|
DOM.append(this.element, DOM.$('div.dropdown-icon'));
|
||||||
|
|
||||||
this.toDispose.push(new Builder(this.element).on([DOM.EventType.CLICK, DOM.EventType.MOUSE_DOWN, GestureEventType.Tap], (e: Event) => {
|
[DOM.EventType.CLICK, DOM.EventType.MOUSE_DOWN, GestureEventType.Tap].forEach(event => {
|
||||||
DOM.EventHelper.stop(e, true); // prevent default click behaviour to trigger
|
this._register(DOM.addDisposableListener(this.element, event, e => DOM.EventHelper.stop(e, true))); // prevent default click behaviour to trigger
|
||||||
}).on([DOM.EventType.MOUSE_DOWN, GestureEventType.Tap], (e: Event) => {
|
});
|
||||||
// We want to show the context menu on dropdown so that as a user you can press and hold the
|
|
||||||
// mouse button, make a choice of action in the menu and release the mouse to trigger that
|
[DOM.EventType.MOUSE_DOWN, GestureEventType.Tap].forEach(event => {
|
||||||
// action.
|
this._register(DOM.addDisposableListener(this.element, event, e => setTimeout(() => this.show(), 100)));
|
||||||
// Due to some weird bugs though, we delay showing the menu to unwind event stack
|
});
|
||||||
// (see https://github.com/Microsoft/vscode/issues/27648)
|
|
||||||
setTimeout(() => this.show(), 100);
|
this._register(DOM.addStandardDisposableListener(this.element, DOM.EventType.KEY_DOWN, (e: StandardKeyboardEvent) => {
|
||||||
}).on([DOM.EventType.KEY_DOWN], (e: KeyboardEvent) => {
|
if (e.equals(KeyCode.Enter)) {
|
||||||
let event = new StandardKeyboardEvent(e);
|
|
||||||
if (event.equals(KeyCode.Enter)) {
|
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.show();
|
this.show();
|
||||||
@@ -96,7 +91,7 @@ export class DropdownList extends Dropdown {
|
|||||||
protected renderContents(container: HTMLElement): IDisposable {
|
protected renderContents(container: HTMLElement): IDisposable {
|
||||||
let div = DOM.append(container, this._contentContainer);
|
let div = DOM.append(container, this._contentContainer);
|
||||||
div.style.width = DOM.getTotalWidth(this.element) + 'px';
|
div.style.width = DOM.getTotalWidth(this.element) + 'px';
|
||||||
return null;
|
return { dispose: () => { } };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -126,11 +121,14 @@ export class DropdownList extends Dropdown {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public style(styles: IDropdownStyles): void {
|
public style(styles: IDropdownStyles & IButtonStyles): void {
|
||||||
this.backgroundColor = styles.backgroundColor;
|
this.backgroundColor = styles.backgroundColor;
|
||||||
this.foregroundColor = styles.foregroundColor;
|
this.foregroundColor = styles.foregroundColor;
|
||||||
this.borderColor = styles.borderColor;
|
this.borderColor = styles.borderColor;
|
||||||
this.applyStyles();
|
this.applyStyles();
|
||||||
|
if (this.button) {
|
||||||
|
this.button.style(styles);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected applyStyles(): void {
|
protected applyStyles(): void {
|
||||||
@@ -143,7 +141,7 @@ export class DropdownList extends Dropdown {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private applyStylesOnElement(element: HTMLElement, background: string, foreground: string, border: string): void {
|
private applyStylesOnElement(element: HTMLElement, background: string | null, foreground: string | null, border: string | null): void {
|
||||||
if (element) {
|
if (element) {
|
||||||
element.style.backgroundColor = background;
|
element.style.backgroundColor = background;
|
||||||
element.style.color = foreground;
|
element.style.color = foreground;
|
||||||
@@ -153,4 +151,4 @@ export class DropdownList extends Dropdown {
|
|||||||
element.style.borderColor = border;
|
element.style.borderColor = border;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
import { Action } from 'vs/base/common/actions';
|
import { Action } from 'vs/base/common/actions';
|
||||||
import { TPromise } from 'vs/base/common/winjs.base';
|
import { TPromise } from 'vs/base/common/winjs.base';
|
||||||
import * as nls from 'vs/nls';
|
|
||||||
|
|
||||||
export class ToggleDropdownAction extends Action {
|
export class ToggleDropdownAction extends Action {
|
||||||
private static readonly ID = 'dropdownAction.toggle';
|
private static readonly ID = 'dropdownAction.toggle';
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import { InputBox, IInputBoxStyles } from 'sql/base/browser/ui/inputBox/inputBox
|
|||||||
import { IMessage, MessageType } from 'vs/base/browser/ui/inputbox/inputBox';
|
import { IMessage, MessageType } from 'vs/base/browser/ui/inputbox/inputBox';
|
||||||
import { IListStyles } from 'vs/base/browser/ui/list/listWidget';
|
import { IListStyles } from 'vs/base/browser/ui/list/listWidget';
|
||||||
import * as DOM from 'vs/base/browser/dom';
|
import * as DOM from 'vs/base/browser/dom';
|
||||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
|
||||||
import { Disposable } from 'vs/base/common/lifecycle';
|
import { Disposable } from 'vs/base/common/lifecycle';
|
||||||
import { Color } from 'vs/base/common/color';
|
import { Color } from 'vs/base/common/color';
|
||||||
import * as nls from 'vs/nls';
|
import * as nls from 'vs/nls';
|
||||||
@@ -74,14 +73,6 @@ const defaults: IDropdownOptions = {
|
|||||||
actionLabel: nls.localize('dropdownAction.toggle', "Toggle dropdown")
|
actionLabel: nls.localize('dropdownAction.toggle', "Toggle dropdown")
|
||||||
};
|
};
|
||||||
|
|
||||||
interface ListResource {
|
|
||||||
label: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface TableTemplate {
|
|
||||||
label: HTMLElement;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Dropdown extends Disposable {
|
export class Dropdown extends Disposable {
|
||||||
private $el: Builder;
|
private $el: Builder;
|
||||||
private $input: Builder;
|
private $input: Builder;
|
||||||
@@ -110,12 +101,12 @@ export class Dropdown extends Disposable {
|
|||||||
constructor(
|
constructor(
|
||||||
container: HTMLElement,
|
container: HTMLElement,
|
||||||
contextViewService: IContextViewProvider,
|
contextViewService: IContextViewProvider,
|
||||||
private _themeService: IThemeService,
|
|
||||||
opt?: IDropdownOptions
|
opt?: IDropdownOptions
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
this._contextView = new ContextView(document.body);
|
this._contextView = new ContextView(document.body);
|
||||||
this._options = mixin(opt, defaults, false) as IDropdownOptions;
|
this._options = opt || Object.create(null);
|
||||||
|
mixin(this._options, defaults, false) as IDropdownOptions;
|
||||||
this.$el = $('.monaco-dropdown').style('width', '100%').appendTo(container);
|
this.$el = $('.monaco-dropdown').style('width', '100%').appendTo(container);
|
||||||
|
|
||||||
this.$input = $('.dropdown-input').style('width', '100%').appendTo(this.$el);
|
this.$input = $('.dropdown-input').style('width', '100%').appendTo(this.$el);
|
||||||
@@ -125,7 +116,7 @@ export class Dropdown extends Disposable {
|
|||||||
this._showList();
|
this._showList();
|
||||||
this._tree.domFocus();
|
this._tree.domFocus();
|
||||||
this._tree.focusFirst();
|
this._tree.focusFirst();
|
||||||
}, opt.actionLabel);
|
}, this._options.actionLabel);
|
||||||
|
|
||||||
this._input = new InputBox(this.$input.getHTMLElement(), contextViewService, {
|
this._input = new InputBox(this.$input.getHTMLElement(), contextViewService, {
|
||||||
validationOptions: {
|
validationOptions: {
|
||||||
@@ -258,18 +249,18 @@ export class Dropdown extends Disposable {
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
let height = filteredLength * this._renderer.getHeight(undefined, undefined) > this._options.maxHeight ? this._options.maxHeight : filteredLength * this._renderer.getHeight(undefined, undefined);
|
let height = filteredLength * this._renderer.getHeight() > this._options.maxHeight! ? this._options.maxHeight! : filteredLength * this._renderer.getHeight();
|
||||||
this.$treeContainer.style('height', height + 'px').style('width', DOM.getContentWidth(this.$input.getHTMLElement()) - 2 + 'px');
|
this.$treeContainer.style('height', height + 'px').style('width', DOM.getContentWidth(this.$input.getHTMLElement()) - 2 + 'px');
|
||||||
this._tree.layout(parseInt(this.$treeContainer.style('height')));
|
this._tree.layout(parseInt(this.$treeContainer.style('height')));
|
||||||
this._tree.refresh();
|
this._tree.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public set values(vals: string[]) {
|
public set values(vals: string[] | undefined) {
|
||||||
if (vals) {
|
if (vals) {
|
||||||
this._filter.filterString = '';
|
this._filter.filterString = '';
|
||||||
this._dataSource.options = vals.map(i => { return { value: i }; });
|
this._dataSource.options = vals.map(i => { return { value: i }; });
|
||||||
let height = this._dataSource.options.length * 22 > this._options.maxHeight ? this._options.maxHeight : this._dataSource.options.length * 22;
|
let height = this._dataSource.options.length * 22 > this._options.maxHeight! ? this._options.maxHeight! : this._dataSource.options.length * 22;
|
||||||
this.$treeContainer.style('height', height + 'px').style('width', DOM.getContentWidth(this.$input.getHTMLElement()) - 2 + 'px');
|
this.$treeContainer.style('height', height + 'px').style('width', DOM.getContentWidth(this.$input.getHTMLElement()) - 2 + 'px');
|
||||||
this._tree.layout(parseInt(this.$treeContainer.style('height')));
|
this._tree.layout(parseInt(this.$treeContainer.style('height')));
|
||||||
this._tree.setInput(new DropdownModel());
|
this._tree.setInput(new DropdownModel());
|
||||||
@@ -297,13 +288,15 @@ export class Dropdown extends Disposable {
|
|||||||
style(style: IListStyles & IInputBoxStyles & IDropdownStyles) {
|
style(style: IListStyles & IInputBoxStyles & IDropdownStyles) {
|
||||||
this._tree.style(style);
|
this._tree.style(style);
|
||||||
this._input.style(style);
|
this._input.style(style);
|
||||||
this.$treeContainer.style('background-color', style.contextBackground.toString());
|
if (style.contextBackground) {
|
||||||
|
this.$treeContainer.style('background-color', style.contextBackground.toString());
|
||||||
|
}
|
||||||
this.$treeContainer.style('outline', `1px solid ${style.contextBorder || this._options.contextBorder}`);
|
this.$treeContainer.style('outline', `1px solid ${style.contextBorder || this._options.contextBorder}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _inputValidator(value: string): IMessage {
|
private _inputValidator(value: string): IMessage {
|
||||||
if (this._dataSource.options && !this._dataSource.options.find(i => i.value === value)) {
|
if (this._dataSource.options && !this._dataSource.options.find(i => i.value === value)) {
|
||||||
if (this._options.strictSelection) {
|
if (this._options.strictSelection && this._options.errorMessage) {
|
||||||
return {
|
return {
|
||||||
content: this._options.errorMessage,
|
content: this._options.errorMessage,
|
||||||
type: MessageType.ERROR
|
type: MessageType.ERROR
|
||||||
|
|||||||
@@ -26,11 +26,11 @@ export class DropdownModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class DropdownRenderer implements tree.IRenderer {
|
export class DropdownRenderer implements tree.IRenderer {
|
||||||
public getHeight(tree: tree.ITree, element: Resource): number {
|
public getHeight(): number {
|
||||||
return 22;
|
return 22;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTemplateId(tree: tree.ITree, element: Resource): string {
|
public getTemplateId(): string {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ export class EditableDropDown extends AngularDisposable implements OnInit, OnCha
|
|||||||
ariaLabel: '',
|
ariaLabel: '',
|
||||||
actionLabel: ''
|
actionLabel: ''
|
||||||
};
|
};
|
||||||
this._selectbox = new Dropdown(this._el.nativeElement, this.contextViewService, this.themeService, dropdownOptions);
|
this._selectbox = new Dropdown(this._el.nativeElement, this.contextViewService, dropdownOptions);
|
||||||
this._selectbox.values = this.options;
|
this._selectbox.values = this.options;
|
||||||
this._selectbox.value = this.selectedOption;
|
this._selectbox.value = this.selectedOption;
|
||||||
|
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ export interface IInputBoxStyles extends vsIInputBoxStyles {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class InputBox extends vsInputBox {
|
export class InputBox extends vsInputBox {
|
||||||
private enabledInputBackground: Color;
|
private enabledInputBackground?: Color;
|
||||||
private enabledInputForeground: Color;
|
private enabledInputForeground?: Color;
|
||||||
private enabledInputBorder: Color;
|
private enabledInputBorder?: Color;
|
||||||
private disabledInputBackground: Color;
|
private disabledInputBackground?: Color;
|
||||||
private disabledInputForeground: Color;
|
private disabledInputForeground?: Color;
|
||||||
private disabledInputBorder: Color;
|
private disabledInputBorder?: Color;
|
||||||
|
|
||||||
private _lastLoseFocusValue: string;
|
private _lastLoseFocusValue: string;
|
||||||
|
|
||||||
@@ -41,8 +41,6 @@ export class InputBox extends vsInputBox {
|
|||||||
this.enabledInputForeground = this.inputForeground;
|
this.enabledInputForeground = this.inputForeground;
|
||||||
this.enabledInputBorder = this.inputBorder;
|
this.enabledInputBorder = this.inputBorder;
|
||||||
this.disabledInputBackground = Color.transparent;
|
this.disabledInputBackground = Color.transparent;
|
||||||
this.disabledInputForeground = null;
|
|
||||||
this.disabledInputBorder = null;
|
|
||||||
|
|
||||||
this._lastLoseFocusValue = this.value;
|
this._lastLoseFocusValue = this.value;
|
||||||
let self = this;
|
let self = this;
|
||||||
@@ -126,4 +124,4 @@ export class InputBox extends vsInputBox {
|
|||||||
this.inputForeground = enabled ? this.enabledInputForeground : this.disabledInputForeground;
|
this.inputForeground = enabled ? this.enabledInputForeground : this.disabledInputForeground;
|
||||||
this.inputBorder = enabled ? this.enabledInputBorder : this.disabledInputBorder;
|
this.inputBorder = enabled ? this.enabledInputBorder : this.disabledInputBorder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
|||||||
import { IContextViewProvider, AnchorAlignment } from 'vs/base/browser/ui/contextview/contextview';
|
import { IContextViewProvider, AnchorAlignment } from 'vs/base/browser/ui/contextview/contextview';
|
||||||
import { RenderOptions, renderFormattedText, renderText } from 'vs/base/browser/htmlContentRenderer';
|
import { RenderOptions, renderFormattedText, renderText } from 'vs/base/browser/htmlContentRenderer';
|
||||||
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
||||||
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
|
||||||
|
|
||||||
const $ = dom.$;
|
const $ = dom.$;
|
||||||
|
|
||||||
@@ -33,27 +32,26 @@ export interface IListBoxStyles {
|
|||||||
* Extends SelectBox to allow multiple selection and adding/remove items dynamically
|
* Extends SelectBox to allow multiple selection and adding/remove items dynamically
|
||||||
*/
|
*/
|
||||||
export class ListBox extends SelectBox {
|
export class ListBox extends SelectBox {
|
||||||
private enabledSelectBackground: Color;
|
private enabledSelectBackground?: Color;
|
||||||
private enabledSelectForeground: Color;
|
private enabledSelectForeground?: Color;
|
||||||
private enabledSelectBorder: Color;
|
private enabledSelectBorder?: Color;
|
||||||
private disabledSelectBackground: Color;
|
private disabledSelectBackground?: Color;
|
||||||
private disabledSelectForeground: Color;
|
private disabledSelectForeground?: Color;
|
||||||
private disabledSelectBorder: Color;
|
private disabledSelectBorder?: Color;
|
||||||
|
|
||||||
private inputValidationInfoBorder: Color;
|
private inputValidationInfoBorder?: Color;
|
||||||
private inputValidationInfoBackground: Color;
|
private inputValidationInfoBackground?: Color;
|
||||||
private inputValidationWarningBorder: Color;
|
private inputValidationWarningBorder?: Color;
|
||||||
private inputValidationWarningBackground: Color;
|
private inputValidationWarningBackground?: Color;
|
||||||
private inputValidationErrorBorder: Color;
|
private inputValidationErrorBorder?: Color;
|
||||||
private inputValidationErrorBackground: Color;
|
private inputValidationErrorBackground?: Color;
|
||||||
|
|
||||||
private message: IMessage;
|
private message?: IMessage;
|
||||||
private contextViewProvider: IContextViewProvider;
|
private contextViewProvider: IContextViewProvider;
|
||||||
private isValid: boolean;
|
private isValid: boolean;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
options: string[],
|
options: string[],
|
||||||
selectedOption: string,
|
|
||||||
contextViewProvider: IContextViewProvider,
|
contextViewProvider: IContextViewProvider,
|
||||||
private _clipboardService: IClipboardService) {
|
private _clipboardService: IClipboardService) {
|
||||||
|
|
||||||
@@ -73,8 +71,6 @@ export class ListBox extends SelectBox {
|
|||||||
this.enabledSelectForeground = this.selectForeground;
|
this.enabledSelectForeground = this.selectForeground;
|
||||||
this.enabledSelectBorder = this.selectBorder;
|
this.enabledSelectBorder = this.selectBorder;
|
||||||
this.disabledSelectBackground = Color.transparent;
|
this.disabledSelectBackground = Color.transparent;
|
||||||
this.disabledSelectForeground = null;
|
|
||||||
this.disabledSelectBorder = null;
|
|
||||||
|
|
||||||
this.inputValidationInfoBorder = defaultOpts.inputValidationInfoBorder;
|
this.inputValidationInfoBorder = defaultOpts.inputValidationInfoBorder;
|
||||||
this.inputValidationInfoBackground = defaultOpts.inputValidationInfoBackground;
|
this.inputValidationInfoBackground = defaultOpts.inputValidationInfoBackground;
|
||||||
@@ -112,7 +108,7 @@ export class ListBox extends SelectBox {
|
|||||||
|
|
||||||
if (this.isValid) {
|
if (this.isValid) {
|
||||||
this.selectElement.style.border = `1px solid ${this.selectBorder}`;
|
this.selectElement.style.border = `1px solid ${this.selectBorder}`;
|
||||||
} else {
|
} else if (this.message) {
|
||||||
const styles = this.stylesForType(this.message.type);
|
const styles = this.stylesForType(this.message.type);
|
||||||
this.selectElement.style.border = styles.border ? `1px solid ${styles.border}` : null;
|
this.selectElement.style.border = styles.border ? `1px solid ${styles.border}` : null;
|
||||||
}
|
}
|
||||||
@@ -123,7 +119,7 @@ export class ListBox extends SelectBox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public get selectedOptions(): string[] {
|
public get selectedOptions(): string[] {
|
||||||
let selected = [];
|
let selected: string[] = [];
|
||||||
for (let i = 0; i < this.selectElement.selectedOptions.length; i++) {
|
for (let i = 0; i < this.selectElement.selectedOptions.length; i++) {
|
||||||
selected.push(this.selectElement.selectedOptions[i].innerHTML);
|
selected.push(this.selectElement.selectedOptions[i].innerHTML);
|
||||||
}
|
}
|
||||||
@@ -136,7 +132,7 @@ export class ListBox extends SelectBox {
|
|||||||
|
|
||||||
// Remove selected options
|
// Remove selected options
|
||||||
public remove(): void {
|
public remove(): void {
|
||||||
let indexes = [];
|
let indexes: number[] = [];
|
||||||
for (let i = 0; i < this.selectElement.selectedOptions.length; i++) {
|
for (let i = 0; i < this.selectElement.selectedOptions.length; i++) {
|
||||||
indexes.push(this.selectElement.selectedOptions[i].index);
|
indexes.push(this.selectElement.selectedOptions[i].index);
|
||||||
}
|
}
|
||||||
@@ -219,24 +215,26 @@ export class ListBox extends SelectBox {
|
|||||||
className: 'monaco-inputbox-message'
|
className: 'monaco-inputbox-message'
|
||||||
};
|
};
|
||||||
|
|
||||||
let spanElement: HTMLElement = (this.message.formatContent
|
if (this.message) {
|
||||||
? renderFormattedText(this.message.content, renderOptions)
|
let spanElement: HTMLElement = (this.message.formatContent
|
||||||
: renderText(this.message.content, renderOptions)) as any;
|
? renderFormattedText(this.message.content, renderOptions)
|
||||||
dom.addClass(spanElement, this.classForType(this.message.type));
|
: renderText(this.message.content, renderOptions)) as any;
|
||||||
|
dom.addClass(spanElement, this.classForType(this.message.type));
|
||||||
|
|
||||||
const styles = this.stylesForType(this.message.type);
|
const styles = this.stylesForType(this.message.type);
|
||||||
spanElement.style.backgroundColor = styles.background ? styles.background.toString() : null;
|
spanElement.style.backgroundColor = styles.background ? styles.background.toString() : null;
|
||||||
spanElement.style.border = styles.border ? `1px solid ${styles.border}` : null;
|
spanElement.style.border = styles.border ? `1px solid ${styles.border}` : null;
|
||||||
|
|
||||||
dom.append(div, spanElement);
|
dom.append(div, spanElement);
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return { dispose: () => { } };
|
||||||
},
|
},
|
||||||
layout: layout
|
layout: layout
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private classForType(type: MessageType): string {
|
private classForType(type?: MessageType): string {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case MessageType.INFO: return 'info';
|
case MessageType.INFO: return 'info';
|
||||||
case MessageType.WARNING: return 'warning';
|
case MessageType.WARNING: return 'warning';
|
||||||
@@ -244,11 +242,11 @@ export class ListBox extends SelectBox {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private stylesForType(type: MessageType): { border: Color; background: Color } {
|
private stylesForType(type?: MessageType): { border?: Color; background?: Color } {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case MessageType.INFO: return { border: this.inputValidationInfoBorder, background: this.inputValidationInfoBackground };
|
case MessageType.INFO: return { border: this.inputValidationInfoBorder, background: this.inputValidationInfoBackground };
|
||||||
case MessageType.WARNING: return { border: this.inputValidationWarningBorder, background: this.inputValidationWarningBackground };
|
case MessageType.WARNING: return { border: this.inputValidationWarningBorder, background: this.inputValidationWarningBackground };
|
||||||
default: return { border: this.inputValidationErrorBorder, background: this.inputValidationErrorBackground };
|
default: return { border: this.inputValidationErrorBorder, background: this.inputValidationErrorBackground };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,11 +81,11 @@ export class PanelComponent extends Disposable {
|
|||||||
private _actionbar: ActionBar;
|
private _actionbar: ActionBar;
|
||||||
private _mru: TabComponent[];
|
private _mru: TabComponent[];
|
||||||
|
|
||||||
protected ScrollbarVisibility = ScrollbarVisibility;
|
protected ScrollbarVisibility = ScrollbarVisibility; // used by angular template
|
||||||
protected NavigationBarLayout = NavigationBarLayout;
|
protected NavigationBarLayout = NavigationBarLayout; // used by angular template
|
||||||
|
|
||||||
@ViewChild('panelActionbar', { read: ElementRef }) private _actionbarRef: ElementRef;
|
@ViewChild('panelActionbar', { read: ElementRef }) private _actionbarRef: ElementRef;
|
||||||
constructor( @Inject(forwardRef(() => NgZone)) private _zone: NgZone) {
|
constructor(@Inject(forwardRef(() => NgZone)) private _zone: NgZone) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,79 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------------------------
|
|
||||||
* 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 { ITask, createCancelablePromise, CancelablePromise } from 'vs/base/common/async';
|
|
||||||
import { Promise, TPromise, ValueCallback } from 'vs/base/common/winjs.base';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Bases on vscode Delayer, however, it works by only running the task if it gets
|
|
||||||
* a specified number of requests in a specified time
|
|
||||||
*
|
|
||||||
* Ex. Useful encapsulation of handling double click from click listeners
|
|
||||||
*/
|
|
||||||
export class MultipleRequestDelayer<T> {
|
|
||||||
|
|
||||||
private timeout: NodeJS.Timer;
|
|
||||||
private completionPromise: CancelablePromise<any>;
|
|
||||||
private onSuccess: ValueCallback;
|
|
||||||
private requests: number = 0;
|
|
||||||
private task: ITask<T>;
|
|
||||||
|
|
||||||
constructor(public delay: number, private maxRequests: number = 2) {
|
|
||||||
this.timeout = null;
|
|
||||||
this.completionPromise = null;
|
|
||||||
this.onSuccess = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
trigger(task: ITask<T>): TPromise<T> {
|
|
||||||
this.cancelTimeout();
|
|
||||||
this.task = task;
|
|
||||||
|
|
||||||
if (++this.requests > this.maxRequests - 1) {
|
|
||||||
this.requests = 0;
|
|
||||||
this.onSuccess(null);
|
|
||||||
return this.completionPromise;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.completionPromise) {
|
|
||||||
this.completionPromise = createCancelablePromise<T>(() => new Promise(resolve => this.onSuccess = resolve).then(() => {
|
|
||||||
this.completionPromise = null;
|
|
||||||
this.onSuccess = null;
|
|
||||||
const task = this.task;
|
|
||||||
this.task = null;
|
|
||||||
|
|
||||||
return task();
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
this.timeout = setTimeout(() => {
|
|
||||||
this.timeout = null;
|
|
||||||
this.requests = 0;
|
|
||||||
}, this.delay);
|
|
||||||
|
|
||||||
return this.completionPromise;
|
|
||||||
}
|
|
||||||
|
|
||||||
isTriggered(): boolean {
|
|
||||||
return this.timeout !== null;
|
|
||||||
}
|
|
||||||
|
|
||||||
cancel(): void {
|
|
||||||
this.cancelTimeout();
|
|
||||||
|
|
||||||
if (this.completionPromise) {
|
|
||||||
this.completionPromise.cancel();
|
|
||||||
this.completionPromise = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private cancelTimeout(): void {
|
|
||||||
if (this.timeout !== null) {
|
|
||||||
clearTimeout(this.timeout);
|
|
||||||
this.timeout = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,12 +9,16 @@
|
|||||||
* Alterable version of the vs memorize function; to unmemoize use unmemoize
|
* Alterable version of the vs memorize function; to unmemoize use unmemoize
|
||||||
*/
|
*/
|
||||||
export function memoize(target: any, key: string, descriptor: any) {
|
export function memoize(target: any, key: string, descriptor: any) {
|
||||||
let fnKey: string = null;
|
let fnKey: string | null = null;
|
||||||
let fn: Function = null;
|
let fn: Function | null = null;
|
||||||
|
|
||||||
if (typeof descriptor.value === 'function') {
|
if (typeof descriptor.value === 'function') {
|
||||||
fnKey = 'value';
|
fnKey = 'value';
|
||||||
fn = descriptor.value;
|
fn = descriptor.value;
|
||||||
|
|
||||||
|
if (fn!.length !== 0) {
|
||||||
|
console.warn('Memoize should only be used in functions with zero parameters');
|
||||||
|
}
|
||||||
} else if (typeof descriptor.get === 'function') {
|
} else if (typeof descriptor.get === 'function') {
|
||||||
fnKey = 'get';
|
fnKey = 'get';
|
||||||
fn = descriptor.get;
|
fn = descriptor.get;
|
||||||
@@ -26,13 +30,13 @@ export function memoize(target: any, key: string, descriptor: any) {
|
|||||||
|
|
||||||
const memoizeKey = `$memoize$${key}`;
|
const memoizeKey = `$memoize$${key}`;
|
||||||
|
|
||||||
descriptor[fnKey] = function (...args: any[]) {
|
descriptor[fnKey!] = function (...args: any[]) {
|
||||||
if (!this.hasOwnProperty(memoizeKey)) {
|
if (!this.hasOwnProperty(memoizeKey)) {
|
||||||
Object.defineProperty(this, memoizeKey, {
|
Object.defineProperty(this, memoizeKey, {
|
||||||
configurable: true,
|
configurable: true,
|
||||||
enumerable: false,
|
enumerable: false,
|
||||||
writable: false,
|
writable: false,
|
||||||
value: fn.apply(this, args)
|
value: fn!.apply(this, args)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,4 +49,4 @@ export function unmemoize(target: Object, key: string) {
|
|||||||
if (target.hasOwnProperty(memoizeKey)) {
|
if (target.hasOwnProperty(memoizeKey)) {
|
||||||
delete target[memoizeKey];
|
delete target[memoizeKey];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,89 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------------------------
|
|
||||||
* 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 { Emitter, Event } from 'vs/base/common/event';
|
|
||||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implementation of vs/base/common/event/echo that is clearable
|
|
||||||
* Similar to `buffer` but it buffers indefinitely and repeats
|
|
||||||
* the buffered events to every new listener.
|
|
||||||
*/
|
|
||||||
export function echo<T>(event: Event<T>, nextTick = false, buffer: T[] = []): { clear: () => void; event: Event<T> } {
|
|
||||||
buffer = buffer.slice();
|
|
||||||
|
|
||||||
event(e => {
|
|
||||||
buffer.push(e);
|
|
||||||
emitter.fire(e);
|
|
||||||
});
|
|
||||||
|
|
||||||
const flush = (listener: (e: T) => any, thisArgs?: any) => buffer.forEach(e => listener.call(thisArgs, e));
|
|
||||||
const clear = () => buffer = [];
|
|
||||||
|
|
||||||
const emitter = new Emitter<T>({
|
|
||||||
onListenerDidAdd(emitter, listener: (e: T) => any, thisArgs?: any) {
|
|
||||||
if (nextTick) {
|
|
||||||
setTimeout(() => flush(listener, thisArgs));
|
|
||||||
} else {
|
|
||||||
flush(listener, thisArgs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
event: emitter.event,
|
|
||||||
clear
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implementation of vs/base/common/event/debounceEvent that is clearable
|
|
||||||
*/
|
|
||||||
export function debounceEvent<T>(event: Event<T>, merger: (last: T, event: T) => T, delay?: number, leading?: boolean): { clear: () => void; event: Event<T> };
|
|
||||||
export function debounceEvent<I, O>(event: Event<I>, merger: (last: O, event: I) => O, delay?: number, leading?: boolean): { clear: () => void; event: Event<O> };
|
|
||||||
export function debounceEvent<I, O>(event: Event<I>, merger: (last: O, event: I) => O, delay: number = 100, leading = false): { clear: () => void; event: Event<O> } {
|
|
||||||
|
|
||||||
let subscription: IDisposable;
|
|
||||||
let output: O = undefined;
|
|
||||||
let handle: any = undefined;
|
|
||||||
let numDebouncedCalls = 0;
|
|
||||||
|
|
||||||
const clear = () => output = undefined;
|
|
||||||
|
|
||||||
const emitter = new Emitter<O>({
|
|
||||||
onFirstListenerAdd() {
|
|
||||||
subscription = event(cur => {
|
|
||||||
numDebouncedCalls++;
|
|
||||||
output = merger(output, cur);
|
|
||||||
|
|
||||||
if (leading && !handle) {
|
|
||||||
emitter.fire(output);
|
|
||||||
}
|
|
||||||
|
|
||||||
clearTimeout(handle);
|
|
||||||
handle = setTimeout(() => {
|
|
||||||
let _output = output;
|
|
||||||
output = undefined;
|
|
||||||
handle = undefined;
|
|
||||||
if (!leading || numDebouncedCalls > 1) {
|
|
||||||
emitter.fire(_output);
|
|
||||||
}
|
|
||||||
|
|
||||||
numDebouncedCalls = 0;
|
|
||||||
}, delay);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onLastListenerRemove() {
|
|
||||||
subscription.dispose();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
event: emitter.event,
|
|
||||||
clear
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ export class EmitterEvent {
|
|||||||
public readonly type: string;
|
public readonly type: string;
|
||||||
public readonly data: any;
|
public readonly data: any;
|
||||||
|
|
||||||
constructor(eventType: string = null, data: any = null) {
|
constructor(eventType: string, data: any) {
|
||||||
this.type = eventType;
|
this.type = eventType;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
@@ -46,9 +46,9 @@ export class EventEmitter implements IEventEmitter {
|
|||||||
protected _bulkListeners: ListenerCallback[];
|
protected _bulkListeners: ListenerCallback[];
|
||||||
private _collectedEvents: EmitterEvent[];
|
private _collectedEvents: EmitterEvent[];
|
||||||
private _deferredCnt: number;
|
private _deferredCnt: number;
|
||||||
private _allowedEventTypes: { [eventType: string]: boolean; };
|
private _allowedEventTypes: { [eventType: string]: boolean; } | null;
|
||||||
|
|
||||||
constructor(allowedEventTypes: string[] = null) {
|
constructor(allowedEventTypes?: string[]) {
|
||||||
this._listeners = {};
|
this._listeners = {};
|
||||||
this._bulkListeners = [];
|
this._bulkListeners = [];
|
||||||
this._collectedEvents = [];
|
this._collectedEvents = [];
|
||||||
@@ -86,7 +86,8 @@ export class EventEmitter implements IEventEmitter {
|
|||||||
this._listeners[eventType] = [listener];
|
this._listeners[eventType] = [listener];
|
||||||
}
|
}
|
||||||
|
|
||||||
let bound = this;
|
let bound: this | null = this;
|
||||||
|
let _listener: ListenerCallback | null = listener;
|
||||||
return {
|
return {
|
||||||
dispose: () => {
|
dispose: () => {
|
||||||
if (!bound) {
|
if (!bound) {
|
||||||
@@ -94,11 +95,11 @@ export class EventEmitter implements IEventEmitter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bound._removeListener(eventType, listener);
|
bound._removeListener(eventType, _listener!);
|
||||||
|
|
||||||
// Prevent leakers from holding on to the event emitter
|
// Prevent leakers from holding on to the event emitter
|
||||||
bound = null;
|
bound = null;
|
||||||
listener = null;
|
_listener = null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -212,10 +213,10 @@ export class EventEmitter implements IEventEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public deferredEmit<T>(callback: () => T): T {
|
public deferredEmit<T>(callback: () => T): T | undefined {
|
||||||
this.beginDeferredEmit();
|
this.beginDeferredEmit();
|
||||||
|
|
||||||
let result: T = safeInvokeNoArg<T>(callback);
|
let result: T | undefined = safeInvokeNoArg<T>(callback);
|
||||||
|
|
||||||
this.endDeferredEmit();
|
this.endDeferredEmit();
|
||||||
|
|
||||||
@@ -251,7 +252,7 @@ export class OrderGuaranteeEventEmitter extends EventEmitter {
|
|||||||
private _emitQueue: EmitQueueElement[];
|
private _emitQueue: EmitQueueElement[];
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super(null);
|
super();
|
||||||
this._emitQueue = [];
|
this._emitQueue = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,12 +277,14 @@ export class OrderGuaranteeEventEmitter extends EventEmitter {
|
|||||||
|
|
||||||
while (this._emitQueue.length > 0) {
|
while (this._emitQueue.length > 0) {
|
||||||
let queueElement = this._emitQueue.shift();
|
let queueElement = this._emitQueue.shift();
|
||||||
safeInvoke1Arg(queueElement.target, queueElement.arg);
|
if (queueElement) {
|
||||||
|
safeInvoke1Arg(queueElement.target, queueElement.arg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function safeInvokeNoArg<T>(func: Function): T {
|
function safeInvokeNoArg<T>(func: Function): T | undefined {
|
||||||
try {
|
try {
|
||||||
return func();
|
return func();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -5,113 +5,6 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// --- trie'ish datastructure
|
|
||||||
|
|
||||||
class Node<E> {
|
|
||||||
element?: E;
|
|
||||||
readonly children = new Map<string, Node<E>>();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A trie map that allows for fast look up when keys are substrings
|
|
||||||
* to the actual search keys (dir/subdir-problem).
|
|
||||||
*/
|
|
||||||
export class TrieMap<E> {
|
|
||||||
|
|
||||||
static PathSplitter = (s: string) => s.split(/[\\/]/).filter(s => !!s);
|
|
||||||
|
|
||||||
private readonly _splitter: (s: string) => string[];
|
|
||||||
private _root = new Node<E>();
|
|
||||||
|
|
||||||
constructor(splitter: (s: string) => string[] = TrieMap.PathSplitter) {
|
|
||||||
this._splitter = s => splitter(s).filter(s => Boolean(s));
|
|
||||||
}
|
|
||||||
|
|
||||||
insert(path: string, element: E): void {
|
|
||||||
const parts = this._splitter(path);
|
|
||||||
let i = 0;
|
|
||||||
|
|
||||||
// find insertion node
|
|
||||||
let node = this._root;
|
|
||||||
for (; i < parts.length; i++) {
|
|
||||||
let child = node.children.get(parts[i]);
|
|
||||||
if (child) {
|
|
||||||
node = child;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// create new nodes
|
|
||||||
let newNode: Node<E>;
|
|
||||||
for (; i < parts.length; i++) {
|
|
||||||
newNode = new Node<E>();
|
|
||||||
node.children.set(parts[i], newNode);
|
|
||||||
node = newNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
node.element = element;
|
|
||||||
}
|
|
||||||
|
|
||||||
lookUp(path: string): E {
|
|
||||||
const parts = this._splitter(path);
|
|
||||||
|
|
||||||
let { children } = this._root;
|
|
||||||
let node: Node<E>;
|
|
||||||
for (const part of parts) {
|
|
||||||
node = children.get(part);
|
|
||||||
if (!node) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
children = node.children;
|
|
||||||
}
|
|
||||||
|
|
||||||
return node.element;
|
|
||||||
}
|
|
||||||
|
|
||||||
findSubstr(path: string): E {
|
|
||||||
const parts = this._splitter(path);
|
|
||||||
|
|
||||||
let lastNode: Node<E>;
|
|
||||||
let { children } = this._root;
|
|
||||||
for (const part of parts) {
|
|
||||||
const node = children.get(part);
|
|
||||||
if (!node) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (node.element) {
|
|
||||||
lastNode = node;
|
|
||||||
}
|
|
||||||
children = node.children;
|
|
||||||
}
|
|
||||||
|
|
||||||
// return the last matching node
|
|
||||||
// that had an element
|
|
||||||
if (lastNode) {
|
|
||||||
return lastNode.element;
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
findSuperstr(path: string): TrieMap<E> {
|
|
||||||
const parts = this._splitter(path);
|
|
||||||
|
|
||||||
let { children } = this._root;
|
|
||||||
let node: Node<E>;
|
|
||||||
for (const part of parts) {
|
|
||||||
node = children.get(part);
|
|
||||||
if (!node) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
children = node.children;
|
|
||||||
}
|
|
||||||
|
|
||||||
const result = new TrieMap<E>(this._splitter);
|
|
||||||
result._root = node;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function toObject<V>(map: Map<string, V>): { [key: string]: V } {
|
export function toObject<V>(map: Map<string, V>): { [key: string]: V } {
|
||||||
if (map) {
|
if (map) {
|
||||||
let rt: { [key: string]: V } = Object.create(null);
|
let rt: { [key: string]: V } = Object.create(null);
|
||||||
|
|||||||
@@ -270,7 +270,7 @@ export class BackupComponent {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Set backup path list
|
// Set backup path list
|
||||||
this.pathListBox = new ListBox([], '', this.contextViewService, this.clipboardService);
|
this.pathListBox = new ListBox([], this.contextViewService, this.clipboardService);
|
||||||
this.pathListBox.render(this.pathElement.nativeElement);
|
this.pathListBox.render(this.pathElement.nativeElement);
|
||||||
|
|
||||||
// Set backup path add/remove buttons
|
// Set backup path add/remove buttons
|
||||||
@@ -916,4 +916,4 @@ export class BackupComponent {
|
|||||||
|
|
||||||
return backupInfo;
|
return backupInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ export class RestoreDialog extends Modal {
|
|||||||
inputContainer.div({ class: 'dialog-input' }, (inputCellContainer) => {
|
inputContainer.div({ class: 'dialog-input' }, (inputCellContainer) => {
|
||||||
// Get the bootstrap params and perform the bootstrap
|
// Get the bootstrap params and perform the bootstrap
|
||||||
inputCellContainer.style('width', '100%');
|
inputCellContainer.style('width', '100%');
|
||||||
this._databaseDropdown = new Dropdown(inputCellContainer.getHTMLElement(), this._contextViewService, this._themeService,
|
this._databaseDropdown = new Dropdown(inputCellContainer.getHTMLElement(), this._contextViewService,
|
||||||
{
|
{
|
||||||
strictSelection: false,
|
strictSelection: false,
|
||||||
ariaLabel: LocalizedStrings.TARGETDATABASE,
|
ariaLabel: LocalizedStrings.TARGETDATABASE,
|
||||||
@@ -919,4 +919,4 @@ export class RestoreDialog extends Modal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ export default class DropDownComponent extends ComponentBase implements ICompone
|
|||||||
ariaLabel: '',
|
ariaLabel: '',
|
||||||
actionLabel: ''
|
actionLabel: ''
|
||||||
};
|
};
|
||||||
this._editableDropdown = new Dropdown(this._editableDropDownContainer.nativeElement, this.contextViewService, this.themeService,
|
this._editableDropdown = new Dropdown(this._editableDropDownContainer.nativeElement, this.contextViewService,
|
||||||
dropdownOptions);
|
dropdownOptions);
|
||||||
|
|
||||||
this._register(this._editableDropdown);
|
this._register(this._editableDropdown);
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Component, Input, Inject, ChangeDetectorRef, forwardRef, ComponentFactoryResolver,
|
Component, Input, Inject, ChangeDetectorRef, forwardRef,
|
||||||
ViewChild, ViewChildren, ElementRef, Injector, OnDestroy, QueryList, AfterViewInit
|
ViewChild, ElementRef, OnDestroy, AfterViewInit
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
|
|
||||||
import * as azdata from 'azdata';
|
import * as azdata from 'azdata';
|
||||||
@@ -17,8 +17,6 @@ import { ListBox } from 'sql/base/browser/ui/listBox/listBox';
|
|||||||
import { attachListBoxStyler } from 'sql/platform/theme/common/styler';
|
import { attachListBoxStyler } from 'sql/platform/theme/common/styler';
|
||||||
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
|
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
|
||||||
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
||||||
import { Emitter } from 'vs/base/common/event';
|
|
||||||
import * as nls from 'vs/nls';
|
|
||||||
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -50,7 +48,7 @@ export default class ListBoxComponent extends ComponentBase implements IComponen
|
|||||||
|
|
||||||
ngAfterViewInit(): void {
|
ngAfterViewInit(): void {
|
||||||
if (this._inputContainer) {
|
if (this._inputContainer) {
|
||||||
this._input = new ListBox([], undefined, this.contextViewService, this.clipboardService);
|
this._input = new ListBox([], this.contextViewService, this.clipboardService);
|
||||||
this._input.render(this._inputContainer.nativeElement);
|
this._input.render(this._inputContainer.nativeElement);
|
||||||
|
|
||||||
this._register(this._input);
|
this._register(this._input);
|
||||||
|
|||||||
@@ -529,7 +529,7 @@ export class QueryEditor extends BaseEditor {
|
|||||||
*/
|
*/
|
||||||
public get listDatabasesActionItem(): ListDatabasesActionItem {
|
public get listDatabasesActionItem(): ListDatabasesActionItem {
|
||||||
if (!this._listDatabasesActionItem) {
|
if (!this._listDatabasesActionItem) {
|
||||||
this._listDatabasesActionItem = this._instantiationService.createInstance(ListDatabasesActionItem, this, this._listDatabasesAction);
|
this._listDatabasesActionItem = this._instantiationService.createInstance(ListDatabasesActionItem, this);
|
||||||
this._register(this._listDatabasesActionItem.attachStyler(this.themeService));
|
this._register(this._listDatabasesActionItem.attachStyler(this.themeService));
|
||||||
}
|
}
|
||||||
return this._listDatabasesActionItem;
|
return this._listDatabasesActionItem;
|
||||||
|
|||||||
@@ -446,11 +446,9 @@ export class ListDatabasesActionItem extends EventEmitter implements IActionItem
|
|||||||
// CONSTRUCTOR /////////////////////////////////////////////////////////
|
// CONSTRUCTOR /////////////////////////////////////////////////////////
|
||||||
constructor(
|
constructor(
|
||||||
private _editor: QueryEditor,
|
private _editor: QueryEditor,
|
||||||
private _action: ListDatabasesAction,
|
|
||||||
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService,
|
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService,
|
||||||
@INotificationService private _notificationService: INotificationService,
|
@INotificationService private _notificationService: INotificationService,
|
||||||
@IContextViewService contextViewProvider: IContextViewService,
|
@IContextViewService contextViewProvider: IContextViewService,
|
||||||
@IThemeService themeService: IThemeService,
|
|
||||||
@IConfigurationService private readonly _configurationService: IConfigurationService
|
@IConfigurationService private readonly _configurationService: IConfigurationService
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
@@ -465,7 +463,7 @@ export class ListDatabasesActionItem extends EventEmitter implements IActionItem
|
|||||||
this._databaseSelectBox.disable();
|
this._databaseSelectBox.disable();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this._dropdown = new Dropdown(this.$databaseListDropdown.getHTMLElement(), contextViewProvider, themeService, {
|
this._dropdown = new Dropdown(this.$databaseListDropdown.getHTMLElement(), contextViewProvider, {
|
||||||
strictSelection: true,
|
strictSelection: true,
|
||||||
placeholder: this._selectDatabaseString,
|
placeholder: this._selectDatabaseString,
|
||||||
ariaLabel: this._selectDatabaseString,
|
ariaLabel: this._selectDatabaseString,
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ export class AccountPicker extends Disposable {
|
|||||||
addAccountAction.addAccountErrorEvent((msg) => this._addAccountErrorEmitter.fire(msg));
|
addAccountAction.addAccountErrorEvent((msg) => this._addAccountErrorEmitter.fire(msg));
|
||||||
addAccountAction.addAccountStartEvent(() => this._addAccountStartEmitter.fire());
|
addAccountAction.addAccountStartEvent(() => this._addAccountStartEmitter.fire());
|
||||||
|
|
||||||
this._dropdown = this._register(new DropdownList(this._rootElement, option, this._listContainer, this._accountList, this._themeService, addAccountAction));
|
this._dropdown = this._register(new DropdownList(this._rootElement, option, this._listContainer, this._accountList, addAccountAction));
|
||||||
this._register(attachDropdownStyler(this._dropdown, this._themeService));
|
this._register(attachDropdownStyler(this._dropdown, this._themeService));
|
||||||
this._register(this._accountList.onSelectionChange((e: IListEvent<azdata.Account>) => {
|
this._register(this._accountList.onSelectionChange((e: IListEvent<azdata.Account>) => {
|
||||||
if (e.elements.length === 1) {
|
if (e.elements.length === 1) {
|
||||||
@@ -235,4 +235,4 @@ export class AccountPicker extends Disposable {
|
|||||||
this._refreshContainer.style.color = link;
|
this._refreshContainer.style.color = link;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,11 +33,20 @@ export function attachDropdownStyler(widget: IThemable, themeService: IThemeServ
|
|||||||
backgroundColor?: cr.ColorIdentifier,
|
backgroundColor?: cr.ColorIdentifier,
|
||||||
foregroundColor?: cr.ColorIdentifier,
|
foregroundColor?: cr.ColorIdentifier,
|
||||||
borderColor?: cr.ColorIdentifier,
|
borderColor?: cr.ColorIdentifier,
|
||||||
|
buttonForeground?: cr.ColorIdentifier,
|
||||||
|
buttonBackground?: cr.ColorIdentifier,
|
||||||
|
buttonHoverBackground?: cr.ColorIdentifier,
|
||||||
|
buttonFocusOutline?: cr.ColorIdentifier
|
||||||
}): IDisposable {
|
}): IDisposable {
|
||||||
return attachStyler(themeService, {
|
return attachStyler(themeService, {
|
||||||
foregroundColor: (style && style.foregroundColor) || cr.inputForeground,
|
foregroundColor: (style && style.foregroundColor) || cr.inputForeground,
|
||||||
borderColor: (style && style.borderColor) || cr.inputBorder,
|
borderColor: (style && style.borderColor) || cr.inputBorder,
|
||||||
backgroundColor: (style && style.backgroundColor) || cr.editorBackground
|
backgroundColor: (style && style.backgroundColor) || cr.editorBackground,
|
||||||
|
buttonForeground: (style && style.buttonForeground) || cr.buttonForeground,
|
||||||
|
buttonBackground: (style && style.buttonBackground) || cr.buttonBackground,
|
||||||
|
buttonHoverBackground: (style && style.buttonHoverBackground) || cr.buttonHoverBackground,
|
||||||
|
buttonBorder: cr.contrastBorder,
|
||||||
|
buttonFocusOutline: (style && style.buttonFocusOutline) || sqlcolors.buttonFocusOutline
|
||||||
}, widget);
|
}, widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,12 +5,10 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import * as extHostApi from 'vs/workbench/api/node/extHost.api.impl';
|
import * as extHostApi from 'vs/workbench/api/node/extHost.api.impl';
|
||||||
import { TrieMap } from 'sql/base/common/map';
|
|
||||||
import { TPromise } from 'vs/base/common/winjs.base';
|
import { TPromise } from 'vs/base/common/winjs.base';
|
||||||
import { IInitData, IExtHostContext, IMainContext } from 'vs/workbench/api/node/extHost.protocol';
|
import { IInitData, IMainContext } from 'vs/workbench/api/node/extHost.protocol';
|
||||||
import { ExtHostExtensionService } from 'vs/workbench/api/node/extHostExtensionService';
|
import { ExtHostExtensionService } from 'vs/workbench/api/node/extHostExtensionService';
|
||||||
import { IExtensionDescription } from 'vs/workbench/services/extensions/common/extensions';
|
import { IExtensionDescription } from 'vs/workbench/services/extensions/common/extensions';
|
||||||
import { realpath } from 'fs';
|
|
||||||
import * as extHostTypes from 'vs/workbench/api/node/extHostTypes';
|
import * as extHostTypes from 'vs/workbench/api/node/extHostTypes';
|
||||||
import { URI } from 'vs/base/common/uri';
|
import { URI } from 'vs/base/common/uri';
|
||||||
|
|
||||||
@@ -43,6 +41,7 @@ import { ExtHostNotebookDocumentsAndEditors } from 'sql/workbench/api/node/extHo
|
|||||||
import { ExtHostStorage } from 'vs/workbench/api/node/extHostStorage';
|
import { ExtHostStorage } from 'vs/workbench/api/node/extHostStorage';
|
||||||
import { ExtensionDescriptionRegistry } from 'vs/workbench/services/extensions/node/extensionDescriptionRegistry';
|
import { ExtensionDescriptionRegistry } from 'vs/workbench/services/extensions/node/extensionDescriptionRegistry';
|
||||||
import { ExtHostExtensionManagement } from 'sql/workbench/api/node/extHostExtensionManagement';
|
import { ExtHostExtensionManagement } from 'sql/workbench/api/node/extHostExtensionManagement';
|
||||||
|
import { TernarySearchTree } from 'vs/base/common/map';
|
||||||
|
|
||||||
export interface ISqlExtensionApiFactory {
|
export interface ISqlExtensionApiFactory {
|
||||||
vsCodeFactory(extension: IExtensionDescription, registry: ExtensionDescriptionRegistry): typeof vscode;
|
vsCodeFactory(extension: IExtensionDescription, registry: ExtensionDescriptionRegistry): typeof vscode;
|
||||||
@@ -995,33 +994,10 @@ export function createApiFactory(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function initializeExtensionApi(extensionService: ExtHostExtensionService, apiFactory: ISqlExtensionApiFactory, extensionRegistry: ExtensionDescriptionRegistry): TPromise<void> {
|
export function initializeExtensionApi(extensionService: ExtHostExtensionService, apiFactory: ISqlExtensionApiFactory, extensionRegistry: ExtensionDescriptionRegistry): TPromise<void> {
|
||||||
return createExtensionPathIndex(extensionService, extensionRegistry).then(trie => defineAPI(apiFactory, trie, extensionRegistry));
|
return extensionService.getExtensionPathIndex().then(trie => defineAPI(apiFactory, trie, extensionRegistry));
|
||||||
}
|
}
|
||||||
|
|
||||||
function createExtensionPathIndex(extensionService: ExtHostExtensionService, extensionRegistry: ExtensionDescriptionRegistry): Promise<TrieMap<IExtensionDescription>> {
|
function defineAPI(factory: ISqlExtensionApiFactory, extensionPaths: TernarySearchTree<IExtensionDescription>, extensionRegistry: ExtensionDescriptionRegistry): void {
|
||||||
|
|
||||||
// create trie to enable fast 'filename -> extension id' look up
|
|
||||||
const trie = new TrieMap<IExtensionDescription>(TrieMap.PathSplitter);
|
|
||||||
const extensions = extensionRegistry.getAllExtensionDescriptions().map(ext => {
|
|
||||||
if (!ext.main) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
realpath(ext.extensionLocation.fsPath, (err, path) => {
|
|
||||||
if (err) {
|
|
||||||
reject(err);
|
|
||||||
} else {
|
|
||||||
trie.insert(path, ext);
|
|
||||||
resolve(void 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return Promise.all(extensions).then(() => trie);
|
|
||||||
}
|
|
||||||
|
|
||||||
function defineAPI(factory: ISqlExtensionApiFactory, extensionPaths: TrieMap<IExtensionDescription>, extensionRegistry: ExtensionDescriptionRegistry): void {
|
|
||||||
type ApiImpl = typeof vscode | typeof azdata | typeof sqlops;
|
type ApiImpl = typeof vscode | typeof azdata | typeof sqlops;
|
||||||
|
|
||||||
// each extension is meant to get its own api implementation
|
// each extension is meant to get its own api implementation
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ export class ConnectionWidget {
|
|||||||
let databaseOption = this._optionsMaps[ConnectionOptionSpecialType.databaseName];
|
let databaseOption = this._optionsMaps[ConnectionOptionSpecialType.databaseName];
|
||||||
let databaseNameBuilder = DialogHelper.appendRow(this._tableContainer, databaseOption.displayName, 'connection-label', 'connection-input');
|
let databaseNameBuilder = DialogHelper.appendRow(this._tableContainer, databaseOption.displayName, 'connection-label', 'connection-input');
|
||||||
|
|
||||||
this._databaseNameInputBox = new Dropdown(databaseNameBuilder.getHTMLElement(), this._contextViewService, this._themeService, {
|
this._databaseNameInputBox = new Dropdown(databaseNameBuilder.getHTMLElement(), this._contextViewService, {
|
||||||
values: [this._defaultDatabaseName, this._loadingDatabaseName],
|
values: [this._defaultDatabaseName, this._loadingDatabaseName],
|
||||||
strictSelection: false,
|
strictSelection: false,
|
||||||
placeholder: this._defaultDatabaseName,
|
placeholder: this._defaultDatabaseName,
|
||||||
@@ -832,4 +832,4 @@ enum AuthenticationType {
|
|||||||
SqlLogin = 'SqlLogin',
|
SqlLogin = 'SqlLogin',
|
||||||
Integrated = 'Integrated',
|
Integrated = 'Integrated',
|
||||||
AzureMFA = 'AzureMFA'
|
AzureMFA = 'AzureMFA'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -477,7 +477,7 @@ suite('SQL QueryAction Tests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// If I query without having initialized anything, state should be clear
|
// If I query without having initialized anything, state should be clear
|
||||||
listItem = new ListDatabasesActionItem(editor.object, undefined, connectionManagementService.object, undefined, undefined, undefined, configurationService.object);
|
listItem = new ListDatabasesActionItem(editor.object, connectionManagementService.object, undefined, undefined, configurationService.object);
|
||||||
|
|
||||||
assert.equal(listItem.isEnabled(), false, 'do not expect dropdown enabled unless connected');
|
assert.equal(listItem.isEnabled(), false, 'do not expect dropdown enabled unless connected');
|
||||||
assert.equal(listItem.currentDatabaseName, undefined, 'do not expect dropdown to have entries unless connected');
|
assert.equal(listItem.currentDatabaseName, undefined, 'do not expect dropdown to have entries unless connected');
|
||||||
@@ -512,7 +512,7 @@ suite('SQL QueryAction Tests', () => {
|
|||||||
cms.setup(x => x.getConnectionProfile(TypeMoq.It.isAny())).returns(() => <IConnectionProfile>{ databaseName: databaseName });
|
cms.setup(x => x.getConnectionProfile(TypeMoq.It.isAny())).returns(() => <IConnectionProfile>{ databaseName: databaseName });
|
||||||
|
|
||||||
// ... Create a database dropdown that has been connected
|
// ... Create a database dropdown that has been connected
|
||||||
let listItem = new ListDatabasesActionItem(editor.object, undefined, cms.object, null, null, null, configurationService.object);
|
let listItem = new ListDatabasesActionItem(editor.object, cms.object, null, null, configurationService.object);
|
||||||
listItem.onConnected();
|
listItem.onConnected();
|
||||||
|
|
||||||
// If: I raise a connection changed event
|
// If: I raise a connection changed event
|
||||||
@@ -536,7 +536,7 @@ suite('SQL QueryAction Tests', () => {
|
|||||||
cms.setup(x => x.getConnectionProfile(TypeMoq.It.isAny())).returns(() => <IConnectionProfile>{ databaseName: databaseName });
|
cms.setup(x => x.getConnectionProfile(TypeMoq.It.isAny())).returns(() => <IConnectionProfile>{ databaseName: databaseName });
|
||||||
|
|
||||||
// ... Create a database dropdown that has been connected
|
// ... Create a database dropdown that has been connected
|
||||||
let listItem = new ListDatabasesActionItem(editor.object, undefined, cms.object, null, null, null, configurationService.object);
|
let listItem = new ListDatabasesActionItem(editor.object, cms.object, null, null, configurationService.object);
|
||||||
listItem.onConnected();
|
listItem.onConnected();
|
||||||
|
|
||||||
// If: I raise a connection changed event for the 'wrong' URI
|
// If: I raise a connection changed event for the 'wrong' URI
|
||||||
@@ -563,7 +563,7 @@ suite('SQL QueryAction Tests', () => {
|
|||||||
cms.setup(x => x.onConnectionChanged).returns(() => dbChangedEmitter.event);
|
cms.setup(x => x.onConnectionChanged).returns(() => dbChangedEmitter.event);
|
||||||
|
|
||||||
// ... Create a database dropdown
|
// ... Create a database dropdown
|
||||||
let listItem = new ListDatabasesActionItem(editor.object, undefined, cms.object, null, null, null, configurationService.object);
|
let listItem = new ListDatabasesActionItem(editor.object, cms.object, null, null, configurationService.object);
|
||||||
|
|
||||||
// If: I raise a connection changed event
|
// If: I raise a connection changed event
|
||||||
let eventParams = <IConnectionParams>{
|
let eventParams = <IConnectionParams>{
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ suite('SQL QueryEditor Tests', () => {
|
|||||||
instantiationService.setup(x => x.createInstance(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns((classDef, editor, action) => {
|
instantiationService.setup(x => x.createInstance(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns((classDef, editor, action) => {
|
||||||
if (classDef.ID) {
|
if (classDef.ID) {
|
||||||
if (classDef.ID === 'listDatabaseQueryActionItem') {
|
if (classDef.ID === 'listDatabaseQueryActionItem') {
|
||||||
return new ListDatabasesActionItem(editor, action, connectionManagementService.object, undefined, undefined, undefined, configurationService.object);
|
return new ListDatabasesActionItem(editor, connectionManagementService.object, undefined, undefined, configurationService.object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Default
|
// Default
|
||||||
@@ -351,7 +351,7 @@ suite('SQL QueryEditor Tests', () => {
|
|||||||
queryActionInstantiationService.setup(x => x.createInstance(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny()))
|
queryActionInstantiationService.setup(x => x.createInstance(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny()))
|
||||||
.returns((definition, editor, action, selectBox) => {
|
.returns((definition, editor, action, selectBox) => {
|
||||||
if (definition.ID === 'listDatabaseQueryActionItem') {
|
if (definition.ID === 'listDatabaseQueryActionItem') {
|
||||||
let item = new ListDatabasesActionItem(editor, action, queryConnectionService.object, undefined, undefined, undefined, configurationService.object);
|
let item = new ListDatabasesActionItem(editor, queryConnectionService.object, undefined, undefined, configurationService.object);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
// Default
|
// Default
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user