notifications - remove old message service and adopt new one

This commit is contained in:
Benjamin Pasero
2018-02-19 17:57:12 +01:00
parent 5fc7be8588
commit 9ab2056393
119 changed files with 800 additions and 1905 deletions

View File

@@ -5,20 +5,20 @@
'use strict';
import nls = require('vs/nls');
import { IMessageService } from 'vs/platform/message/common/message';
import Severity from 'vs/base/common/severity';
import { Action } from 'vs/base/common/actions';
import { MainThreadMessageServiceShape, MainContext, IExtHostContext, MainThreadMessageOptions } from '../node/extHost.protocol';
import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers';
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
import { IChoiceService } from 'vs/platform/dialogs/common/dialogs';
import { INotificationService, INotificationHandle } from 'vs/platform/notification/common/notification';
@extHostNamedCustomer(MainContext.MainThreadMessageService)
export class MainThreadMessageService implements MainThreadMessageServiceShape {
constructor(
extHostContext: IExtHostContext,
@IMessageService private readonly _messageService: IMessageService,
@INotificationService private readonly _notificationService: INotificationService,
@IChoiceService private readonly _choiceService: IChoiceService
) {
//
@@ -40,7 +40,7 @@ export class MainThreadMessageService implements MainThreadMessageServiceShape {
return new Promise<number>(resolve => {
let messageHide: Function;
let messageHandle: INotificationHandle;
let actions: MessageItemAction[] = [];
let hasCloseAffordance = false;
@@ -48,7 +48,7 @@ export class MainThreadMessageService implements MainThreadMessageServiceShape {
constructor(id: string, label: string, handle: number) {
super(id, label, undefined, true, () => {
resolve(handle);
messageHide(); // triggers dispose! make sure promise is already resolved
messageHandle.dispose(); // triggers dispose! make sure promise is already resolved
return undefined;
});
}
@@ -68,9 +68,10 @@ export class MainThreadMessageService implements MainThreadMessageServiceShape {
actions.push(new MessageItemAction('__close', nls.localize('close', "Close"), undefined));
}
messageHide = this._messageService.show(severity, {
messageHandle = this._notificationService.notify({
severity,
message,
actions,
actions: { primary: actions },
source: extension && `${extension.displayName || extension.name}`
});
});

View File

@@ -8,10 +8,10 @@ import Event, { Emitter } from 'vs/base/common/event';
import { TPromise } from 'vs/base/common/winjs.base';
import { Disposable } from 'vs/base/common/lifecycle';
import { ExtHostContext, MainThreadTreeViewsShape, ExtHostTreeViewsShape, MainContext, IExtHostContext } from '../node/extHost.protocol';
import { IMessageService, Severity } from 'vs/platform/message/common/message';
import { ITreeViewDataProvider, ITreeItem, ICustomViewsService } from 'vs/workbench/common/views';
import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers';
import { distinct } from 'vs/base/common/arrays';
import { INotificationService } from 'vs/platform/notification/common/notification';
@extHostNamedCustomer(MainContext.MainThreadTreeViews)
export class MainThreadTreeViews extends Disposable implements MainThreadTreeViewsShape {
@@ -22,14 +22,14 @@ export class MainThreadTreeViews extends Disposable implements MainThreadTreeVie
constructor(
extHostContext: IExtHostContext,
@ICustomViewsService private viewsService: ICustomViewsService,
@IMessageService private messageService: IMessageService
@INotificationService private notificationService: INotificationService
) {
super();
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostTreeViews);
}
$registerTreeViewDataProvider(treeViewId: string): void {
const dataProvider = this._register(new TreeViewDataProvider(treeViewId, this._proxy, this.messageService));
const dataProvider = this._register(new TreeViewDataProvider(treeViewId, this._proxy, this.notificationService));
this._dataProviders.set(treeViewId, dataProvider);
this.viewsService.getTreeViewer(treeViewId).dataProvider = dataProvider;
}
@@ -61,7 +61,7 @@ class TreeViewDataProvider implements ITreeViewDataProvider {
constructor(private treeViewId: string,
private _proxy: ExtHostTreeViewsShape,
private messageService: IMessageService
private notificationService: INotificationService
) {
}
@@ -73,7 +73,7 @@ class TreeViewDataProvider implements ITreeViewDataProvider {
.then(children => {
return this.postGetChildren(children);
}, err => {
this.messageService.show(Severity.Error, err);
this.notificationService.error(err);
return [];
});
}

View File

@@ -16,9 +16,9 @@ import { compare } from 'vs/base/common/strings';
import { TernarySearchTree } from 'vs/base/common/map';
import { basenameOrAuthority, isEqual } from 'vs/base/common/resources';
import { isLinux } from 'vs/base/common/platform';
import { Severity } from 'vs/platform/message/common/message';
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
import { localize } from 'vs/nls';
import { Severity } from 'vs/platform/notification/common/notification';
function isFolderEqual(folderA: URI, folderB: URI): boolean {
return isEqual(folderA, folderB, !isLinux);