mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-20 09:35:38 -05:00
Strict Null Checks, Builder Removal, Formatting (#4849)
* remove builder; more null checks * null checks * formatting * wip * fix dropdown themeing * formatting * formatting * fix tests * update what files are checked * add code to help refresh bad nodes
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
* 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/media/icons/common-icons';
|
||||
import 'vs/css!./media/breadcrumb';
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
import { Button as vsButton, IButtonOptions, IButtonStyles as vsIButtonStyles } from 'vs/base/browser/ui/button/button';
|
||||
import * as DOM from 'vs/base/browser/dom';
|
||||
import { Color } from 'vs/base/common/color';
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import {
|
||||
Component, Inject, forwardRef, ElementRef, OnInit, Input,
|
||||
Output, OnChanges, SimpleChanges, EventEmitter
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
import 'vs/css!./media/dropdownList';
|
||||
import * as DOM from 'vs/base/browser/dom';
|
||||
import { Dropdown, IDropdownOptions } from 'vs/base/browser/ui/dropdown/dropdown';
|
||||
|
||||
@@ -10,7 +10,6 @@ import { DropdownDataSource, DropdownFilter, DropdownModel, DropdownRenderer, Dr
|
||||
|
||||
import { IContextViewProvider, ContextView } from 'vs/base/browser/ui/contextview/contextview';
|
||||
import { mixin } from 'vs/base/common/objects';
|
||||
import { Builder, $ } from 'sql/base/browser/builder';
|
||||
import { InputBox, IInputBoxStyles } from 'sql/base/browser/ui/inputBox/inputBox';
|
||||
import { IMessage, MessageType } from 'vs/base/browser/ui/inputbox/inputBox';
|
||||
import { IListStyles } from 'vs/base/browser/ui/list/listWidget';
|
||||
@@ -22,6 +21,7 @@ import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { KeyCode } from 'vs/base/common/keyCodes';
|
||||
import { Tree } from 'vs/base/parts/tree/browser/treeImpl';
|
||||
import { ILayoutService } from 'vs/platform/layout/browser/layoutService';
|
||||
|
||||
export interface IDropdownOptions extends IDropdownStyles {
|
||||
/**
|
||||
@@ -74,9 +74,9 @@ const defaults: IDropdownOptions = {
|
||||
};
|
||||
|
||||
export class Dropdown extends Disposable {
|
||||
private $el: Builder;
|
||||
private $input: Builder;
|
||||
private $treeContainer: Builder;
|
||||
private _el: HTMLElement;
|
||||
private _inputContainer: HTMLElement;
|
||||
private _treeContainer: HTMLElement;
|
||||
private _input: InputBox;
|
||||
private _tree: Tree;
|
||||
private _options: IDropdownOptions;
|
||||
@@ -101,16 +101,19 @@ export class Dropdown extends Disposable {
|
||||
constructor(
|
||||
container: HTMLElement,
|
||||
contextViewService: IContextViewProvider,
|
||||
readonly layoutService: ILayoutService,
|
||||
opt?: IDropdownOptions
|
||||
) {
|
||||
super();
|
||||
this._contextView = new ContextView(document.body);
|
||||
this._contextView = new ContextView(layoutService.container);
|
||||
this._options = opt || Object.create(null);
|
||||
mixin(this._options, defaults, false) as IDropdownOptions;
|
||||
this.$el = $('.monaco-dropdown').style('width', '100%').appendTo(container);
|
||||
this._el = DOM.append(container, DOM.$('.monaco-dropdown'));
|
||||
this._el.style.width = '100%';
|
||||
|
||||
this.$input = $('.dropdown-input').style('width', '100%').appendTo(this.$el);
|
||||
this.$treeContainer = $('.dropdown-tree');
|
||||
this._inputContainer = DOM.append(this._el, DOM.$('.dropdown-input'));
|
||||
this._inputContainer.style.width = '100%';
|
||||
this._treeContainer = DOM.$('.dropdown-tree');
|
||||
|
||||
this._toggleAction = new ToggleDropdownAction(() => {
|
||||
this._showList();
|
||||
@@ -118,7 +121,7 @@ export class Dropdown extends Disposable {
|
||||
this._tree.focusFirst();
|
||||
}, this._options.actionLabel);
|
||||
|
||||
this._input = new InputBox(this.$input.getHTMLElement(), contextViewService, {
|
||||
this._input = new InputBox(this._inputContainer, contextViewService, {
|
||||
validationOptions: {
|
||||
// @SQLTODO
|
||||
//showMessage: false,
|
||||
@@ -156,7 +159,7 @@ export class Dropdown extends Disposable {
|
||||
e.stopPropagation();
|
||||
break;
|
||||
case KeyCode.Escape:
|
||||
if (this.$treeContainer.getHTMLElement().parentElement) {
|
||||
if (this._treeContainer.parentElement) {
|
||||
this._input.validate();
|
||||
this._onBlur.fire();
|
||||
this._contextView.hide();
|
||||
@@ -170,7 +173,7 @@ export class Dropdown extends Disposable {
|
||||
e.stopPropagation();
|
||||
break;
|
||||
case KeyCode.DownArrow:
|
||||
if (!this.$treeContainer.getHTMLElement().parentElement) {
|
||||
if (!this._treeContainer.parentElement) {
|
||||
this._showList();
|
||||
}
|
||||
this._tree.domFocus();
|
||||
@@ -181,7 +184,7 @@ export class Dropdown extends Disposable {
|
||||
}
|
||||
}));
|
||||
|
||||
this._tree = new Tree(this.$treeContainer.getHTMLElement(), {
|
||||
this._tree = new Tree(this._treeContainer, {
|
||||
dataSource: this._dataSource,
|
||||
filter: this._filter,
|
||||
renderer: this._renderer,
|
||||
@@ -214,9 +217,6 @@ export class Dropdown extends Disposable {
|
||||
});
|
||||
|
||||
this._register(this._contextView);
|
||||
this._register(this.$el);
|
||||
this._register(this.$input);
|
||||
this._register(this.$treeContainer);
|
||||
this._register(this._tree);
|
||||
this._register(this._input);
|
||||
this._register(this._contextView);
|
||||
@@ -227,14 +227,14 @@ export class Dropdown extends Disposable {
|
||||
this._onFocus.fire();
|
||||
this._filter.filterString = '';
|
||||
this._contextView.show({
|
||||
getAnchor: () => this.$input.getHTMLElement(),
|
||||
getAnchor: () => this._inputContainer,
|
||||
render: container => {
|
||||
this.$treeContainer.appendTo(container);
|
||||
DOM.append(container, this._treeContainer);
|
||||
this._layoutTree();
|
||||
return { dispose: () => { } };
|
||||
},
|
||||
onDOMEvent: (e: any) => {
|
||||
if (!DOM.isAncestor(e.srcElement, this.$el.getHTMLElement()) && !DOM.isAncestor(e.srcElement, this.$treeContainer.getHTMLElement())) {
|
||||
onDOMEvent: e => {
|
||||
if (!DOM.isAncestor((<HTMLElement>e.srcElement), this._el) && !DOM.isAncestor((<HTMLElement>e.srcElement), this._treeContainer)) {
|
||||
this._input.validate();
|
||||
this._onBlur.fire();
|
||||
this._contextView.hide();
|
||||
@@ -254,8 +254,9 @@ export class Dropdown extends Disposable {
|
||||
}
|
||||
}, 0);
|
||||
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._tree.layout(parseInt(this.$treeContainer.style('height')));
|
||||
this._treeContainer.style.height = height + 'px';
|
||||
this._treeContainer.style.width = DOM.getContentWidth(this._inputContainer) - 2 + 'px';
|
||||
this._tree.layout(parseInt(this._treeContainer.style.height));
|
||||
this._tree.refresh();
|
||||
}
|
||||
}
|
||||
@@ -265,8 +266,9 @@ export class Dropdown extends Disposable {
|
||||
this._filter.filterString = '';
|
||||
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;
|
||||
this.$treeContainer.style('height', height + 'px').style('width', DOM.getContentWidth(this.$input.getHTMLElement()) - 2 + 'px');
|
||||
this._tree.layout(parseInt(this.$treeContainer.style('height')));
|
||||
this._treeContainer.style.height = height + 'px';
|
||||
this._treeContainer.style.width = DOM.getContentWidth(this._inputContainer) - 2 + 'px';
|
||||
this._tree.layout(parseInt(this._treeContainer.style.height));
|
||||
this._tree.setInput(new DropdownModel());
|
||||
this._input.validate();
|
||||
}
|
||||
@@ -292,10 +294,8 @@ export class Dropdown extends Disposable {
|
||||
style(style: IListStyles & IInputBoxStyles & IDropdownStyles) {
|
||||
this._tree.style(style);
|
||||
this._input.style(style);
|
||||
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.backgroundColor = style.contextBackground ? style.contextBackground.toString() : null;
|
||||
this._treeContainer.style.outline = `1px solid ${style.contextBorder || this._options.contextBorder}`;
|
||||
}
|
||||
|
||||
private _inputValidator(value: string): IMessage | null {
|
||||
|
||||
@@ -9,7 +9,6 @@ import { generateUuid } from 'vs/base/common/uuid';
|
||||
import * as DOM from 'vs/base/browser/dom';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { $ } from 'sql/base/browser/builder';
|
||||
|
||||
export interface Template {
|
||||
label: HTMLElement;
|
||||
@@ -34,9 +33,13 @@ export class DropdownRenderer implements tree.IRenderer {
|
||||
}
|
||||
|
||||
public renderTemplate(tree: tree.ITree, templateId: string, container: HTMLElement): Template {
|
||||
const row = $('div.list-row').style('height', '22px').style('padding-left', '5px').getHTMLElement();
|
||||
const row = DOM.$('div.list-row');
|
||||
row.style.height = '22px';
|
||||
row.style.paddingLeft = '5px';
|
||||
DOM.append(container, row);
|
||||
const label = $('span.label').style('margin', 'auto').style('vertical-align', 'middle').getHTMLElement();
|
||||
const label = DOM.$('span.label');
|
||||
label.style.margin = 'auto';
|
||||
label.style.verticalAlign = 'middle';
|
||||
DOM.append(row, label);
|
||||
|
||||
return { label, row };
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import {
|
||||
Component, Inject, forwardRef, ElementRef, OnInit, Input,
|
||||
Output, OnChanges, SimpleChanges, EventEmitter
|
||||
@@ -12,10 +10,11 @@ import {
|
||||
|
||||
import { Dropdown, IDropdownOptions } from 'sql/base/browser/ui/editableDropdown/dropdown';
|
||||
import { AngularDisposable } from 'sql/base/node/lifecycle';
|
||||
import { attachEditableDropdownStyler } from 'sql/platform/theme/common/styler';
|
||||
|
||||
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { attachEditableDropdownStyler } from 'sql/platform/theme/common/styler';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { ILayoutService } from 'vs/platform/layout/browser/layoutService';
|
||||
|
||||
@Component({
|
||||
selector: 'editable-select-box',
|
||||
@@ -35,7 +34,8 @@ export class EditableDropDown extends AngularDisposable implements OnInit, OnCha
|
||||
constructor(
|
||||
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef,
|
||||
@Inject(IThemeService) private themeService: IThemeService,
|
||||
@Inject(IContextViewService) private contextViewService: IContextViewService
|
||||
@Inject(IContextViewService) private contextViewService: IContextViewService,
|
||||
@Inject(ILayoutService) private layoutService: ILayoutService
|
||||
) {
|
||||
super();
|
||||
}
|
||||
@@ -49,7 +49,7 @@ export class EditableDropDown extends AngularDisposable implements OnInit, OnCha
|
||||
ariaLabel: '',
|
||||
actionLabel: ''
|
||||
};
|
||||
this._selectbox = new Dropdown(this._el.nativeElement, this.contextViewService, dropdownOptions);
|
||||
this._selectbox = new Dropdown(this._el.nativeElement, this.contextViewService, this.layoutService, dropdownOptions);
|
||||
this._selectbox.values = this.options;
|
||||
this._selectbox.value = this.selectedOption;
|
||||
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import {
|
||||
Component, Inject, forwardRef, ElementRef, OnInit, Input,
|
||||
Output, OnChanges, SimpleChanges, EventEmitter
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
import { InputBox as vsInputBox, IInputOptions, IInputBoxStyles as vsIInputBoxStyles, IMessage } from 'vs/base/browser/ui/inputbox/inputBox';
|
||||
import { IContextViewProvider } from 'vs/base/browser/ui/contextview/contextview';
|
||||
import { Color } from 'vs/base/common/color';
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
import { SelectBox, ISelectBoxStyles, ISelectOptionItem } from 'vs/base/browser/ui/selectBox/selectBox';
|
||||
import { Color } from 'vs/base/common/color';
|
||||
import { IMessage, MessageType, defaultOpts } from 'vs/base/browser/ui/inputbox/inputBox';
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* 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!./media/panel';
|
||||
|
||||
import { registerThemingParticipant, ITheme, ICssStyleCollector } from 'vs/platform/theme/common/themeService';
|
||||
@@ -69,4 +70,4 @@ registerThemingParticipant((theme: ITheme, collector: ICssStyleCollector) => {
|
||||
}
|
||||
`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Component, Input, ContentChild, OnDestroy, TemplateRef, ChangeDetectorRef, forwardRef, Inject } from '@angular/core';
|
||||
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
import * as nls from 'vs/nls';
|
||||
|
||||
@@ -25,4 +26,4 @@ export class CloseTabAction extends Action {
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* 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/media/icons/common-icons';
|
||||
import 'vs/css!./tabHeader';
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import 'vs/css!./scrollableSplitview';
|
||||
import { HeightMap, IView as HeightIView, IViewItem as HeightIViewItem } from './heightMap';
|
||||
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import {
|
||||
Component, Inject, forwardRef, ElementRef, OnInit, Input,
|
||||
Output, OnChanges, SimpleChanges, EventEmitter
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
import 'vs/css!./media/selectBox';
|
||||
|
||||
import { SelectBox as vsSelectBox, ISelectBoxStyles as vsISelectBoxStyles, ISelectBoxOptions, ISelectOptionItem } from 'vs/base/browser/ui/selectBox/selectBox';
|
||||
|
||||
@@ -3,11 +3,8 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
import { range } from 'vs/base/common/arrays';
|
||||
|
||||
/**
|
||||
* Implements the various additional navigation keybindings we want out of slickgrid
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as DOM from 'vs/base/browser/dom';
|
||||
import * as Platform from 'vs/base/common/platform';
|
||||
import { StandardWheelEvent, IMouseWheelEvent } from 'vs/base/browser/mouseEvent';
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
export interface IRowNumberColumnOptions {
|
||||
numberOfRows: number;
|
||||
cssClass?: string;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Observer } from 'rxjs/Observer';
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
import 'vs/css!vs/base/browser/ui/actionbar/actionbar';
|
||||
|
||||
import { Builder, $ } from 'sql/base/browser/builder';
|
||||
import { IAction, IActionRunner, ActionRunner } from 'vs/base/common/actions';
|
||||
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
@@ -35,21 +34,22 @@ export class ActionBar extends ActionRunner implements IActionRunner {
|
||||
|
||||
// Items
|
||||
private _items: IActionItem[];
|
||||
private _focusedItem: number;
|
||||
private _focusedItem?: number;
|
||||
private _focusTracker: DOM.IFocusTracker;
|
||||
|
||||
// Elements
|
||||
private _domNode: HTMLElement;
|
||||
private _actionsList: HTMLElement;
|
||||
|
||||
constructor(container: HTMLElement | Builder, options: IActionBarOptions = defaultOptions) {
|
||||
constructor(container: HTMLElement, options: IActionBarOptions = defaultOptions) {
|
||||
super();
|
||||
this._options = options;
|
||||
this._context = options.context;
|
||||
this._toDispose = [];
|
||||
this._actionRunner = this._options.actionRunner;
|
||||
|
||||
if (!this._actionRunner) {
|
||||
if (this._options.actionRunner) {
|
||||
this._actionRunner = this._options.actionRunner;
|
||||
} else {
|
||||
this._actionRunner = new ActionRunner();
|
||||
this._toDispose.push(this._actionRunner);
|
||||
}
|
||||
@@ -71,7 +71,7 @@ export class ActionBar extends ActionRunner implements IActionRunner {
|
||||
this._domNode.className += ' vertical';
|
||||
}
|
||||
|
||||
$(this._domNode).on(DOM.EventType.KEY_DOWN, (e: KeyboardEvent) => {
|
||||
this._register(DOM.addDisposableListener(this._domNode, DOM.EventType.KEY_DOWN, (e: KeyboardEvent) => {
|
||||
let event = new StandardKeyboardEvent(e);
|
||||
let eventHandled = true;
|
||||
|
||||
@@ -91,15 +91,15 @@ export class ActionBar extends ActionRunner implements IActionRunner {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
// Prevent native context menu on actions
|
||||
$(this._domNode).on(DOM.EventType.CONTEXT_MENU, (e: Event) => {
|
||||
this._register(DOM.addDisposableListener(this._domNode, DOM.EventType.CONTEXT_MENU, (e: Event) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
});
|
||||
}));
|
||||
|
||||
$(this._domNode).on(DOM.EventType.KEY_UP, (e: KeyboardEvent) => {
|
||||
this._register(DOM.addDisposableListener(this._domNode, DOM.EventType.KEY_UP, (e: KeyboardEvent) => {
|
||||
let event = new StandardKeyboardEvent(e);
|
||||
|
||||
// Run action on Enter/Space
|
||||
@@ -113,9 +113,9 @@ export class ActionBar extends ActionRunner implements IActionRunner {
|
||||
else if (event.equals(KeyCode.Tab) || event.equals(KeyMod.Shift | KeyCode.Tab)) {
|
||||
this.updateFocusedItem();
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
this._focusTracker = DOM.trackFocus(this._domNode);
|
||||
this._focusTracker = this._register(DOM.trackFocus(this._domNode));
|
||||
this._focusTracker.onDidBlur(() => {
|
||||
if (document.activeElement === this._domNode || !DOM.isAncestor(document.activeElement, this._domNode)) {
|
||||
|
||||
@@ -136,7 +136,7 @@ export class ActionBar extends ActionRunner implements IActionRunner {
|
||||
|
||||
this._domNode.appendChild(this._actionsList);
|
||||
|
||||
((container instanceof Builder) ? container.getHTMLElement() : container).appendChild(this._domNode);
|
||||
container.appendChild(this._domNode);
|
||||
}
|
||||
|
||||
public setAriaLabel(label: string): void {
|
||||
@@ -183,8 +183,8 @@ export class ActionBar extends ActionRunner implements IActionRunner {
|
||||
}
|
||||
}
|
||||
|
||||
public getContainer(): Builder {
|
||||
return $(this._domNode);
|
||||
public getContainer(): HTMLElement {
|
||||
return this._domNode;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -216,7 +216,7 @@ export class ActionBar extends ActionRunner implements IActionRunner {
|
||||
actionItemElement.className = 'action-item';
|
||||
actionItemElement.setAttribute('role', 'presentation');
|
||||
|
||||
let item: IActionItem = null;
|
||||
let item: IActionItem | undefined = undefined;
|
||||
|
||||
if (this._options.actionItemProvider) {
|
||||
item = this._options.actionItemProvider(action);
|
||||
@@ -251,7 +251,7 @@ export class ActionBar extends ActionRunner implements IActionRunner {
|
||||
public clear(): void {
|
||||
// Do not dispose action items if they were provided from outside
|
||||
this._items = this._options.actionItemProvider ? [] : lifecycle.dispose(this._items);
|
||||
$(this._actionsList).empty();
|
||||
DOM.clearNode(this._actionsList);
|
||||
}
|
||||
|
||||
public length(): number {
|
||||
@@ -364,19 +364,12 @@ export class ActionBar extends ActionRunner implements IActionRunner {
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
if (this._items !== null) {
|
||||
lifecycle.dispose(this._items);
|
||||
}
|
||||
this._items = null;
|
||||
|
||||
if (this._focusTracker) {
|
||||
this._focusTracker.dispose();
|
||||
this._focusTracker = null;
|
||||
}
|
||||
lifecycle.dispose(this._items);
|
||||
this._items = [];
|
||||
|
||||
this._toDispose = lifecycle.dispose(this._toDispose);
|
||||
|
||||
this.getContainer().destroy();
|
||||
this._domNode.remove();
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -3,18 +3,14 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import 'vs/css!./media/taskbar';
|
||||
import 'vs/css!./media/icons';
|
||||
import 'vs/css!sql/media/icons/common-icons';
|
||||
|
||||
import { ActionBar } from './actionbar';
|
||||
|
||||
import { Builder, $ } from 'sql/base/browser/builder';
|
||||
import { Action, IActionRunner, IAction } from 'vs/base/common/actions';
|
||||
import { ActionsOrientation } from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
import { IContextMenuProvider } from 'vs/base/browser/ui/dropdown/dropdown';
|
||||
import { IToolBarOptions } from 'vs/base/browser/ui/toolbar/toolbar';
|
||||
|
||||
/**
|
||||
@@ -37,21 +33,19 @@ export interface ITaskbarContent {
|
||||
export class Taskbar {
|
||||
private options: IToolBarOptions;
|
||||
private actionBar: ActionBar;
|
||||
private lookupKeybindings: boolean;
|
||||
|
||||
constructor(container: HTMLElement, contextMenuProvider: IContextMenuProvider, options: IToolBarOptions = { orientation: ActionsOrientation.HORIZONTAL }) {
|
||||
constructor(container: HTMLElement, options: IToolBarOptions = { orientation: ActionsOrientation.HORIZONTAL }) {
|
||||
this.options = options;
|
||||
this.lookupKeybindings = typeof this.options.getKeyBinding === 'function' && typeof this.options.getKeyBinding === 'function';
|
||||
|
||||
let element = document.createElement('div');
|
||||
element.className = 'monaco-toolbar carbon-taskbar';
|
||||
container.appendChild(element);
|
||||
|
||||
this.actionBar = new ActionBar($(element), {
|
||||
this.actionBar = new ActionBar(element, {
|
||||
orientation: options.orientation,
|
||||
ariaLabel: options.ariaLabel,
|
||||
actionItemProvider: (action: Action) => {
|
||||
return options.actionItemProvider ? options.actionItemProvider(action) : null;
|
||||
return options.actionItemProvider ? options.actionItemProvider(action) : undefined;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -98,7 +92,7 @@ export class Taskbar {
|
||||
this.actionBar.context = context;
|
||||
}
|
||||
|
||||
public getContainer(): Builder {
|
||||
public getContainer(): HTMLElement {
|
||||
return this.actionBar.getContainer();
|
||||
}
|
||||
|
||||
@@ -131,8 +125,9 @@ export class Taskbar {
|
||||
}
|
||||
|
||||
private getKeybindingLabel(action: IAction): string {
|
||||
const key = this.lookupKeybindings ? this.options.getKeyBinding(action) : void 0;
|
||||
return key ? key.getLabel() : '';
|
||||
const key = this.options.getKeyBinding ? this.options.getKeyBinding(action) : undefined;
|
||||
const label = key ? key.getLabel() : undefined;
|
||||
return label || '';
|
||||
}
|
||||
|
||||
public addAction(primaryAction: IAction): void {
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Alterable version of the vs memorize function; to unmemoize use unmemoize
|
||||
*/
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
* 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 Errors = require('vs/base/common/errors');
|
||||
import * as errors from 'vs/base/common/errors';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
|
||||
export class EmitterEvent {
|
||||
@@ -288,7 +287,7 @@ function safeInvokeNoArg<T>(func: Function): T | undefined {
|
||||
try {
|
||||
return func();
|
||||
} catch (e) {
|
||||
Errors.onUnexpectedError(e);
|
||||
errors.onUnexpectedError(e);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
@@ -297,6 +296,6 @@ function safeInvoke1Arg(func: Function, arg1: any): any {
|
||||
try {
|
||||
return func(arg1);
|
||||
} catch (e) {
|
||||
Errors.onUnexpectedError(e);
|
||||
errors.onUnexpectedError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
export function log(...args: any[]): void {
|
||||
console.log(`\x1b[90m[main ${new Date().toLocaleTimeString()}]\x1b[0m`, ...args);
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
export function toObject<V>(map: Map<string, V>): { [key: string]: V } {
|
||||
if (map) {
|
||||
let rt: { [key: string]: V } = Object.create(null);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* 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 * as Types from 'vs/base/common/types';
|
||||
|
||||
export function clone<T>(obj: T): T {
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Deferred promise
|
||||
@@ -23,4 +22,4 @@ export class Deferred<T> {
|
||||
then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => TResult | Thenable<TResult> | void): Thenable<TResult> {
|
||||
return this.promise.then(onfulfilled, onrejected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Converts HTML characters inside the string to use entities instead. Makes the string safe from
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
import { OnDestroy } from '@angular/core';
|
||||
import { Subscription } from 'rxjs/Subscription';
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
* 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 { Subscription } from 'rxjs/Subscription';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
@@ -13,4 +12,4 @@ export function toDisposableSubscription(sub: Subscription): IDisposable {
|
||||
sub.unsubscribe();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user