Skip to content

Commit

Permalink
Allow welcome content in custom views
Browse files Browse the repository at this point in the history
Fixes #92143
  • Loading branch information
alexr00 committed Mar 6, 2020
1 parent c7be212 commit 85dda6d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/vs/workbench/browser/parts/views/customView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export class CustomTreeViewPane extends ViewPane {
this._register(this.treeView.onDidChangeTitle((newTitle) => this.updateTitle(newTitle)));
this._register(toDisposable(() => this.treeView.setVisibility(false)));
this._register(this.onDidChangeBodyVisibility(() => this.updateTreeVisibility()));
this._register(this.treeView.onDidChangeWelcomeState(() => this._onDidChangeViewWelcomeState.fire()));
this.updateTreeVisibility();
}

Expand All @@ -83,6 +84,10 @@ export class CustomTreeViewPane extends ViewPane {
}
}

shouldShowWelcome(): boolean {
return (this.treeView.dataProvider === undefined) && (this.treeView.message === undefined);
}

layoutBody(height: number, width: number): void {
this.treeView.layout(height, width);
}
Expand Down Expand Up @@ -151,6 +156,9 @@ export class CustomTreeView extends Disposable implements ITreeView {
private readonly _onDidChangeActions: Emitter<void> = this._register(new Emitter<void>());
readonly onDidChangeActions: Event<void> = this._onDidChangeActions.event;

private readonly _onDidChangeWelcomeState: Emitter<void> = this._register(new Emitter<void>());
readonly onDidChangeWelcomeState: Event<void> = this._onDidChangeWelcomeState.event;

private readonly _onDidChangeTitle: Emitter<string> = this._register(new Emitter<string>());
readonly onDidChangeTitle: Event<string> = this._onDidChangeTitle.event;

Expand Down Expand Up @@ -223,6 +231,8 @@ export class CustomTreeView extends Disposable implements ITreeView {
this._dataProvider = undefined;
this.updateMessage();
}

this._onDidChangeWelcomeState.fire();
}

private _message: string | undefined;
Expand All @@ -233,6 +243,7 @@ export class CustomTreeView extends Disposable implements ITreeView {
set message(message: string | undefined) {
this._message = message;
this.updateMessage();
this._onDidChangeWelcomeState.fire();
}

get title(): string {
Expand Down
2 changes: 2 additions & 0 deletions src/vs/workbench/common/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,8 @@ export interface ITreeView extends IDisposable {

readonly onDidChangeTitle: Event<string>;

readonly onDidChangeWelcomeState: Event<void>;

refresh(treeItems?: ITreeItem[]): Promise<void>;

setVisibility(visible: boolean): void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ const viewsWelcomeExtensionPointSchema = Object.freeze<IConfigurationPropertySch
[ViewsWelcomeExtensionPointFields.view]: {
type: 'string',
description: nls.localize('contributes.viewsWelcome.view.view', "Target view identifier for this welcome content."),
enum: Object.keys(ViewIdentifierMap),
},
[ViewsWelcomeExtensionPointFields.contents]: {
type: 'string',
Expand Down

0 comments on commit 85dda6d

Please sign in to comment.