|
| 1 | +/*--------------------------------------------------------------------------------------------- |
| 2 | + * Copyright (c) Microsoft Corporation. All rights reserved. |
| 3 | + * Licensed under the MIT License. See License.txt in the project root for license information. |
| 4 | + *--------------------------------------------------------------------------------------------*/ |
| 5 | + |
| 6 | +import * as nls from 'vs/nls'; |
| 7 | +import { TreeViewsViewletPanel, IViewletViewOptions } from 'vs/workbench/browser/parts/views/viewsViewlet'; |
| 8 | +import { TPromise } from 'vs/base/common/winjs.base'; |
| 9 | +import * as dom from 'vs/base/browser/dom'; |
| 10 | +import { IViewletPanelOptions } from 'vs/workbench/browser/parts/views/panelViewlet'; |
| 11 | +import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; |
| 12 | +import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; |
| 13 | +import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; |
| 14 | +import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; |
| 15 | +import { WorkbenchTree } from 'vs/platform/list/browser/listService'; |
| 16 | +import { renderViewTree, twistiePixels } from 'vs/workbench/parts/debug/browser/baseDebugView'; |
| 17 | +import { IAccessibilityProvider, ITree, IRenderer, IDataSource } from 'vs/base/parts/tree/browser/tree'; |
| 18 | + |
| 19 | +export class LoadedScriptsView extends TreeViewsViewletPanel { |
| 20 | + |
| 21 | + private treeContainer: HTMLElement; |
| 22 | + |
| 23 | + constructor( |
| 24 | + options: IViewletViewOptions, |
| 25 | + @IContextMenuService contextMenuService: IContextMenuService, |
| 26 | + @IKeybindingService keybindingService: IKeybindingService, |
| 27 | + @IInstantiationService private instantiationService: IInstantiationService, |
| 28 | + @IConfigurationService configurationService: IConfigurationService, |
| 29 | + ) { |
| 30 | + super({ ...(options as IViewletPanelOptions), ariaHeaderLabel: nls.localize('loadedScriptsSection', "Loaded Scripts Section") }, keybindingService, contextMenuService, configurationService); |
| 31 | + } |
| 32 | + |
| 33 | + protected renderBody(container: HTMLElement): void { |
| 34 | + dom.addClass(container, 'debug-loaded-scripts'); |
| 35 | + this.treeContainer = renderViewTree(container); |
| 36 | + |
| 37 | + this.tree = this.instantiationService.createInstance(WorkbenchTree, this.treeContainer, { |
| 38 | + dataSource: new LoadedScriptsDataSource(), |
| 39 | + renderer: this.instantiationService.createInstance(LoadedScriptsRenderer), |
| 40 | + accessibilityProvider: new LoadedSciptsAccessibilityProvider(), |
| 41 | + }, { |
| 42 | + ariaLabel: nls.localize({ comment: ['Debug is a noun in this context, not a verb.'], key: 'loadedScriptsAriaLabel' }, "Debug Loaded Scripts"), |
| 43 | + twistiePixels |
| 44 | + }); |
| 45 | + } |
| 46 | + |
| 47 | + layoutBody(size: number): void { |
| 48 | + if (this.treeContainer) { |
| 49 | + this.treeContainer.style.height = size + 'px'; |
| 50 | + } |
| 51 | + super.layoutBody(size); |
| 52 | + } |
| 53 | +} |
| 54 | + |
| 55 | +// A good example of data source, renderers, action providers and accessibilty providers can be found in the callStackView.ts |
| 56 | + |
| 57 | +class LoadedScriptsDataSource implements IDataSource { |
| 58 | + |
| 59 | + getId(tree: ITree, element: any): string { |
| 60 | + throw new Error('Method not implemented.'); |
| 61 | + } |
| 62 | + |
| 63 | + hasChildren(tree: ITree, element: any): boolean { |
| 64 | + throw new Error('Method not implemented.'); |
| 65 | + } |
| 66 | + |
| 67 | + getChildren(tree: ITree, element: any): TPromise<any> { |
| 68 | + throw new Error('Method not implemented.'); |
| 69 | + } |
| 70 | + |
| 71 | + getParent(tree: ITree, element: any): TPromise<any> { |
| 72 | + throw new Error('Method not implemented.'); |
| 73 | + } |
| 74 | +} |
| 75 | + |
| 76 | +class LoadedScriptsRenderer implements IRenderer { |
| 77 | + |
| 78 | + getHeight(tree: ITree, element: any): number { |
| 79 | + throw new Error('Method not implemented.'); |
| 80 | + } |
| 81 | + |
| 82 | + getTemplateId(tree: ITree, element: any): string { |
| 83 | + throw new Error('Method not implemented.'); |
| 84 | + } |
| 85 | + |
| 86 | + renderTemplate(tree: ITree, templateId: string, container: HTMLElement) { |
| 87 | + throw new Error('Method not implemented.'); |
| 88 | + } |
| 89 | + |
| 90 | + renderElement(tree: ITree, element: any, templateId: string, templateData: any): void { |
| 91 | + throw new Error('Method not implemented.'); |
| 92 | + } |
| 93 | + |
| 94 | + disposeTemplate(tree: ITree, templateId: string, templateData: any): void { |
| 95 | + throw new Error('Method not implemented.'); |
| 96 | + } |
| 97 | +} |
| 98 | + |
| 99 | +class LoadedSciptsAccessibilityProvider implements IAccessibilityProvider { |
| 100 | + |
| 101 | + public getAriaLabel(tree: ITree, element: any): string { |
| 102 | + return nls.localize('implement me', "implement me"); |
| 103 | + } |
| 104 | +} |
0 commit comments