Skip to content

Commit

Permalink
Adopt new tree in custom views (#76407)
Browse files Browse the repository at this point in the history
Auto expand initial state of tree nodes is not yet implemented.
Part of #63566
  • Loading branch information
alexr00 authored Jul 8, 2019
1 parent b07ff48 commit a70ca60
Show file tree
Hide file tree
Showing 5 changed files with 205 additions and 176 deletions.
25 changes: 25 additions & 0 deletions src/vs/base/browser/ui/tree/treeDefaults.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as nls from 'vs/nls';
import { Action } from 'vs/base/common/actions';
import { AsyncDataTree } from 'vs/base/browser/ui/tree/asyncDataTree';

export class CollapseAllAction<TInput, T, TFilterData = void> extends Action {

constructor(private viewer: AsyncDataTree<TInput, T, TFilterData>, enabled: boolean) {
super('vs.tree.collapse', nls.localize('collapse all', "Collapse All"), 'monaco-tree-action collapse-all', enabled);
}

public run(context?: any): Promise<any> {
this.viewer.collapseAll();
this.viewer.setSelection([]);
this.viewer.setFocus([]);
this.viewer.domFocus();
this.viewer.focusFirst();

return Promise.resolve();
}
}
5 changes: 4 additions & 1 deletion src/vs/workbench/api/browser/mainThreadTreeViews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ export class MainThreadTreeViews extends Disposable implements MainThreadTreeVie
await treeView.refresh();
}
for (const parent of parentChain) {
await treeView.expand(parent);
const parentItem = dataProvider.getItem(parent.handle);
if (parentItem) {
await treeView.expand(parentItem);
}
}
const item = dataProvider.getItem(itemIn.handle);
if (item) {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/browser/viewsExtensionPoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ class ViewsExtensionHandler implements IWorkbenchContribution {
when: ContextKeyExpr.deserialize(item.when),
canToggleVisibility: true,
collapsed: this.showCollapsed(container),
treeView: this.instantiationService.createInstance(CustomTreeView, item.id, container),
treeView: this.instantiationService.createInstance(CustomTreeView, item.id, item.name, container),
order: ExtensionIdentifier.equals(extension.description.identifier, container.extensionId) ? index + 1 : undefined,
extensionId: extension.description.identifier,
originalContainerId: entry.key
Expand Down
Loading

0 comments on commit a70ca60

Please sign in to comment.