diff --git a/src/vs/platform/statusbar/common/statusbar.ts b/src/vs/platform/statusbar/common/statusbar.ts index 5d6fde91462..fe3e8129d83 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 255fb6abe57..4c5f73ca97d 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 fa69e03408d..089772e9ce3 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 5614ff23fee..5b59feeb118 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 1ca7670ee0e..c9c3ecb4001 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 23fcbf5fe2b..65cbc3a44b1 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 c14aceed4cb..f6715b6fab8 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 1f7490e5430..b939b90d9b3 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 11e05b5104d..de8d68429cf 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 c02649dfdf2..9ce3b7df426 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 8bae20dde0f..efa06ed7e58 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); } }