提交 01423e45 编写于 作者: B Benjamin Pasero

debt - move status message into notification status

上级 fa3b4d7c
......@@ -15,9 +15,9 @@ import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService
import { Range } from 'vs/editor/common/core/range';
import { Disposable, dispose, IDisposable, combinedDisposable } from 'vs/base/common/lifecycle';
import { Emitter, Event } from 'vs/base/common/event';
import { IStatusbarService } from 'vs/platform/statusbar/common/statusbar';
import { localize } from 'vs/nls';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { INotificationService } from 'vs/platform/notification/common/notification';
export const ctxHasSymbols = new RawContextKey('hasSymbols', false);
......@@ -45,7 +45,7 @@ class SymbolNavigationService implements ISymbolNavigationService {
constructor(
@IContextKeyService contextKeyService: IContextKeyService,
@ICodeEditorService private readonly _editorService: ICodeEditorService,
@IStatusbarService private readonly _statusbarService: IStatusbarService,
@INotificationService private readonly _notificationService: INotificationService,
@IKeybindingService private readonly _keybindingService: IKeybindingService,
) {
this._ctxHasSymbols = ctxHasSymbols.bindTo(contextKeyService);
......@@ -143,7 +143,7 @@ class SymbolNavigationService implements ISymbolNavigationService {
? localize('location.kb', "Symbol {0} of {1}, {2} for next", this._currentIdx + 1, this._currentModel!.references.length, kb.getLabel())
: localize('location', "Symbol {0} of {1}", this._currentIdx + 1, this._currentModel!.references.length);
this._currentMessage = this._statusbarService.setStatusMessage(message);
this._currentMessage = this._notificationService.status(message);
}
}
......
......@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { createDecorator, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
import { IDisposable } from 'vs/base/common/lifecycle';
import { ThemeColor } from 'vs/platform/theme/common/themeService';
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
......@@ -64,18 +64,13 @@ export interface IStatusbarEntry {
export interface IStatusbarService {
_serviceBrand: any;
_serviceBrand: ServiceIdentifier<IStatusbarService>;
/**
* Adds an entry to the statusbar with the given alignment and priority. Use the returned accessor
* to update or remove the statusbar entry.
*/
addEntry(entry: IStatusbarEntry, alignment: StatusbarAlignment, priority?: number): IStatusbarEntryAccessor;
/**
* Prints something to the status bar area with optional auto dispose and delay.
*/
setStatusMessage(message: string, autoDisposeAfter?: number, delayBy?: number): IDisposable;
}
export interface IStatusbarEntryAccessor extends IDisposable {
......
......@@ -13,7 +13,6 @@ import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { ILabelService } from 'vs/platform/label/common/label';
import { IFileMatch, IPatternInfo, ISearchProgressItem, ISearchService } from 'vs/workbench/services/search/common/search';
import { IStatusbarService } from 'vs/platform/statusbar/common/statusbar';
import { IWindowService } from 'vs/platform/windows/common/windows';
import { IWorkspaceContextService, WorkbenchState, IWorkspace } from 'vs/platform/workspace/common/workspace';
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
......@@ -24,6 +23,7 @@ import { IWorkspaceEditingService } from 'vs/workbench/services/workspace/common
import { ExtHostContext, ExtHostWorkspaceShape, IExtHostContext, MainContext, MainThreadWorkspaceShape, IWorkspaceData, ITextSearchComplete } from '../common/extHost.protocol';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { isEqualOrParent } from 'vs/base/common/resources';
import { INotificationService } from 'vs/platform/notification/common/notification';
@extHostNamedCustomer(MainContext.MainThreadWorkspace)
export class MainThreadWorkspace implements MainThreadWorkspaceShape {
......@@ -39,7 +39,7 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape {
@IWorkspaceContextService private readonly _contextService: IWorkspaceContextService,
@ITextFileService private readonly _textFileService: ITextFileService,
@IWorkspaceEditingService private readonly _workspaceEditingService: IWorkspaceEditingService,
@IStatusbarService private readonly _statusbarService: IStatusbarService,
@INotificationService private readonly _notificationService: INotificationService,
@IWindowService private readonly _windowService: IWindowService,
@IInstantiationService private readonly _instantiationService: IInstantiationService,
@ILabelService private readonly _labelService: ILabelService,
......@@ -66,7 +66,7 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape {
const workspaceFoldersToAdd = foldersToAdd.map(f => ({ uri: URI.revive(f.uri), name: f.name }));
// Indicate in status message
this._statusbarService.setStatusMessage(this.getStatusMessage(extensionName, workspaceFoldersToAdd.length, deleteCount), 10 * 1000 /* 10s */);
this._notificationService.status(this.getStatusMessage(extensionName, workspaceFoldersToAdd.length, deleteCount), { hideAfter: 10 * 1000 /* 10s */ });
return this._workspaceEditingService.updateFolders(index, deleteCount, workspaceFoldersToAdd, true);
}
......
......@@ -5,18 +5,20 @@
import { INotificationsModel, INotificationChangeEvent, NotificationChangeType, INotificationViewItem, IStatusMessageChangeEvent, StatusMessageChangeType, IStatusMessageViewItem } from 'vs/workbench/common/notifications';
import { IStatusbarService, StatusbarAlignment, IStatusbarEntryAccessor, IStatusbarEntry } from 'vs/platform/statusbar/common/statusbar';
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
import { Disposable, IDisposable, dispose } from 'vs/base/common/lifecycle';
import { HIDE_NOTIFICATIONS_CENTER, SHOW_NOTIFICATIONS_CENTER } from 'vs/workbench/browser/parts/notifications/notificationsCommands';
import { localize } from 'vs/nls';
export class NotificationsStatus extends Disposable {
private notificationsCenterStatusItem: IStatusbarEntryAccessor;
private isNotificationsCenterVisible: boolean;
private notificationsCenterStatusItem: IStatusbarEntryAccessor;
private currentNotifications = new Set<INotificationViewItem>();
private statusMessageDispose: IDisposable;
private currentStatusMessage: [IStatusMessageViewItem, IDisposable] | undefined;
private isNotificationsCenterVisible: boolean;
constructor(
private model: INotificationsModel,
@IStatusbarService private readonly statusbarService: IStatusbarService
......@@ -108,7 +110,7 @@ export class NotificationsStatus extends Disposable {
this.currentStatusMessage = [
statusItem,
this.statusbarService.setStatusMessage(statusItem.message, hideAfter, showAfter)
this.doSetStatusMessage(statusItem.message, hideAfter, showAfter)
];
break;
......@@ -123,4 +125,42 @@ export class NotificationsStatus extends Disposable {
break;
}
}
private doSetStatusMessage(message: string, autoDisposeAfter: number = -1, delayBy: number = 0): IDisposable {
// Dismiss any previous
dispose(this.statusMessageDispose);
// Create new
let statusMessageEntry: IStatusbarEntryAccessor;
let showHandle: any = setTimeout(() => {
statusMessageEntry = this.statusbarService.addEntry({ text: message }, StatusbarAlignment.LEFT, -Number.MAX_VALUE /* far right on left hand side */);
showHandle = null;
}, delayBy);
// Dispose function takes care of timeouts and actual entry
let hideHandle: any;
const statusMessageDispose = {
dispose: () => {
if (showHandle) {
clearTimeout(showHandle);
}
if (hideHandle) {
clearTimeout(hideHandle);
}
if (statusMessageEntry) {
statusMessageEntry.dispose();
}
}
};
this.statusMessageDispose = statusMessageDispose;
if (typeof autoDisposeAfter === 'number' && autoDisposeAfter > 0) {
hideHandle = setTimeout(() => statusMessageDispose.dispose(), autoDisposeAfter);
}
return statusMessageDispose;
}
}
\ No newline at end of file
......@@ -51,7 +51,6 @@ export class StatusbarPart extends Part implements IStatusbarService {
//#endregion
private statusMessageDispose: IDisposable;
private styleElement: HTMLStyleElement;
private pendingEntries: PendingEntry[] = [];
......@@ -285,44 +284,6 @@ export class StatusbarPart extends Part implements IStatusbarService {
return el;
}
setStatusMessage(message: string, autoDisposeAfter: number = -1, delayBy: number = 0): IDisposable {
// Dismiss any previous
dispose(this.statusMessageDispose);
// Create new
let statusMessageEntry: IStatusbarEntryAccessor;
let showHandle: any = setTimeout(() => {
statusMessageEntry = this.addEntry({ text: message }, StatusbarAlignment.LEFT, -Number.MAX_VALUE /* far right on left hand side */);
showHandle = null;
}, delayBy);
// Dispose function takes care of timeouts and actual entry
let hideHandle: any;
const statusMessageDispose = {
dispose: () => {
if (showHandle) {
clearTimeout(showHandle);
}
if (hideHandle) {
clearTimeout(hideHandle);
}
if (statusMessageEntry) {
statusMessageEntry.dispose();
}
}
};
this.statusMessageDispose = statusMessageDispose;
if (typeof autoDisposeAfter === 'number' && autoDisposeAfter > 0) {
hideHandle = setTimeout(() => statusMessageDispose.dispose(), autoDisposeAfter);
}
return statusMessageDispose;
}
layout(width: number, height: number): void {
super.layoutContents(width, height);
}
......
......@@ -26,7 +26,6 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import { ITextModel } from 'vs/editor/common/model';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
import { IModeService } from 'vs/editor/common/services/modeService';
import { IStatusbarService } from 'vs/platform/statusbar/common/statusbar';
import { ILabelService } from 'vs/platform/label/common/label';
import { IExtensionEnablementService } from 'vs/platform/extensionManagement/common/extensionManagement';
......@@ -46,7 +45,6 @@ class DefaultFormatter extends Disposable implements IWorkbenchContribution {
@INotificationService private readonly _notificationService: INotificationService,
@IQuickInputService private readonly _quickInputService: IQuickInputService,
@IModeService private readonly _modeService: IModeService,
@IStatusbarService private readonly _statusbarService: IStatusbarService,
@ILabelService private readonly _labelService: ILabelService,
) {
super();
......@@ -97,7 +95,7 @@ class DefaultFormatter extends Disposable implements IWorkbenchContribution {
// formatter does not target this file
const label = this._labelService.getUriLabel(document.uri, { relative: true });
const message = nls.localize('miss', "Extension '{0}' cannot format '{1}'", extension.displayName || extension.name, label);
this._statusbarService.setStatusMessage(message, 4000);
this._notificationService.status(message, { hideAfter: 4000 });
return undefined;
}
} else if (formatter.length === 1) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册