mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-04-05 11:30:29 -04:00
Merge from vscode 011858832762aaff245b2336fb1c38166e7a10fb (#4663)
This commit is contained in:
@@ -9,7 +9,7 @@ import { URI } from 'vs/base/common/uri';
|
||||
import { ITree, IActionProvider } from 'vs/base/parts/tree/browser/tree';
|
||||
import { IconLabel, IIconLabelValueOptions } from 'vs/base/browser/ui/iconLabel/iconLabel';
|
||||
import { IQuickNavigateConfiguration, IModel, IDataSource, IFilter, IAccessiblityProvider, IRenderer, IRunner, Mode, IEntryRunContext } from 'vs/base/parts/quickopen/common/quickOpen';
|
||||
import { Action, IAction, IActionRunner, IActionItem } from 'vs/base/common/actions';
|
||||
import { IAction, IActionRunner } from 'vs/base/common/actions';
|
||||
import { compareAnything } from 'vs/base/common/comparers';
|
||||
import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
import { HighlightedLabel } from 'vs/base/browser/ui/highlightedlabel/highlightedLabel';
|
||||
@@ -291,18 +291,6 @@ class NoActionProvider implements IActionProvider {
|
||||
getActions(tree: ITree, element: any): IAction[] | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
hasSecondaryActions(tree: ITree, element: any): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
getSecondaryActions(tree: ITree, element: any): IAction[] | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
getActionItem(tree: ITree, element: any, action: Action): IActionItem | null {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export interface IQuickOpenEntryTemplateData {
|
||||
|
||||
@@ -9,7 +9,7 @@ import * as Keyboard from 'vs/base/browser/keyboardEvent';
|
||||
import { INavigator } from 'vs/base/common/iterator';
|
||||
import { ScrollbarVisibility } from 'vs/base/common/scrollable';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { IAction, IActionItem } from 'vs/base/common/actions';
|
||||
import { IAction } from 'vs/base/common/actions';
|
||||
import { Color } from 'vs/base/common/color';
|
||||
import { IItemCollapseEvent, IItemExpandEvent } from 'vs/base/parts/tree/browser/treeModel';
|
||||
import { IDragAndDropData } from 'vs/base/browser/dnd';
|
||||
@@ -169,81 +169,21 @@ export interface ITree {
|
||||
*/
|
||||
getHighlight(includeHidden?: boolean): any;
|
||||
|
||||
/**
|
||||
* Returns whether an element is highlighted or not.
|
||||
*/
|
||||
isHighlighted(element: any): boolean;
|
||||
|
||||
/**
|
||||
* Clears the highlight.
|
||||
*/
|
||||
clearHighlight(eventPayload?: any): void;
|
||||
|
||||
/**
|
||||
* Selects an element.
|
||||
*/
|
||||
select(element: any, eventPayload?: any): void;
|
||||
|
||||
/**
|
||||
* Selects a range of elements.
|
||||
*/
|
||||
selectRange(fromElement: any, toElement: any, eventPayload?: any): void;
|
||||
|
||||
/**
|
||||
* Deselects a range of elements.
|
||||
*/
|
||||
deselectRange(fromElement: any, toElement: any, eventPayload?: any): void;
|
||||
|
||||
/**
|
||||
* Selects several elements.
|
||||
*/
|
||||
selectAll(elements: any[], eventPayload?: any): void;
|
||||
|
||||
/**
|
||||
* Deselects an element.
|
||||
*/
|
||||
deselect(element: any, eventPayload?: any): void;
|
||||
|
||||
/**
|
||||
* Deselects several elements.
|
||||
*/
|
||||
deselectAll(elements: any[], eventPayload?: any): void;
|
||||
|
||||
/**
|
||||
* Replaces the current selection with the given elements.
|
||||
*/
|
||||
setSelection(elements: any[], eventPayload?: any): void;
|
||||
|
||||
/**
|
||||
* Toggles the element's selection.
|
||||
*/
|
||||
toggleSelection(element: any, eventPayload?: any): void;
|
||||
|
||||
/**
|
||||
* Returns the currently selected elements.
|
||||
*/
|
||||
getSelection(includeHidden?: boolean): any[];
|
||||
|
||||
/**
|
||||
* Returns whether an element is selected or not.
|
||||
*/
|
||||
isSelected(element: any): boolean;
|
||||
|
||||
/**
|
||||
* Selects the next `count`-nth element, in visible order.
|
||||
*/
|
||||
selectNext(count?: number, clearSelection?: boolean, eventPayload?: any): void;
|
||||
|
||||
/**
|
||||
* Selects the previous `count`-nth element, in visible order.
|
||||
*/
|
||||
selectPrevious(count?: number, clearSelection?: boolean, eventPayload?: any): void;
|
||||
|
||||
/**
|
||||
* Selects the currently selected element's parent.
|
||||
*/
|
||||
selectParent(clearSelection?: boolean, eventPayload?: any): void;
|
||||
|
||||
/**
|
||||
* Clears the selection.
|
||||
*/
|
||||
@@ -254,11 +194,6 @@ export interface ITree {
|
||||
*/
|
||||
setFocus(element?: any, eventPayload?: any): void;
|
||||
|
||||
/**
|
||||
* Returns whether an element is focused or not.
|
||||
*/
|
||||
isFocused(element: any): boolean;
|
||||
|
||||
/**
|
||||
* Returns focused element.
|
||||
*/
|
||||
@@ -316,6 +251,7 @@ export interface ITree {
|
||||
*/
|
||||
clearFocus(eventPayload?: any): void;
|
||||
|
||||
// {{SQL CARBON EDIT}} @todo anthonydresser we need to refactor our code to not need these methods
|
||||
/**
|
||||
* Adds the trait to elements.
|
||||
*/
|
||||
@@ -327,14 +263,15 @@ export interface ITree {
|
||||
removeTraits(trait: string, elements: any[]): void;
|
||||
|
||||
/**
|
||||
* Toggles the element's trait.
|
||||
* Selects an element.
|
||||
*/
|
||||
toggleTrait(trait: string, element: any): void;
|
||||
select(element: any, eventPayload?: any): void;
|
||||
|
||||
/**
|
||||
* Returns whether the element has the trait or not.
|
||||
* Deselects an element.
|
||||
*/
|
||||
hasTrait(trait: string, element: any): boolean;
|
||||
deselect(element: any, eventPayload?: any): void;
|
||||
// {{SQL CARBON EDIT}} END
|
||||
|
||||
/**
|
||||
* Returns a navigator which allows to discover the visible and
|
||||
@@ -582,12 +519,14 @@ export interface IDragOverReaction {
|
||||
autoExpand?: boolean;
|
||||
}
|
||||
|
||||
// {{SQL CARBON EDIT}} @todo anthonydresser refactor to not need this
|
||||
export const DRAG_OVER_REJECT: IDragOverReaction = { accept: false };
|
||||
export const DRAG_OVER_ACCEPT: IDragOverReaction = { accept: true };
|
||||
export const DRAG_OVER_ACCEPT_BUBBLE_UP: IDragOverReaction = { accept: true, bubble: DragOverBubble.BUBBLE_UP };
|
||||
export const DRAG_OVER_ACCEPT_BUBBLE_DOWN = (autoExpand = false) => ({ accept: true, bubble: DragOverBubble.BUBBLE_DOWN, autoExpand });
|
||||
export const DRAG_OVER_ACCEPT_BUBBLE_UP_COPY: IDragOverReaction = { accept: true, bubble: DragOverBubble.BUBBLE_UP, effect: DragOverEffect.COPY };
|
||||
export const DRAG_OVER_ACCEPT_BUBBLE_DOWN_COPY = (autoExpand = false) => ({ accept: true, bubble: DragOverBubble.BUBBLE_DOWN, effect: DragOverEffect.COPY, autoExpand });
|
||||
// {{SQL CARBON EDIT}} END
|
||||
|
||||
export interface IDragAndDrop {
|
||||
|
||||
@@ -635,12 +574,6 @@ export interface IFilter {
|
||||
isVisible(tree: ITree, element: any): boolean;
|
||||
}
|
||||
|
||||
export interface IElementCallback {
|
||||
(tree: ITree, element: any): void;
|
||||
}
|
||||
|
||||
export type ICallback = () => void;
|
||||
|
||||
export interface ISorter {
|
||||
|
||||
/**
|
||||
@@ -730,19 +663,4 @@ export interface IActionProvider {
|
||||
* Returns a promise of an array with the actions of the element that should show up in place right to the element in the tree.
|
||||
*/
|
||||
getActions(tree: ITree | null, element: any): IAction[] | null;
|
||||
|
||||
/**
|
||||
* Returns whether or not the element has secondary actions. These show up once the user has expanded the element's action bar.
|
||||
*/
|
||||
hasSecondaryActions(tree: ITree, element: any): boolean;
|
||||
|
||||
/**
|
||||
* Returns a promise of an array with the secondary actions of the element that should show up once the user has expanded the element's action bar.
|
||||
*/
|
||||
getSecondaryActions(tree: ITree, element: any): IAction[] | null;
|
||||
|
||||
/**
|
||||
* Returns an action item to render an action.
|
||||
*/
|
||||
getActionItem(tree: ITree, element: any, action: IAction): IActionItem | null;
|
||||
}
|
||||
|
||||
@@ -230,50 +230,14 @@ export class Tree implements _.ITree {
|
||||
return this.model.getHighlight();
|
||||
}
|
||||
|
||||
public isHighlighted(element: any): boolean {
|
||||
return this.model.isFocused(element);
|
||||
}
|
||||
|
||||
public clearHighlight(eventPayload?: any): void {
|
||||
this.model.setHighlight(null, eventPayload);
|
||||
}
|
||||
|
||||
public select(element: any, eventPayload?: any): void {
|
||||
this.model.select(element, eventPayload);
|
||||
}
|
||||
|
||||
public selectRange(fromElement: any, toElement: any, eventPayload?: any): void {
|
||||
this.model.selectRange(fromElement, toElement, eventPayload);
|
||||
}
|
||||
|
||||
public deselectRange(fromElement: any, toElement: any, eventPayload?: any): void {
|
||||
this.model.deselectRange(fromElement, toElement, eventPayload);
|
||||
}
|
||||
|
||||
public selectAll(elements: any[], eventPayload?: any): void {
|
||||
this.model.selectAll(elements, eventPayload);
|
||||
}
|
||||
|
||||
public deselect(element: any, eventPayload?: any): void {
|
||||
this.model.deselect(element, eventPayload);
|
||||
}
|
||||
|
||||
public deselectAll(elements: any[], eventPayload?: any): void {
|
||||
this.model.deselectAll(elements, eventPayload);
|
||||
}
|
||||
|
||||
public setSelection(elements: any[], eventPayload?: any): void {
|
||||
this.model.setSelection(elements, eventPayload);
|
||||
}
|
||||
|
||||
public toggleSelection(element: any, eventPayload?: any): void {
|
||||
this.model.toggleSelection(element, eventPayload);
|
||||
}
|
||||
|
||||
public isSelected(element: any): boolean {
|
||||
return this.model.isSelected(element);
|
||||
}
|
||||
|
||||
public getSelection(): any[] {
|
||||
return this.model.getSelection();
|
||||
}
|
||||
@@ -282,26 +246,10 @@ export class Tree implements _.ITree {
|
||||
this.model.setSelection([], eventPayload);
|
||||
}
|
||||
|
||||
public selectNext(count?: number, clearSelection?: boolean, eventPayload?: any): void {
|
||||
this.model.selectNext(count, clearSelection, eventPayload);
|
||||
}
|
||||
|
||||
public selectPrevious(count?: number, clearSelection?: boolean, eventPayload?: any): void {
|
||||
this.model.selectPrevious(count, clearSelection, eventPayload);
|
||||
}
|
||||
|
||||
public selectParent(clearSelection?: boolean, eventPayload?: any): void {
|
||||
this.model.selectParent(clearSelection, eventPayload);
|
||||
}
|
||||
|
||||
public setFocus(element?: any, eventPayload?: any): void {
|
||||
this.model.setFocus(element, eventPayload);
|
||||
}
|
||||
|
||||
public isFocused(element: any): boolean {
|
||||
return this.model.isFocused(element);
|
||||
}
|
||||
|
||||
public getFocus(): any {
|
||||
return this.model.getFocus();
|
||||
}
|
||||
@@ -346,6 +294,7 @@ export class Tree implements _.ITree {
|
||||
this.model.setFocus(null, eventPayload);
|
||||
}
|
||||
|
||||
// {{SQL CARBON EDIT}} @todo anthonydresser we need to refactor our code to not need these methods
|
||||
public addTraits(trait: string, elements: any[]): void {
|
||||
this.model.addTraits(trait, elements);
|
||||
}
|
||||
@@ -354,14 +303,14 @@ export class Tree implements _.ITree {
|
||||
this.model.removeTraits(trait, elements);
|
||||
}
|
||||
|
||||
public toggleTrait(trait: string, element: any): void {
|
||||
this.model.hasTrait(trait, element) ? this.model.removeTraits(trait, [element])
|
||||
: this.model.addTraits(trait, [element]);
|
||||
public select(element: any, eventPayload?: any): void {
|
||||
this.model.select(element, eventPayload);
|
||||
}
|
||||
|
||||
public hasTrait(trait: string, element: any): boolean {
|
||||
return this.model.hasTrait(trait, element);
|
||||
public deselect(element: any, eventPayload?: any): void {
|
||||
this.model.deselect(element, eventPayload);
|
||||
}
|
||||
// {{SQL CARBON EDIT}} end
|
||||
|
||||
getNavigator(fromElement?: any, subTreeOnly?: boolean): INavigator<any> {
|
||||
return new MappedNavigator(this.model.getNavigator(fromElement, subTreeOnly), i => i && i.getElement());
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
import * as Assert from 'vs/base/common/assert';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { IDisposable, combinedDisposable } from 'vs/base/common/lifecycle';
|
||||
import * as arrays from 'vs/base/common/arrays';
|
||||
import { INavigator } from 'vs/base/common/iterator';
|
||||
import * as _ from './tree';
|
||||
import { Event, Emitter, EventMultiplexer, Relay } from 'vs/base/common/event';
|
||||
@@ -872,42 +871,6 @@ export class TreeNavigator implements INavigator<Item> {
|
||||
}
|
||||
}
|
||||
|
||||
function getRange(one: Item, other: Item): Item[] {
|
||||
let oneHierarchy = one.getHierarchy();
|
||||
let otherHierarchy = other.getHierarchy();
|
||||
let length = arrays.commonPrefixLength(oneHierarchy, otherHierarchy);
|
||||
let item: Item | null = oneHierarchy[length - 1];
|
||||
let nav = item.getNavigator();
|
||||
|
||||
let oneIndex: number | null = null;
|
||||
let otherIndex: number | null = null;
|
||||
|
||||
let index = 0;
|
||||
let result: Item[] = [];
|
||||
|
||||
while (item && (oneIndex === null || otherIndex === null)) {
|
||||
result.push(item);
|
||||
|
||||
if (item === one) {
|
||||
oneIndex = index;
|
||||
}
|
||||
if (item === other) {
|
||||
otherIndex = index;
|
||||
}
|
||||
|
||||
index++;
|
||||
item = nav.next();
|
||||
}
|
||||
|
||||
if (oneIndex === null || otherIndex === null) {
|
||||
return [];
|
||||
}
|
||||
|
||||
let min = Math.min(oneIndex, otherIndex);
|
||||
let max = Math.max(oneIndex, otherIndex);
|
||||
return result.slice(min, max + 1);
|
||||
}
|
||||
|
||||
export interface IBaseEvent {
|
||||
item: Item | null;
|
||||
}
|
||||
@@ -1205,28 +1168,6 @@ export class TreeModel {
|
||||
this.selectAll([element], eventPayload);
|
||||
}
|
||||
|
||||
public selectRange(fromElement: any, toElement: any, eventPayload?: any): void {
|
||||
let fromItem = this.getItem(fromElement);
|
||||
let toItem = this.getItem(toElement);
|
||||
|
||||
if (!fromItem || !toItem) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.selectAll(getRange(fromItem, toItem), eventPayload);
|
||||
}
|
||||
|
||||
public deselectRange(fromElement: any, toElement: any, eventPayload?: any): void {
|
||||
let fromItem = this.getItem(fromElement);
|
||||
let toItem = this.getItem(toElement);
|
||||
|
||||
if (!fromItem || !toItem) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.deselectAll(getRange(fromItem, toItem), eventPayload);
|
||||
}
|
||||
|
||||
public selectAll(elements: any[], eventPayload?: any): void {
|
||||
this.addTraits('selected', elements);
|
||||
let eventData: _.ISelectionEvent = { selection: this.getSelection(), payload: eventPayload };
|
||||
@@ -1249,12 +1190,6 @@ export class TreeModel {
|
||||
this._onDidSelect.fire(eventData);
|
||||
}
|
||||
|
||||
public toggleSelection(element: any, eventPayload?: any): void {
|
||||
this.toggleTrait('selected', element);
|
||||
let eventData: _.ISelectionEvent = { selection: this.getSelection(), payload: eventPayload };
|
||||
this._onDidSelect.fire(eventData);
|
||||
}
|
||||
|
||||
public isSelected(element: any): boolean {
|
||||
let item = this.getItem(element);
|
||||
|
||||
@@ -1324,21 +1259,6 @@ export class TreeModel {
|
||||
}
|
||||
}
|
||||
|
||||
public selectParent(eventPayload?: any, clearSelection: boolean = true): void {
|
||||
let selection = this.getSelection();
|
||||
let item: Item = selection.length > 0 ? selection[0] : this.input;
|
||||
let nav = this.getNavigator(item, false);
|
||||
let parent = nav.parent();
|
||||
|
||||
if (parent) {
|
||||
if (clearSelection) {
|
||||
this.setSelection([parent], eventPayload);
|
||||
} else {
|
||||
this.select(parent, eventPayload);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public setFocus(element?: any, eventPayload?: any): void {
|
||||
this.setTraits('focused', element ? [element] : []);
|
||||
let eventData: _.IFocusEvent = { focus: this.getFocus(), payload: eventPayload };
|
||||
@@ -1513,25 +1433,6 @@ export class TreeModel {
|
||||
}
|
||||
}
|
||||
|
||||
public hasTrait(trait: string, element: any): boolean {
|
||||
const item = this.getItem(element);
|
||||
return !!(item && item.hasTrait(trait));
|
||||
}
|
||||
|
||||
private toggleTrait(trait: string, element: any): void {
|
||||
let item = this.getItem(element);
|
||||
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.hasTrait(trait)) {
|
||||
this.removeTraits(trait, [element]);
|
||||
} else {
|
||||
this.addTraits(trait, [element]);
|
||||
}
|
||||
}
|
||||
|
||||
private setTraits(trait: string, elements: any[]): void {
|
||||
if (elements.length === 0) {
|
||||
this.removeTraits(trait, elements);
|
||||
|
||||
@@ -161,19 +161,19 @@ const SAMPLE: any = {
|
||||
};
|
||||
|
||||
class TestDataSource implements _.IDataSource {
|
||||
public getId(tree, element): string {
|
||||
public getId(tree: _.ITree, element: any): string {
|
||||
return element.id;
|
||||
}
|
||||
|
||||
public hasChildren(tree, element): boolean {
|
||||
public hasChildren(tree: _.ITree, element: any): boolean {
|
||||
return !!element.children;
|
||||
}
|
||||
|
||||
public getChildren(tree, element): Promise<any> {
|
||||
public getChildren(tree: _.ITree, element: any): Promise<any> {
|
||||
return Promise.resolve(element.children);
|
||||
}
|
||||
|
||||
public getParent(tree, element): Promise<any> {
|
||||
public getParent(tree: _.ITree, element: any): Promise<any> {
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
}
|
||||
@@ -700,13 +700,13 @@ suite('TreeModel - Expansion', () => {
|
||||
|
||||
class TestFilter implements _.IFilter {
|
||||
|
||||
public fn: (any) => boolean;
|
||||
public fn: (element: any) => boolean;
|
||||
|
||||
constructor() {
|
||||
this.fn = () => true;
|
||||
}
|
||||
|
||||
public isVisible(tree, element): boolean {
|
||||
public isVisible(tree: _.ITree, element: any): boolean {
|
||||
return this.fn(element);
|
||||
}
|
||||
}
|
||||
@@ -1092,39 +1092,39 @@ class DynamicModel implements _.IDataSource {
|
||||
this.promiseFactory = null;
|
||||
}
|
||||
|
||||
public addChild(parent, child): void {
|
||||
public addChild(parent: string, child: string): void {
|
||||
if (!this.data[parent]) {
|
||||
this.data[parent] = [];
|
||||
}
|
||||
this.data[parent].push(child);
|
||||
}
|
||||
|
||||
public removeChild(parent, child): void {
|
||||
public removeChild(parent: string, child: string): void {
|
||||
this.data[parent].splice(this.data[parent].indexOf(child), 1);
|
||||
if (this.data[parent].length === 0) {
|
||||
delete this.data[parent];
|
||||
}
|
||||
}
|
||||
|
||||
public move(element, oldParent, newParent): void {
|
||||
public move(element: string, oldParent: string, newParent: string): void {
|
||||
this.removeChild(oldParent, element);
|
||||
this.addChild(newParent, element);
|
||||
}
|
||||
|
||||
public rename(parent, oldName, newName): void {
|
||||
public rename(parent: string, oldName: string, newName: string): void {
|
||||
this.removeChild(parent, oldName);
|
||||
this.addChild(parent, newName);
|
||||
}
|
||||
|
||||
public getId(tree, element): string {
|
||||
public getId(tree: _.ITree, element: any): string {
|
||||
return element;
|
||||
}
|
||||
|
||||
public hasChildren(tree, element): boolean {
|
||||
public hasChildren(tree: _.ITree, element: any): boolean {
|
||||
return !!this.data[element];
|
||||
}
|
||||
|
||||
public getChildren(tree, element): Promise<any> {
|
||||
public getChildren(tree: _.ITree, element: any): Promise<any> {
|
||||
this._onGetChildren.fire(element);
|
||||
const result = this.promiseFactory ? this.promiseFactory() : Promise.resolve(null);
|
||||
return result.then(() => {
|
||||
@@ -1133,7 +1133,7 @@ class DynamicModel implements _.IDataSource {
|
||||
});
|
||||
}
|
||||
|
||||
public getParent(tree, element): Promise<any> {
|
||||
public getParent(tree: _.ITree, element: any): Promise<any> {
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
}
|
||||
@@ -1395,7 +1395,7 @@ suite('TreeModel - Dynamic data model', () => {
|
||||
assert.equal(getTimes, 2);
|
||||
assert.equal(gotTimes, 1);
|
||||
|
||||
let p2Complete;
|
||||
let p2Complete: () => void;
|
||||
dataModel.promiseFactory = () => { return new Promise((c) => { p2Complete = c; }); };
|
||||
const p2 = model.refresh('father');
|
||||
|
||||
@@ -1412,7 +1412,7 @@ suite('TreeModel - Dynamic data model', () => {
|
||||
assert.equal(getTimes, 3);
|
||||
assert.equal(gotTimes, 2);
|
||||
|
||||
p2Complete();
|
||||
p2Complete!();
|
||||
|
||||
// all good
|
||||
assert.equal(refreshTimes, 5); // (+1) second son request
|
||||
|
||||
@@ -7,7 +7,7 @@ import * as assert from 'assert';
|
||||
import { ArrayIterator } from 'vs/base/common/iterator';
|
||||
import { HeightMap, IViewItem } from 'vs/base/parts/tree/browser/treeViewModel';
|
||||
|
||||
function makeItem(id, height): any {
|
||||
function makeItem(id: any, height: any): any {
|
||||
return {
|
||||
id: id,
|
||||
getHeight: function () { return height; },
|
||||
|
||||
Reference in New Issue
Block a user