mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-07 09:35:41 -05:00
Merge VS Code 1.23.1 (#1520)
This commit is contained in:
@@ -1,40 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IChannel } from 'vs/base/parts/ipc/common/ipc';
|
||||
import { IChoiceService } from 'vs/platform/dialogs/common/dialogs';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
|
||||
export interface IChoiceChannel extends IChannel {
|
||||
call(command: 'choose'): TPromise<number>;
|
||||
call(command: string, arg?: any): TPromise<any>;
|
||||
}
|
||||
|
||||
export class ChoiceChannel implements IChoiceChannel {
|
||||
|
||||
constructor( @IChoiceService private choiceService: IChoiceService) {
|
||||
}
|
||||
|
||||
call(command: string, args?: [Severity, string, string[], number, boolean]): TPromise<any> {
|
||||
switch (command) {
|
||||
case 'choose': return this.choiceService.choose(args[0], args[1], args[2], args[3], args[4]);
|
||||
}
|
||||
return TPromise.wrapError(new Error('invalid command'));
|
||||
}
|
||||
}
|
||||
|
||||
export class ChoiceChannelClient implements IChoiceService {
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
constructor(private channel: IChoiceChannel) { }
|
||||
|
||||
choose(severity: Severity, message: string, options: string[], cancelId?: number, modal?: boolean): TPromise<number> {
|
||||
return this.channel.call('choose', [severity, message, options, cancelId, modal]);
|
||||
}
|
||||
}
|
||||
46
src/vs/platform/dialogs/common/dialogIpc.ts
Normal file
46
src/vs/platform/dialogs/common/dialogIpc.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IChannel } from 'vs/base/parts/ipc/common/ipc';
|
||||
import { IDialogService, IConfirmation, IConfirmationResult } from 'vs/platform/dialogs/common/dialogs';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
|
||||
export interface IDialogChannel extends IChannel {
|
||||
call(command: 'show'): TPromise<number>;
|
||||
call(command: 'confirm'): TPromise<IConfirmationResult>;
|
||||
call(command: string, arg?: any): TPromise<any>;
|
||||
}
|
||||
|
||||
export class DialogChannel implements IDialogChannel {
|
||||
|
||||
constructor(@IDialogService private dialogService: IDialogService) {
|
||||
}
|
||||
|
||||
call(command: string, args?: any[]): TPromise<any> {
|
||||
switch (command) {
|
||||
case 'show': return this.dialogService.show(args[0], args[1], args[2]);
|
||||
case 'confirm': return this.dialogService.confirm(args[0]);
|
||||
}
|
||||
return TPromise.wrapError(new Error('invalid command'));
|
||||
}
|
||||
}
|
||||
|
||||
export class DialogChannelClient implements IDialogService {
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
constructor(private channel: IDialogChannel) { }
|
||||
|
||||
show(severity: Severity, message: string, options: string[]): TPromise<number> {
|
||||
return this.channel.call('show', [severity, message, options]);
|
||||
}
|
||||
|
||||
confirm(confirmation: IConfirmation): TPromise<IConfirmationResult> {
|
||||
return this.channel.call('confirm', [confirmation]);
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,9 @@
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { basename } from 'vs/base/common/paths';
|
||||
import { localize } from 'vs/nls';
|
||||
|
||||
export interface IConfirmation {
|
||||
title?: string;
|
||||
@@ -22,63 +25,66 @@ export interface IConfirmation {
|
||||
}
|
||||
|
||||
export interface IConfirmationResult {
|
||||
|
||||
/**
|
||||
* Will be true if the dialog was confirmed with the primary button
|
||||
* pressed.
|
||||
*/
|
||||
confirmed: boolean;
|
||||
|
||||
/**
|
||||
* This will only be defined if the confirmation was created
|
||||
* with the checkox option defined.
|
||||
*/
|
||||
checkboxChecked?: boolean;
|
||||
}
|
||||
|
||||
export const IConfirmationService = createDecorator<IConfirmationService>('confirmationService');
|
||||
export const IDialogService = createDecorator<IDialogService>('dialogService');
|
||||
|
||||
export interface IConfirmationService {
|
||||
export interface IDialogOptions {
|
||||
cancelId?: number;
|
||||
detail?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* A service to bring up modal dialogs.
|
||||
*
|
||||
* Note: use the `INotificationService.prompt()` method for a non-modal way to ask
|
||||
* the user for input.
|
||||
*/
|
||||
export interface IDialogService {
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
/**
|
||||
* Ask the user for confirmation with a modal dialog.
|
||||
*/
|
||||
confirm(confirmation: IConfirmation): TPromise<boolean>;
|
||||
confirm(confirmation: IConfirmation): TPromise<IConfirmationResult>;
|
||||
|
||||
/**
|
||||
* Ask the user for confirmation with a checkbox in a modal dialog.
|
||||
* Present a modal dialog to the user.
|
||||
*
|
||||
* @returns A promise with the selected choice index. If the user refused to choose,
|
||||
* then a promise with index of `cancelId` option is returned. If there is no such
|
||||
* option then promise with index `0` is returned.
|
||||
*/
|
||||
confirmWithCheckbox(confirmation: IConfirmation): TPromise<IConfirmationResult>;
|
||||
show(severity: Severity, message: string, buttons: string[], options?: IDialogOptions): TPromise<number>;
|
||||
}
|
||||
|
||||
export const IChoiceService = createDecorator<IChoiceService>('choiceService');
|
||||
const MAX_CONFIRM_FILES = 10;
|
||||
export function getConfirmMessage(start: string, resourcesToConfirm: URI[]): string {
|
||||
const message = [start];
|
||||
message.push('');
|
||||
message.push(...resourcesToConfirm.slice(0, MAX_CONFIRM_FILES).map(r => basename(r.fsPath)));
|
||||
|
||||
/**
|
||||
* The choices to present to the user. The `ISecondaryChoice` hint allows to control where
|
||||
* choices appear when the `modal` option is set to `false`. In that case, the choices
|
||||
* are presented as part of a notification and secondary choices will appear less
|
||||
* prominent.
|
||||
*/
|
||||
export interface SecondaryChoice {
|
||||
label: string;
|
||||
keepOpen?: boolean;
|
||||
}
|
||||
export type PrimaryChoice = string;
|
||||
export type Choice = PrimaryChoice | SecondaryChoice;
|
||||
if (resourcesToConfirm.length > MAX_CONFIRM_FILES) {
|
||||
if (resourcesToConfirm.length - MAX_CONFIRM_FILES === 1) {
|
||||
message.push(localize('moreFile', "...1 additional file not shown"));
|
||||
} else {
|
||||
message.push(localize('moreFiles', "...{0} additional files not shown", resourcesToConfirm.length - MAX_CONFIRM_FILES));
|
||||
}
|
||||
}
|
||||
|
||||
export interface IChoiceService {
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
/**
|
||||
* Prompt the user for a choice between multiple choices.
|
||||
*
|
||||
* @param choices the choices to present to the user. The `isSecondary` hint allows
|
||||
* to control where are presented as part of a notification and secondary choices will
|
||||
* appear less choices appear when the `modal` option is set to `false`. In that case,
|
||||
* the choices prominent.
|
||||
*
|
||||
* @param when `modal` is true, this will block the user until chooses.
|
||||
*
|
||||
* @returns A promise with the selected choice index. The promise is cancellable
|
||||
* which hides the message. The promise can return an error, meaning that
|
||||
* the user refused to choose.
|
||||
*
|
||||
* When `modal` is true and user refused to choose, then promise with index of
|
||||
* `Cancel` option is returned. If there is no such option then promise with
|
||||
* `0` index is returned.
|
||||
*/
|
||||
choose(severity: Severity, message: string, choices: Choice[], cancelId?: number, modal?: boolean): TPromise<number>;
|
||||
message.push('');
|
||||
return message.join('\n');
|
||||
}
|
||||
@@ -5,14 +5,15 @@
|
||||
|
||||
import * as readline from 'readline';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IChoiceService } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { IDialogService, IConfirmation, IConfirmationResult } from 'vs/platform/dialogs/common/dialogs';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import { localize } from 'vs/nls';
|
||||
|
||||
export class ChoiceCliService implements IChoiceService {
|
||||
export class CommandLineDialogService implements IDialogService {
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
choose(severity: Severity, message: string, options: string[]): TPromise<number> {
|
||||
show(severity: Severity, message: string, options: string[]): TPromise<number> {
|
||||
const promise = new TPromise<number>((c, e) => {
|
||||
const rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
@@ -55,4 +56,12 @@ export class ChoiceCliService implements IChoiceService {
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
confirm(confirmation: IConfirmation): TPromise<IConfirmationResult> {
|
||||
return this.show(Severity.Info, confirmation.message, [confirmation.primaryButton, confirmation.secondaryButton || localize('cancel', "Cancel")]).then(index => {
|
||||
return {
|
||||
confirmed: index === 0
|
||||
} as IConfirmationResult;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user