1+ /*---------------------------------------------------------------------------------------------
2+ * Copyright (c) Microsoft Corporation. All rights reserved.
3+ * Licensed under the MIT License. See License.txt in the project root for license information.
4+ *--------------------------------------------------------------------------------------------*/
5+ 'use strict' ;
6+
7+ import { TPromise } from 'vs/base/common/winjs.base' ;
8+ import Severity from 'vs/base/common/severity' ;
9+ import { createDecorator } from 'vs/platform/instantiation/common/instantiation' ;
10+
11+ export interface IConfirmation {
12+ title ?: string ;
13+ type ?: 'none' | 'info' | 'error' | 'question' | 'warning' ;
14+ message : string ;
15+ detail ?: string ;
16+ primaryButton ?: string ;
17+ secondaryButton ?: string ;
18+ checkbox ?: {
19+ label : string ;
20+ checked ?: boolean ;
21+ } ;
22+ }
23+
24+ export interface IConfirmationResult {
25+ confirmed : boolean ;
26+ checkboxChecked ?: boolean ;
27+ }
28+
29+ export const IConfirmationService = createDecorator < IConfirmationService > ( 'confirmationService' ) ;
30+
31+ export interface IConfirmationService {
32+
33+ _serviceBrand : any ;
34+
35+ /**
36+ * Ask the user for confirmation.
37+ */
38+ confirm ( confirmation : IConfirmation ) : TPromise < boolean > ;
39+
40+ /**
41+ * Ask the user for confirmation with a checkbox.
42+ */
43+ confirmWithCheckbox ( confirmation : IConfirmation ) : TPromise < IConfirmationResult > ;
44+ }
45+
46+ export const IChoiceService = createDecorator < IChoiceService > ( 'choiceService' ) ;
47+
48+ export interface IChoiceService {
49+
50+ _serviceBrand : any ;
51+
52+ /**
53+ * Prompt the user for a choice between multiple options.
54+ *
55+ * @param when `modal` is true, this will block the user until chooses.
56+ *
57+ * @returns A promise with the selected choice index. The promise is cancellable
58+ * which hides the message. The promise can return an error, meaning that
59+ * the user refused to choose.
60+ *
61+ * When `modal` is true and user refused to choose, then promise with index of
62+ * `Cancel` option is returned. If there is no such option then promise with
63+ * `0` index is returned.
64+ */
65+ choose ( severity : Severity , message : string , options : string [ ] , cancelId : number , modal ?: boolean ) : TPromise < number > ;
66+ }
0 commit comments