message.ts 1.9 KB
Newer Older
E
Erich Gamma 已提交
1 2 3 4 5 6 7
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/
'use strict';

import nls = require('vs/nls');
A
Alex Dima 已提交
8
import {TPromise} from 'vs/base/common/winjs.base';
E
Erich Gamma 已提交
9
import Severity from 'vs/base/common/severity';
10
import {createDecorator} from 'vs/platform/instantiation/common/instantiation';
E
Erich Gamma 已提交
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
import {Action} from 'vs/base/common/actions';

export interface IMessageWithAction {
	message: string;
	actions: Action[];
}

export interface IConfirmation {
	title?: string;
	message: string;
	detail?: string;
	primaryButton?: string;
	secondaryButton?: string;
}

B
Benjamin Pasero 已提交
26
export const CloseAction = new Action('close.message', nls.localize('close', "Close"), null, true, () => TPromise.as(true));
27 28
export const LaterAction = new Action('later.message', nls.localize('later', "Later"), null, true, () => TPromise.as(true));
export const CancelAction = new Action('cancel.message', nls.localize('cancel', "Cancel"), null, true, () => TPromise.as(true));
E
Erich Gamma 已提交
29

B
Benjamin Pasero 已提交
30
export const IMessageService = createDecorator<IMessageService>('messageService');
E
Erich Gamma 已提交
31 32

export interface IMessageService {
33
	_serviceBrand: any;
E
Erich Gamma 已提交
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56

	/**
	 * Tells the service to show a message with a given severity
	 * the returned function can be used to hide the message again
	 */
	show(sev: Severity, message: string): () => void;
	show(sev: Severity, message: Error): () => void;
	show(sev: Severity, message: string[]): () => void;
	show(sev: Severity, message: Error[]): () => void;
	show(sev: Severity, message: IMessageWithAction): () => void;

	/**
	 * Hide any messages showing currently.
	 */
	hideAll(): void;

	/**
	 * Ask the user for confirmation.
	 */
	confirm(confirmation: IConfirmation): boolean;
}

export import Severity = Severity;