From 9105c43ab0fc0b386adbf698f74356055772d9c4 Mon Sep 17 00:00:00 2001 From: Vincent Fugnitto Date: Wed, 14 Aug 2019 12:20:20 -0400 Subject: [PATCH] Add 'title' for widgets in the sidebar - added `title` to widgets present in the sidebar by using the widget's caption. - added `caption` title to view containers. - adjusted the `explorer` to display the workpace uri path when hovering over the widget's title. Signed-off-by: Vincent Fugnitto --- packages/core/src/browser/shell/side-panel-toolbar.ts | 1 + packages/core/src/browser/view-container.ts | 7 ++++++- packages/navigator/src/browser/navigator-widget.tsx | 9 +++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/core/src/browser/shell/side-panel-toolbar.ts b/packages/core/src/browser/shell/side-panel-toolbar.ts index 2f8d9fa329d9d..badb71cb5f0d0 100644 --- a/packages/core/src/browser/shell/side-panel-toolbar.ts +++ b/packages/core/src/browser/shell/side-panel-toolbar.ts @@ -97,6 +97,7 @@ export class SidePanelToolbar extends BaseWidget { if (this.titleContainer && title) { this._toolbarTitle = title; this.titleContainer.innerHTML = this._toolbarTitle.label; + this.titleContainer.title = this._toolbarTitle.caption || this._toolbarTitle.label; this.update(); } } diff --git a/packages/core/src/browser/view-container.ts b/packages/core/src/browser/view-container.ts index 500754fdc1cc0..f0aba85b0b38d 100644 --- a/packages/core/src/browser/view-container.ts +++ b/packages/core/src/browser/view-container.ts @@ -846,8 +846,13 @@ export class ViewContainerPart extends BaseWidget { const title = document.createElement('span'); title.classList.add('label', 'noselect'); const updateTitle = () => title.innerText = this.wrapped.title.label; + const updateCaption = () => title.title = this.wrapped.title.caption || this.wrapped.title.label; updateTitle(); - disposable.push(this.onTitleChanged(updateTitle)); + updateCaption(); + disposable.pushAll([ + this.onTitleChanged(updateTitle), + this.onTitleChanged(updateCaption) + ]); header.appendChild(title); return { header, diff --git a/packages/navigator/src/browser/navigator-widget.tsx b/packages/navigator/src/browser/navigator-widget.tsx index 27222f8487d60..0ca32e643f6d9 100644 --- a/packages/navigator/src/browser/navigator-widget.tsx +++ b/packages/navigator/src/browser/navigator-widget.tsx @@ -18,7 +18,7 @@ import { injectable, inject, postConstruct } from 'inversify'; import { Message } from '@phosphor/messaging'; import URI from '@theia/core/lib/common/uri'; import { CommandService, SelectionService } from '@theia/core/lib/common'; -import { CommonCommands, CorePreferences } from '@theia/core/lib/browser'; +import { CommonCommands, CorePreferences, LabelProvider } from '@theia/core/lib/browser'; import { ContextMenuRenderer, ExpandableTreeNode, TreeProps, TreeModel, TreeNode, @@ -44,6 +44,8 @@ export class FileNavigatorWidget extends FileTreeWidget { @inject(CorePreferences) protected readonly corePreferences: CorePreferences; + @inject(LabelProvider) protected readonly labelProvider: LabelProvider; + @inject(NavigatorContextKeyService) protected readonly contextKeyService: NavigatorContextKeyService; @@ -106,12 +108,15 @@ export class FileNavigatorWidget extends FileTreeWidget { const rootNode = this.model.root.children[0]; if (WorkspaceRootNode.is(rootNode)) { this.title.label = rootNode.name; + this.title.caption = this.labelProvider.getLongName(rootNode.uri); } } else { this.title.label = this.model.root.name; + this.title.caption = this.title.label; } + } else { + this.title.caption = this.title.label; } - this.title.caption = this.title.label; } protected enableDndOnMainPanel(): void {