diff --git a/src/vs/platform/list/browser/listService.ts b/src/vs/platform/list/browser/listService.ts index 28aa9e8644682ef8683ca6e17bbf79d07cc8605d..20d63d05c2a586bdf4ffc689d79d34ebe59ab6ff 100644 --- a/src/vs/platform/list/browser/listService.ts +++ b/src/vs/platform/list/browser/listService.ts @@ -576,12 +576,12 @@ export interface IResourceResultsNavigationOptions { openOnFocus: boolean; } -export class ObjectTreeResourceNavigator extends Disposable { +export class TreeResourceNavigator2 extends Disposable { private readonly _openResource: Emitter> = new Emitter>(); readonly openResource: Event> = this._openResource.event; - constructor(private tree: WorkbenchObjectTree, private options?: IResourceResultsNavigationOptions) { + constructor(private tree: WorkbenchObjectTree | WorkbenchDataTree, private options?: IResourceResultsNavigationOptions) { super(); this.registerListeners(); @@ -633,79 +633,6 @@ export class ObjectTreeResourceNavigator extends Disposable { } } -export class DataTreeResourceNavigator extends Disposable { - - private readonly _openResource: Emitter = new Emitter(); - readonly openResource: Event = this._openResource.event; - - constructor(private tree: DataTree, private options?: IResourceResultsNavigationOptions) { - super(); - - this.registerListeners(); - } - - private registerListeners(): void { - if (this.options && this.options.openOnFocus) { - this._register(this.tree.onDidChangeFocus(e => this.onFocus(e))); - } - - this._register(this.tree.onDidChangeSelection(e => this.onSelection(e))); - } - - private onFocus({ payload }: any): void { - const element = this.tree.getFocus(); - this.tree.setSelection(element /*, { fromFocus: true }*/); - - const originalEvent: KeyboardEvent | MouseEvent = payload && payload.originalEvent; - const isMouseEvent = payload && payload.origin === 'mouse'; - const isDoubleClick = isMouseEvent && originalEvent && originalEvent.detail === 2; - - const preventOpen = payload && payload.preventOpenOnFocus; - if (!preventOpen && (!isMouseEvent || /*this.tree.openOnSingleClick ||*/ isDoubleClick)) { - this._openResource.fire({ - editorOptions: { - preserveFocus: true, - pinned: false, - revealIfVisible: true - }, - sideBySide: false, - element, - payload - }); - } - } - - private onSelection({ payload }: any): void { - if (payload && payload.fromFocus) { - return; - } - - const originalEvent: KeyboardEvent | MouseEvent = payload && payload.originalEvent; - const isMouseEvent = payload && payload.origin === 'mouse'; - const isDoubleClick = isMouseEvent && originalEvent && originalEvent.detail === 2; - - if (!isMouseEvent || /*this.tree.openOnSingleClick ||*/ isDoubleClick) { - if (isDoubleClick && originalEvent) { - originalEvent.preventDefault(); // focus moves to editor, we need to prevent default - } - - const isFromKeyboard = payload && payload.origin === 'keyboard'; - const sideBySide = (originalEvent && (originalEvent.ctrlKey || originalEvent.metaKey || originalEvent.altKey)); - const preserveFocus = !((isFromKeyboard && (!payload || !payload.preserveFocus)) || isDoubleClick || (payload && payload.focusEditor)); - this._openResource.fire({ - editorOptions: { - preserveFocus, - pinned: isDoubleClick, - revealIfVisible: true - }, - sideBySide, - element: this.tree.getSelection()[0], - payload - }); - } - } -} - export interface IHighlighter { getHighlights(tree: ITree, element: any, pattern: string): FuzzyScore; getHighlightsStorageKey?(element: any): any; diff --git a/src/vs/workbench/parts/debug/browser/loadedScriptsView.ts b/src/vs/workbench/parts/debug/browser/loadedScriptsView.ts index bcdd6f69a2dc198515850db8451a5808b61bd199..22daa011337ab72534acc41cff42c7f42702b121 100644 --- a/src/vs/workbench/parts/debug/browser/loadedScriptsView.ts +++ b/src/vs/workbench/parts/debug/browser/loadedScriptsView.ts @@ -25,12 +25,13 @@ import { ltrim } from 'vs/base/common/strings'; import { RunOnceScheduler } from 'vs/base/common/async'; import { ResourceLabel, IResourceLabel, IResourceLabelOptions } from 'vs/workbench/browser/labels'; import { FileKind } from 'vs/platform/files/common/files'; -import { DataTree, IDataSource } from 'vs/base/browser/ui/tree/dataTree'; +import { IDataSource } from 'vs/base/browser/ui/tree/dataTree'; import { IListVirtualDelegate } from 'vs/base/browser/ui/list/list'; import { ITreeRenderer, ITreeNode } from 'vs/base/browser/ui/tree/tree'; import { IAccessibilityProvider } from 'vs/base/browser/ui/list/listWidget'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; -import { DataTreeResourceNavigator } from 'vs/platform/list/browser/listService'; +import { WorkbenchDataTree, IListService, TreeResourceNavigator2 } from 'vs/platform/list/browser/listService'; +import { IThemeService } from 'vs/platform/theme/common/themeService'; const SMART = true; @@ -357,7 +358,7 @@ export class LoadedScriptsView extends ViewletPanel { private treeContainer: HTMLElement; private loadedScriptsItemType: IContextKey; - private tree: DataTree; + private tree: WorkbenchDataTree; private changeScheduler: RunOnceScheduler; private treeNeedsRefreshOnVisible: boolean; @@ -368,10 +369,12 @@ export class LoadedScriptsView extends ViewletPanel { @IInstantiationService private instantiationService: IInstantiationService, @IConfigurationService configurationService: IConfigurationService, @IEditorService private editorService: IEditorService, - @IContextKeyService contextKeyService: IContextKeyService, + @IContextKeyService private contextKeyService: IContextKeyService, @IWorkspaceContextService private contextService: IWorkspaceContextService, @IEnvironmentService private environmentService: IEnvironmentService, - @IDebugService private debugService: IDebugService + @IDebugService private debugService: IDebugService, + @IListService private listService: IListService, + @IThemeService private themeService: IThemeService ) { super({ ...(options as IViewletPanelOptions), ariaHeaderLabel: nls.localize('loadedScriptsSection', "Loaded Scripts Section") }, keybindingService, contextMenuService, configurationService); this.loadedScriptsItemType = CONTEXT_LOADED_SCRIPTS_ITEM_TYPE.bindTo(contextKeyService); @@ -385,7 +388,7 @@ export class LoadedScriptsView extends ViewletPanel { const root = new RootTreeItem(this.debugService.getModel(), this.environmentService, this.contextService); - this.tree = new DataTree(this.treeContainer, new LoadedScriptsDelegate(), + this.tree = new WorkbenchDataTree(this.treeContainer, new LoadedScriptsDelegate(), [ this.instantiationService.createInstance(LoadedScriptsRenderer) ], @@ -394,7 +397,8 @@ export class LoadedScriptsView extends ViewletPanel { accessibilityProvider: new LoadedSciptsAccessibilityProvider(), ariaLabel: nls.localize({ comment: ['Debug is a noun in this context, not a verb.'], key: 'loadedScriptsAriaLabel' }, "Debug Loaded Scripts"), identityProvider: element => element.getId() - } + }, + this.contextKeyService, this.listService, this.themeService, this.configurationService ); this.changeScheduler = new RunOnceScheduler(() => { @@ -405,7 +409,7 @@ export class LoadedScriptsView extends ViewletPanel { }, 300); this.disposables.push(this.changeScheduler); - const loadedScriptsNavigator = new DataTreeResourceNavigator(this.tree); + const loadedScriptsNavigator = new TreeResourceNavigator2(this.tree); this.disposables.push(loadedScriptsNavigator); this.disposables.push(loadedScriptsNavigator.openResource(e => { if (e.element instanceof BaseTreeItem) { diff --git a/src/vs/workbench/parts/debug/electron-browser/callStackView.ts b/src/vs/workbench/parts/debug/electron-browser/callStackView.ts index 45bc6bbb7e341e366441599beca29b9c0a2c997e..7fb253c7ad5cd265b0387fdb4a4af3c5737ea270 100644 --- a/src/vs/workbench/parts/debug/electron-browser/callStackView.ts +++ b/src/vs/workbench/parts/debug/electron-browser/callStackView.ts @@ -25,12 +25,13 @@ import { IViewletPanelOptions, ViewletPanel } from 'vs/workbench/browser/parts/v import { ILabelService } from 'vs/platform/label/common/label'; import { DebugSession } from 'vs/workbench/parts/debug/electron-browser/debugSession'; import { IAccessibilityProvider } from 'vs/base/browser/ui/list/listWidget'; -import { DataTree, IDataSource } from 'vs/base/browser/ui/tree/dataTree'; +import { IDataSource } from 'vs/base/browser/ui/tree/dataTree'; import { ITreeContextMenuEvent } from 'vs/base/browser/ui/tree/abstractTree'; import { fillInContextMenuActions } from 'vs/platform/actions/browser/menuItemActionItem'; import { IListVirtualDelegate } from 'vs/base/browser/ui/list/list'; import { ITreeRenderer, ITreeNode } from 'vs/base/browser/ui/tree/tree'; -import { DataTreeResourceNavigator } from 'vs/platform/list/browser/listService'; +import { TreeResourceNavigator2, WorkbenchDataTree, IListService } from 'vs/platform/list/browser/listService'; +import { IThemeService } from 'vs/platform/theme/common/themeService'; const $ = dom.$; @@ -45,7 +46,7 @@ export class CallStackView extends ViewletPanel { private ignoreSelectionChangedEvent: boolean; private callStackItemType: IContextKey; private dataSource: CallStackDataSource; - private tree: DataTree; + private tree: WorkbenchDataTree; private contributedContextMenu: IMenu; constructor( @@ -57,7 +58,9 @@ export class CallStackView extends ViewletPanel { @IEditorService private editorService: IEditorService, @IConfigurationService configurationService: IConfigurationService, @IMenuService menuService: IMenuService, - @IContextKeyService contextKeyService: IContextKeyService + @IContextKeyService private contextKeyService: IContextKeyService, + @IThemeService private themeService: IThemeService, + @IListService private listService: IListService ) { super({ ...(options as IViewletPanelOptions), ariaHeaderLabel: nls.localize('callstackSection', "Call Stack Section") }, keybindingService, contextMenuService, configurationService); this.callStackItemType = CONTEXT_CALLSTACK_ITEM_TYPE.bindTo(contextKeyService); @@ -100,7 +103,7 @@ export class CallStackView extends ViewletPanel { const treeContainer = renderViewTree(container); this.dataSource = new CallStackDataSource(this.debugService); - this.tree = new DataTree(treeContainer, new CallStackDelegate(), [ + this.tree = new WorkbenchDataTree(treeContainer, new CallStackDelegate(), [ new SessionsRenderer(), new ThreadsRenderer(), this.instantiationService.createInstance(StackFramesRenderer), @@ -110,9 +113,9 @@ export class CallStackView extends ViewletPanel { ], this.dataSource, { accessibilityProvider: new CallStackAccessibilityProvider(), ariaLabel: nls.localize({ comment: ['Debug is a noun in this context, not a verb.'], key: 'callStackAriaLabel' }, "Debug Call Stack"), - }); + }, this.contextKeyService, this.listService, this.themeService, this.configurationService); - const callstackNavigator = new DataTreeResourceNavigator(this.tree); + const callstackNavigator = new TreeResourceNavigator2(this.tree); this.disposables.push(callstackNavigator); this.disposables.push(callstackNavigator.openResource(e => { if (this.ignoreSelectionChangedEvent) { diff --git a/src/vs/workbench/parts/debug/electron-browser/repl.ts b/src/vs/workbench/parts/debug/electron-browser/repl.ts index 1dce13dd72ca008923cab92ad62c5d74366c3a35..fd27534783eab621b702fc820e78953a4e8852a2 100644 --- a/src/vs/workbench/parts/debug/electron-browser/repl.ts +++ b/src/vs/workbench/parts/debug/electron-browser/repl.ts @@ -47,7 +47,7 @@ import { FocusSessionActionItem } from 'vs/workbench/parts/debug/browser/debugAc import { CompletionContext, CompletionList, CompletionProviderRegistry } from 'vs/editor/common/modes'; import { first } from 'vs/base/common/arrays'; import { IPanelService } from 'vs/workbench/services/panel/common/panelService'; -import { DataTree, IDataSource } from 'vs/base/browser/ui/tree/dataTree'; +import { IDataSource } from 'vs/base/browser/ui/tree/dataTree'; import { IAccessibilityProvider } from 'vs/base/browser/ui/list/listWidget'; import { Variable, Expression, SimpleReplElement, RawObjectReplElement } from 'vs/workbench/parts/debug/common/debugModel'; import { IListVirtualDelegate } from 'vs/base/browser/ui/list/list'; @@ -64,6 +64,8 @@ import { ReplCollapseAllAction } from 'vs/workbench/parts/debug/browser/debugAct import { Separator } from 'vs/base/browser/ui/actionbar/actionbar'; import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { removeAnsiEscapeCodes, isFullWidthCharacter, endsWith } from 'vs/base/common/strings'; +import { WorkbenchDataTree, IListService } from 'vs/platform/list/browser/listService'; +import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; const $ = dom.$; @@ -89,7 +91,7 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati private static readonly REPL_INPUT_MAX_HEIGHT = 170; private history: HistoryNavigator; - private tree: DataTree; + private tree: WorkbenchDataTree; private dataSource: ReplDataSource; private container: HTMLElement; private treeContainer: HTMLElement; @@ -112,7 +114,9 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati @IModelService private modelService: IModelService, @IContextKeyService private contextKeyService: IContextKeyService, @ICodeEditorService codeEditorService: ICodeEditorService, - @IContextMenuService private contextMenuService: IContextMenuService + @IContextMenuService private contextMenuService: IContextMenuService, + @IListService private listService: IListService, + @IConfigurationService private configurationService: IConfigurationService ) { super(REPL_ID, telemetryService, themeService, storageService); @@ -320,7 +324,7 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati this.createReplInput(this.container); this.dataSource = new ReplDataSource(); - this.tree = new DataTree(this.treeContainer, new ReplDelegate(), [ + this.tree = new WorkbenchDataTree(this.treeContainer, new ReplDelegate(), [ this.instantiationService.createInstance(VariablesRenderer), this.instantiationService.createInstance(ReplSimpleElementsRenderer), new ReplExpressionsRenderer(), @@ -328,7 +332,7 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati ], this.dataSource, { ariaLabel: nls.localize('replAriaLabel', "Read Eval Print Loop Panel"), accessibilityProvider: new ReplAccessibilityProvider() - }); + }, this.contextKeyService, this.listService, this.themeService, this.configurationService); this.toDispose.push(this.tree.onContextMenu(e => this.onContextMenu(e))); // Make sure to select the session if debugging is already active diff --git a/src/vs/workbench/parts/debug/electron-browser/variablesView.ts b/src/vs/workbench/parts/debug/electron-browser/variablesView.ts index c13acab71ce9abdffaaa9fb2a3f9e10eba1c23f5..f3444c62eca83e4f49a09887e95683fbf25af432 100644 --- a/src/vs/workbench/parts/debug/electron-browser/variablesView.ts +++ b/src/vs/workbench/parts/debug/electron-browser/variablesView.ts @@ -19,7 +19,7 @@ import { CopyValueAction, CopyEvaluatePathAction } from 'vs/workbench/parts/debu import { Separator } from 'vs/base/browser/ui/actionbar/actionbar'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IViewletPanelOptions, ViewletPanel } from 'vs/workbench/browser/parts/views/panelViewlet'; -import { DataTree, IDataSource } from 'vs/base/browser/ui/tree/dataTree'; +import { IDataSource } from 'vs/base/browser/ui/tree/dataTree'; import { IAccessibilityProvider } from 'vs/base/browser/ui/list/listWidget'; import { ITreeContextMenuEvent, ITreeMouseEvent } from 'vs/base/browser/ui/tree/abstractTree'; import { IListVirtualDelegate } from 'vs/base/browser/ui/list/list'; @@ -27,6 +27,8 @@ import { ITreeRenderer, ITreeNode } from 'vs/base/browser/ui/tree/tree'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { Emitter } from 'vs/base/common/event'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; +import { WorkbenchDataTree, IListService } from 'vs/platform/list/browser/listService'; +import { IThemeService } from 'vs/platform/theme/common/themeService'; const $ = dom.$; @@ -39,7 +41,7 @@ export class VariablesView extends ViewletPanel { private onFocusStackFrameScheduler: RunOnceScheduler; private needsRefresh: boolean; - private tree: DataTree; + private tree: WorkbenchDataTree; constructor( options: IViewletViewOptions, @@ -48,7 +50,9 @@ export class VariablesView extends ViewletPanel { @IKeybindingService keybindingService: IKeybindingService, @IConfigurationService configurationService: IConfigurationService, @IInstantiationService private instantiationService: IInstantiationService, - @IContextKeyService private contextKeyService: IContextKeyService + @IContextKeyService private contextKeyService: IContextKeyService, + @IListService private listService: IListService, + @IThemeService private themeService: IThemeService ) { super({ ...(options as IViewletPanelOptions), ariaHeaderLabel: nls.localize('variablesSection', "Variables Section") }, keybindingService, contextMenuService, configurationService); @@ -63,11 +67,12 @@ export class VariablesView extends ViewletPanel { dom.addClass(container, 'debug-variables'); const treeContainer = renderViewTree(container); - this.tree = new DataTree(treeContainer, new VariablesDelegate(), [this.instantiationService.createInstance(VariablesRenderer), new ScopesRenderer()], + this.tree = new WorkbenchDataTree(treeContainer, new VariablesDelegate(), + [this.instantiationService.createInstance(VariablesRenderer), new ScopesRenderer()], new VariablesDataSource(this.debugService), { ariaLabel: nls.localize('variablesAriaTreeLabel', "Debug Variables"), accessibilityProvider: new VariablesAccessibilityProvider() - }); + }, this.contextKeyService, this.listService, this.themeService, this.configurationService); CONTEXT_VARIABLES_FOCUSED.bindTo(this.contextKeyService.createScoped(treeContainer)); diff --git a/src/vs/workbench/parts/debug/electron-browser/watchExpressionsView.ts b/src/vs/workbench/parts/debug/electron-browser/watchExpressionsView.ts index 8a76388295e37ed594a726d0618882fa8230429a..e5d4e6f70f2f3d504f5555f20e98748fc2424ae0 100644 --- a/src/vs/workbench/parts/debug/electron-browser/watchExpressionsView.ts +++ b/src/vs/workbench/parts/debug/electron-browser/watchExpressionsView.ts @@ -20,12 +20,14 @@ import { Separator } from 'vs/base/browser/ui/actionbar/actionbar'; import { renderExpressionValue, renderViewTree, IInputBoxOptions, AbstractExpressionsRenderer, IExpressionTemplateData } from 'vs/workbench/parts/debug/browser/baseDebugView'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IViewletPanelOptions, ViewletPanel } from 'vs/workbench/browser/parts/views/panelViewlet'; -import { DataTree, IDataSource } from 'vs/base/browser/ui/tree/dataTree'; +import { IDataSource } from 'vs/base/browser/ui/tree/dataTree'; import { IListVirtualDelegate } from 'vs/base/browser/ui/list/list'; import { IAccessibilityProvider } from 'vs/base/browser/ui/list/listWidget'; import { ITreeContextMenuEvent, ITreeMouseEvent } from 'vs/base/browser/ui/tree/abstractTree'; import { VariablesRenderer, variableSetEmitter } from 'vs/workbench/parts/debug/electron-browser/variablesView'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; +import { WorkbenchDataTree, IListService } from 'vs/platform/list/browser/listService'; +import { IThemeService } from 'vs/platform/theme/common/themeService'; const MAX_VALUE_RENDER_LENGTH_IN_VIEWLET = 1024; @@ -33,7 +35,7 @@ export class WatchExpressionsView extends ViewletPanel { private onWatchExpressionsUpdatedScheduler: RunOnceScheduler; private needsRefresh: boolean; - private tree: DataTree; + private tree: WorkbenchDataTree; constructor( options: IViewletViewOptions, @@ -42,7 +44,9 @@ export class WatchExpressionsView extends ViewletPanel { @IKeybindingService keybindingService: IKeybindingService, @IInstantiationService private instantiationService: IInstantiationService, @IConfigurationService configurationService: IConfigurationService, - @IContextKeyService private contextKeyService: IContextKeyService + @IContextKeyService private contextKeyService: IContextKeyService, + @IListService private listService: IListService, + @IThemeService private themeService: IThemeService ) { super({ ...(options as IViewletPanelOptions), ariaHeaderLabel: nls.localize('watchExpressionsSection', "Watch Expressions Section") }, keybindingService, contextMenuService, configurationService); @@ -59,11 +63,11 @@ export class WatchExpressionsView extends ViewletPanel { const expressionsRenderer = this.instantiationService.createInstance(WatchExpressionsRenderer); this.disposables.push(expressionsRenderer); - this.tree = new DataTree(treeContainer, new WatchExpressionsDelegate(), [expressionsRenderer, this.instantiationService.createInstance(VariablesRenderer)], + this.tree = new WorkbenchDataTree(treeContainer, new WatchExpressionsDelegate(), [expressionsRenderer, this.instantiationService.createInstance(VariablesRenderer)], new WatchExpressionsDataSource(this.debugService), { ariaLabel: nls.localize({ comment: ['Debug is a noun in this context, not a verb.'], key: 'watchAriaTreeLabel' }, "Debug Watch Expressions"), accessibilityProvider: new WatchExpressionsAccessibilityProvider(), - }); + }, this.contextKeyService, this.listService, this.themeService, this.configurationService); this.tree.refresh(null); diff --git a/src/vs/workbench/parts/markers/electron-browser/markersPanel.ts b/src/vs/workbench/parts/markers/electron-browser/markersPanel.ts index c19ab72a7d034152e46440661a33119ac4fb4d22..8e166ec89873311feb603d603c5627a1001cab6a 100644 --- a/src/vs/workbench/parts/markers/electron-browser/markersPanel.ts +++ b/src/vs/workbench/parts/markers/electron-browser/markersPanel.ts @@ -27,7 +27,7 @@ import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/c import { Iterator } from 'vs/base/common/iterator'; import { ITreeElement, ITreeNode } from 'vs/base/browser/ui/tree/tree'; import { debounceEvent, Relay, Event, Emitter } from 'vs/base/common/event'; -import { WorkbenchObjectTree, ObjectTreeResourceNavigator } from 'vs/platform/list/browser/listService'; +import { WorkbenchObjectTree, TreeResourceNavigator2 } from 'vs/platform/list/browser/listService'; import { FilterOptions } from 'vs/workbench/parts/markers/electron-browser/markersFilterOptions'; import { IExpression, getEmptyExpression } from 'vs/base/common/glob'; import { mixin, deepClone } from 'vs/base/common/objects'; @@ -314,7 +314,7 @@ export class MarkersPanel extends Panel implements IMarkerFilterController { relatedInformationFocusContextKey.set(false); })); - const markersNavigator = this._register(new ObjectTreeResourceNavigator(this.tree, { openOnFocus: true })); + const markersNavigator = this._register(new TreeResourceNavigator2(this.tree, { openOnFocus: true })); this._register(debounceEvent(markersNavigator.openResource, (last, event) => event, 75, true)(options => { this.openFileAtElement(options.element, options.editorOptions.preserveFocus, options.sideBySide, options.editorOptions.pinned); }));