mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-22 09:38:38 +01:00
Add title API for tree views (#80623)
* First pass at set view title * Change to get/set instead of setTitle and get the name of the view from the extension contributions
This commit is contained in:
@@ -244,6 +244,7 @@ export interface MainThreadTreeViewsShape extends IDisposable {
|
||||
$refresh(treeViewId: string, itemsToRefresh?: { [treeItemHandle: string]: ITreeItem }): Promise<void>;
|
||||
$reveal(treeViewId: string, treeItem: ITreeItem, parentChain: ITreeItem[], options: IRevealOptions): Promise<void>;
|
||||
$setMessage(treeViewId: string, message: string): void;
|
||||
$setTitle(treeViewId: string, title: string): void;
|
||||
}
|
||||
|
||||
export interface MainThreadDownloadServiceShape extends IDisposable {
|
||||
|
||||
@@ -96,6 +96,11 @@ export class ExtHostTreeViews implements ExtHostTreeViewsShape {
|
||||
checkProposedApiEnabled(extension);
|
||||
treeView.message = message;
|
||||
},
|
||||
get title() { return treeView.title; },
|
||||
set title(title: string) {
|
||||
checkProposedApiEnabled(extension);
|
||||
treeView.title = title;
|
||||
},
|
||||
reveal: (element: T, options?: IRevealOptions): Promise<void> => {
|
||||
return treeView.reveal(element, options);
|
||||
},
|
||||
@@ -195,6 +200,15 @@ class ExtHostTreeView<T> extends Disposable {
|
||||
|
||||
constructor(private viewId: string, options: vscode.TreeViewOptions<T>, private proxy: MainThreadTreeViewsShape, private commands: CommandsConverter, private logService: ILogService, private extension: IExtensionDescription) {
|
||||
super();
|
||||
if (extension.contributes && extension.contributes.views) {
|
||||
for (const location in extension.contributes.views) {
|
||||
for (const view of extension.contributes.views[location]) {
|
||||
if (view.id === viewId) {
|
||||
this._title = view.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.dataProvider = options.treeDataProvider;
|
||||
this.proxy.$registerTreeViewDataProvider(viewId, { showCollapseAll: !!options.showCollapseAll, canSelectMany: !!options.canSelectMany });
|
||||
if (this.dataProvider.onDidChangeTreeData) {
|
||||
@@ -274,6 +288,16 @@ class ExtHostTreeView<T> extends Disposable {
|
||||
this._onDidChangeData.fire({ message: true, element: false });
|
||||
}
|
||||
|
||||
private _title: string = '';
|
||||
get title(): string {
|
||||
return this._title;
|
||||
}
|
||||
|
||||
set title(title: string) {
|
||||
this._title = title;
|
||||
this.proxy.$setTitle(this.viewId, title);
|
||||
}
|
||||
|
||||
setExpanded(treeItemHandle: TreeItemHandle, expanded: boolean): void {
|
||||
const element = this.getExtensionElement(treeItemHandle);
|
||||
if (element) {
|
||||
|
||||
Reference in New Issue
Block a user