diff --git a/src/vs/platform/statusbar/common/statusbar.ts b/src/vs/platform/statusbar/common/statusbar.ts index 5d6fde9146225fe2897803beb8c99d4012fa9b17..fe3e8129d8325026116d7195482c50959079493a 100644 --- a/src/vs/platform/statusbar/common/statusbar.ts +++ b/src/vs/platform/statusbar/common/statusbar.ts @@ -20,16 +20,6 @@ export const enum StatusbarAlignment { */ export interface IStatusbarEntry { - /** - * The identifier of the entry is needed to allow users to hide entries via settings. - */ - readonly id: string; - - /** - * A human readable name the entry is about. - */ - readonly name: string; - /** * The text to show for the entry. You can embed icons in the text by leveraging the syntax: * @@ -80,8 +70,11 @@ export interface IStatusbarService { /** * Adds an entry to the statusbar with the given alignment and priority. Use the returned accessor * to update or remove the statusbar entry. + * + * @param id identifier of the entry is needed to allow users to hide entries via settings + * @param name human readable name the entry is about */ - addEntry(entry: IStatusbarEntry, alignment: StatusbarAlignment, priority?: number): IStatusbarEntryAccessor; + addEntry(entry: IStatusbarEntry, id: string, name: string, alignment: StatusbarAlignment, priority?: number): IStatusbarEntryAccessor; } export interface IStatusbarEntryAccessor extends IDisposable { diff --git a/src/vs/workbench/api/browser/mainThreadStatusBar.ts b/src/vs/workbench/api/browser/mainThreadStatusBar.ts index 255fb6abe57f7f5ca39ae4c540ccedade178b3d4..4c5f73ca97da8f882795ba6cd908e4857d61585b 100644 --- a/src/vs/workbench/api/browser/mainThreadStatusBar.ts +++ b/src/vs/workbench/api/browser/mainThreadStatusBar.ts @@ -27,15 +27,7 @@ export class MainThreadStatusBar implements MainThreadStatusBarShape { } $setEntry(id: number, extension: IExtensionDescription, text: string, tooltip: string, command: string, color: string | ThemeColor, alignment: MainThreadStatusBarAlignment, priority: number): void { - const entry: IStatusbarEntry = { - id: extension.identifier.value, - name: localize('extensionLabel', "{0} (Extension)", extension.displayName || extension.name), - text, - tooltip, - command, - color, - extensionId: extension.identifier - }; + const entry: IStatusbarEntry = { text, tooltip, command, color, extensionId: extension.identifier }; // Reset existing entry if alignment or priority changed let existingEntry = this.entries.get(id); @@ -47,7 +39,10 @@ export class MainThreadStatusBar implements MainThreadStatusBarShape { // Create new entry if not existing if (!existingEntry) { - this.entries.set(id, { accessor: this.statusbarService.addEntry(entry, alignment, priority), alignment, priority }); + const entryId = extension.identifier.value; + const entryName = localize('extensionLabel', "{0} (Extension)", extension.displayName || extension.name); + + this.entries.set(id, { accessor: this.statusbarService.addEntry(entry, entryId, entryName, alignment, priority), alignment, priority }); } // Otherwise update diff --git a/src/vs/workbench/browser/parts/notifications/notificationsStatus.ts b/src/vs/workbench/browser/parts/notifications/notificationsStatus.ts index fa69e03408dd167e785c5844b922c2b120a8f8ca..089772e9ce3241c11b3428eeec97ec3cfa00b86f 100644 --- a/src/vs/workbench/browser/parts/notifications/notificationsStatus.ts +++ b/src/vs/workbench/browser/parts/notifications/notificationsStatus.ts @@ -58,8 +58,6 @@ export class NotificationsStatus extends Disposable { private updateNotificationsCenterStatusItem(): void { const statusProperties: IStatusbarEntry = { - id: 'status.notifications', - name: localize('status.notifications', "Notifictions"), text: this.currentNotifications.size === 0 ? '$(bell)' : `$(bell) ${this.currentNotifications.size}`, command: this.isNotificationsCenterVisible ? HIDE_NOTIFICATIONS_CENTER : SHOW_NOTIFICATIONS_CENTER, tooltip: this.getTooltip(), @@ -67,7 +65,7 @@ export class NotificationsStatus extends Disposable { }; if (!this.notificationsCenterStatusItem) { - this.notificationsCenterStatusItem = this.statusbarService.addEntry(statusProperties, StatusbarAlignment.RIGHT, -1000 /* towards the far end of the right hand side */); + this.notificationsCenterStatusItem = this.statusbarService.addEntry(statusProperties, 'status.notifications', localize('status.notifications', "Notifictions"), StatusbarAlignment.RIGHT, -1000 /* towards the far end of the right hand side */); } else { this.notificationsCenterStatusItem.update(statusProperties); } @@ -139,11 +137,13 @@ export class NotificationsStatus extends Disposable { // Create new let statusMessageEntry: IStatusbarEntryAccessor; let showHandle: any = setTimeout(() => { - statusMessageEntry = this.statusbarService.addEntry({ - id: 'status.message', - name: localize('status.message', "Status Message"), - text: message - }, StatusbarAlignment.LEFT, -Number.MAX_VALUE /* far right on left hand side */); + statusMessageEntry = this.statusbarService.addEntry( + { text: message }, + 'status.message', + localize('status.message', "Status Message"), + StatusbarAlignment.LEFT, + -Number.MAX_VALUE /* far right on left hand side */ + ); showHandle = null; }, showAfter); diff --git a/src/vs/workbench/browser/parts/statusbar/statusbarPart.ts b/src/vs/workbench/browser/parts/statusbar/statusbarPart.ts index 5614ff23feeb326a5110023725937b01124b5ea8..5b59feeb118389f7267c14a0ccdd798e828486ef 100644 --- a/src/vs/workbench/browser/parts/statusbar/statusbarPart.ts +++ b/src/vs/workbench/browser/parts/statusbar/statusbarPart.ts @@ -37,6 +37,8 @@ import { Event, Emitter } from 'vs/base/common/event'; import { values } from 'vs/base/common/map'; interface IPendingStatusbarEntry { + id: string; + name: string; entry: IStatusbarEntry; alignment: StatusbarAlignment; priority: number; @@ -279,20 +281,20 @@ export class StatusbarPart extends Part implements IStatusbarService { }); } - addEntry(entry: IStatusbarEntry, alignment: StatusbarAlignment, priority: number = 0): IStatusbarEntryAccessor { + addEntry(entry: IStatusbarEntry, id: string, name: string, alignment: StatusbarAlignment, priority: number = 0): IStatusbarEntryAccessor { // As long as we have not been created into a container yet, record all entries // that are pending so that they can get created at a later point if (!this.element) { - return this.doAddPendingEntry(entry, alignment, priority); + return this.doAddPendingEntry(entry, id, name, alignment, priority); } // Otherwise add to view - return this.doAddEntry(entry, alignment, priority); + return this.doAddEntry(entry, id, name, alignment, priority); } - private doAddPendingEntry(entry: IStatusbarEntry, alignment: StatusbarAlignment, priority: number): IStatusbarEntryAccessor { - const pendingEntry: IPendingStatusbarEntry = { entry, alignment, priority }; + private doAddPendingEntry(entry: IStatusbarEntry, id: string, name: string, alignment: StatusbarAlignment, priority: number): IStatusbarEntryAccessor { + const pendingEntry: IPendingStatusbarEntry = { entry, id, name, alignment, priority }; this.pendingEntries.push(pendingEntry); const accessor: IStatusbarEntryAccessor = { @@ -316,14 +318,14 @@ export class StatusbarPart extends Part implements IStatusbarService { return accessor; } - private doAddEntry(entry: IStatusbarEntry, alignment: StatusbarAlignment, priority: number): IStatusbarEntryAccessor { + private doAddEntry(entry: IStatusbarEntry, id: string, name: string, alignment: StatusbarAlignment, priority: number): IStatusbarEntryAccessor { // Add to view model - const viewModelItem: IStatusbarViewModelItem = { id: entry.id, name: entry.name, alignment, priority }; + const viewModelItem: IStatusbarViewModelItem = { id, name, alignment, priority }; this.viewModel.add(viewModelItem); // Render entry in status bar - const itemContainer = this.doCreateStatusItem(entry.id, entry.name, alignment, priority, ...coalesce(['statusbar-entry', entry.showBeak ? 'has-beak' : undefined])); + const itemContainer = this.doCreateStatusItem(id, name, alignment, priority, ...coalesce(['statusbar-entry', entry.showBeak ? 'has-beak' : undefined])); const item = this.instantiationService.createInstance(StatusbarEntryItem, itemContainer, entry); // Insert according to priority @@ -445,9 +447,9 @@ export class StatusbarPart extends Part implements IStatusbarService { // Fill in pending entries if any while (this.pendingEntries.length) { - const entry = this.pendingEntries.shift(); - if (entry) { - entry.accessor = this.addEntry(entry.entry, entry.alignment, entry.priority); + const pending = this.pendingEntries.shift(); + if (pending) { + pending.accessor = this.addEntry(pending.entry, pending.id, pending.name, pending.alignment, pending.priority); } } } diff --git a/src/vs/workbench/contrib/debug/browser/debugStatus.ts b/src/vs/workbench/contrib/debug/browser/debugStatus.ts index 1ca7670ee0e5d4764ae08ddf568ca63d17cbd0c4..c9c3ecb40017e60321b4046a688710f075ec4985 100644 --- a/src/vs/workbench/contrib/debug/browser/debugStatus.ts +++ b/src/vs/workbench/contrib/debug/browser/debugStatus.ts @@ -23,17 +23,21 @@ export class DebugStatusContribution implements IWorkbenchContribution { @IConfigurationService readonly configurationService: IConfigurationService ) { + const addStatusBarEntry = () => { + this.entryAccessor = this.statusBarService.addEntry(this.entry, 'status.debug', nls.localize('status.debug', "Debug Configuration"), StatusbarAlignment.LEFT, 30 /* Low Priority */); + }; + const setShowInStatusBar = () => { this.showInStatusBar = configurationService.getValue('debug').showInStatusBar; if (this.showInStatusBar === 'always' && !this.entryAccessor) { - this.entryAccessor = this.statusBarService.addEntry(this.entry, StatusbarAlignment.LEFT, 30 /* Low Priority */); + addStatusBarEntry(); } }; setShowInStatusBar(); this.toDispose.push(this.debugService.onDidChangeState(state => { if (state !== State.Inactive && this.showInStatusBar === 'onFirstSessionStart' && !this.entryAccessor) { - this.entryAccessor = this.statusBarService.addEntry(this.entry, StatusbarAlignment.LEFT, 30 /* Low Priority */); + addStatusBarEntry(); } })); this.toDispose.push(configurationService.onDidChangeConfiguration(e => { @@ -65,8 +69,6 @@ export class DebugStatusContribution implements IWorkbenchContribution { private get entry(): IStatusbarEntry { return { - id: 'status.debug', - name: nls.localize('status.debug', "Debug Configuration"), text: this.getText(), tooltip: nls.localize('selectAndStartDebug', "Select and start debug configuration"), command: 'workbench.action.debug.selectandstart' diff --git a/src/vs/workbench/contrib/extensions/electron-browser/extensionProfileService.ts b/src/vs/workbench/contrib/extensions/electron-browser/extensionProfileService.ts index 23fcbf5fe2b66eb023545330ac40b4281f2bb03b..65cbc3a44b1d01da7eb35d2d225e3a54e26830cf 100644 --- a/src/vs/workbench/contrib/extensions/electron-browser/extensionProfileService.ts +++ b/src/vs/workbench/contrib/extensions/electron-browser/extensionProfileService.ts @@ -84,8 +84,6 @@ export class ExtensionHostProfileService extends Disposable implements IExtensio if (visible) { const indicator: IStatusbarEntry = { - id: 'status.profiler', - name: nls.localize('status.profiler', "Extension Profiler"), text: nls.localize('profilingExtensionHost', "$(sync~spin) Profiling Extension Host"), tooltip: nls.localize('selectAndStartDebug', "Click to stop profiling."), command: 'workbench.action.extensionHostProfilder.stop' @@ -100,7 +98,7 @@ export class ExtensionHostProfileService extends Disposable implements IExtensio this.profilingStatusBarIndicatorLabelUpdater = toDisposable(() => clearInterval(handle)); if (!this.profilingStatusBarIndicator) { - this.profilingStatusBarIndicator = this._statusbarService.addEntry(indicator, StatusbarAlignment.RIGHT); + this.profilingStatusBarIndicator = this._statusbarService.addEntry(indicator, 'status.profiler', nls.localize('status.profiler', "Extension Profiler"), StatusbarAlignment.RIGHT); } else { this.profilingStatusBarIndicator.update(indicator); } diff --git a/src/vs/workbench/contrib/markers/browser/markers.contribution.ts b/src/vs/workbench/contrib/markers/browser/markers.contribution.ts index c14aceed4cbb8ce4a5b0a20ef755be37e97e2246..f6715b6fab8563af559234ad0602dd0272a46f46 100644 --- a/src/vs/workbench/contrib/markers/browser/markers.contribution.ts +++ b/src/vs/workbench/contrib/markers/browser/markers.contribution.ts @@ -279,15 +279,13 @@ class MarkersStatusBarContributions extends Disposable implements IWorkbenchCont @IStatusbarService private readonly statusbarService: IStatusbarService ) { super(); - this.markersStatusItem = this._register(this.statusbarService.addEntry(this.getMarkersItem(), StatusbarAlignment.LEFT, 50 /* Medium Priority */)); + this.markersStatusItem = this._register(this.statusbarService.addEntry(this.getMarkersItem(), 'status.problems', localize('status.problems', "Problems"), StatusbarAlignment.LEFT, 50 /* Medium Priority */)); this.markerService.onMarkerChanged(() => this.markersStatusItem.update(this.getMarkersItem())); } private getMarkersItem(): IStatusbarEntry { const markersStatistics = this.markerService.getStatistics(); return { - id: 'status.problems', - name: localize('status.problems', "Problems"), text: this.getMarkersText(markersStatistics), tooltip: this.getMarkersTooltip(markersStatistics), command: 'workbench.actions.view.toggleProblems' diff --git a/src/vs/workbench/contrib/remote/electron-browser/remote.contribution.ts b/src/vs/workbench/contrib/remote/electron-browser/remote.contribution.ts index 1f7490e5430fcb85882aa772bff4e5affa150e6d..b939b90d9b3b156f0753d5f03623893dafb713b9 100644 --- a/src/vs/workbench/contrib/remote/electron-browser/remote.contribution.ts +++ b/src/vs/workbench/contrib/remote/electron-browser/remote.contribution.ts @@ -138,14 +138,12 @@ export class RemoteWindowActiveIndicator extends Disposable implements IWorkbenc private renderWindowIndicator(text: string, tooltip?: string, command?: string): void { const properties: IStatusbarEntry = { - id: 'status.host', - name: nls.localize('status.host', "Remote Host"), backgroundColor: themeColorFromId(STATUS_BAR_HOST_NAME_BACKGROUND), color: themeColorFromId(STATUS_BAR_HOST_NAME_FOREGROUND), text, tooltip, command }; if (this.windowIndicatorEntry) { this.windowIndicatorEntry.update(properties); } else { - this.windowIndicatorEntry = this.statusbarService.addEntry(properties, StatusbarAlignment.LEFT, Number.MAX_VALUE /* first entry */); + this.windowIndicatorEntry = this.statusbarService.addEntry(properties, 'status.host', nls.localize('status.host', "Remote Host"), StatusbarAlignment.LEFT, Number.MAX_VALUE /* first entry */); } } diff --git a/src/vs/workbench/contrib/scm/browser/scmActivity.ts b/src/vs/workbench/contrib/scm/browser/scmActivity.ts index 11e05b5104dd9e80fed9d24d1ea5fa789efc68cb..de8d68429cfca679f364c0c8f0b77320213f2b00 100644 --- a/src/vs/workbench/contrib/scm/browser/scmActivity.ts +++ b/src/vs/workbench/contrib/scm/browser/scmActivity.ts @@ -190,13 +190,11 @@ export class StatusBarController implements IWorkbenchContribution { const disposables = new DisposableStore(); for (const c of commands) { disposables.add(this.statusbarService.addEntry({ - id: 'status.scm', - name: localize('status.scm', "Source Control"), text: c.title, tooltip: `${label} - ${c.tooltip}`, command: c.id, arguments: c.arguments - }, MainThreadStatusBarAlignment.LEFT, 10000)); + }, 'status.scm', localize('status.scm', "Source Control"), MainThreadStatusBarAlignment.LEFT, 10000)); } this.statusBarDisposable = disposables; diff --git a/src/vs/workbench/contrib/tasks/electron-browser/task.contribution.ts b/src/vs/workbench/contrib/tasks/electron-browser/task.contribution.ts index c02649dfdf2cd4f246df6015194fe41e8ee991f8..9ce3b7df426d72cc6f7a91f33bc9c26008f003ce 100644 --- a/src/vs/workbench/contrib/tasks/electron-browser/task.contribution.ts +++ b/src/vs/workbench/contrib/tasks/electron-browser/task.contribution.ts @@ -182,15 +182,13 @@ export class TaskStatusBarContributions extends Disposable implements IWorkbench } } else { const itemProps: IStatusbarEntry = { - id: 'status.runningTasks', - name: nls.localize('status.runningTasks', "Running Tasks"), text: `$(tools) ${tasks.length}`, tooltip: nls.localize('runningTasks', "Show Running Tasks"), command: 'workbench.action.tasks.showTasks', }; if (!this.runningTasksStatusItem) { - this.runningTasksStatusItem = this.statusbarService.addEntry(itemProps, StatusbarAlignment.LEFT, 50 /* Medium Priority */); + this.runningTasksStatusItem = this.statusbarService.addEntry(itemProps, 'status.runningTasks', nls.localize('status.runningTasks', "Running Tasks"), StatusbarAlignment.LEFT, 50 /* Medium Priority */); } else { this.runningTasksStatusItem.update(itemProps); } diff --git a/src/vs/workbench/services/progress/browser/progressService.ts b/src/vs/workbench/services/progress/browser/progressService.ts index 8bae20dde0ff0325ea06d2017876e36f558c7de6..efa06ed7e5896a7e23b230a1510a2758487a1157 100644 --- a/src/vs/workbench/services/progress/browser/progressService.ts +++ b/src/vs/workbench/services/progress/browser/progressService.ts @@ -129,11 +129,9 @@ export class ProgressService implements IProgressService { } this._globalStatusEntry = this._statusbarService.addEntry({ - id: 'status.progress', - name: localize('status.progress', "Progress Message"), text: `$(sync~spin) ${text}`, tooltip: title - }, StatusbarAlignment.LEFT); + }, 'status.progress', localize('status.progress', "Progress Message"), StatusbarAlignment.LEFT); } }