提交 845c2048 编写于 作者: B Benjamin Pasero

Assign accelerator keys to dialog buttons (fixes #1693)

上级 101bd39e
......@@ -709,13 +709,13 @@ export class BaseDeleteFileAction extends BaseFileAction {
confirm = {
message: this.element.isDirectory ? nls.localize('confirmMoveTrashMessageFolder', "Are you sure you want to delete '{0}' and its contents?", this.element.name) : nls.localize('confirmMoveTrashMessageFile', "Are you sure you want to delete '{0}'?", this.element.name),
detail: isWindows ? nls.localize('undoBin', "You can restore from the recycle bin.") : nls.localize('undoTrash', "You can restore from the trash."),
primaryButton: isWindows ? nls.localize('deleteButtonLabelRecycleBin', "Move to Recycle Bin") : nls.localize('deleteButtonLabelTrash', "Move to Trash")
primaryButton: isWindows ? nls.localize('deleteButtonLabelRecycleBin', "&&Move to Recycle Bin") : nls.localize('deleteButtonLabelTrash', "&&Move to Trash")
};
} else {
confirm = {
message: this.element.isDirectory ? nls.localize('confirmDeleteMessageFolder', "Are you sure you want to permanently delete '{0}' and its contents?", this.element.name) : nls.localize('confirmDeleteMessageFile', "Are you sure you want to permanently delete '{0}'?", this.element.name),
detail: nls.localize('irreversible', "This action is irreversible!"),
primaryButton: nls.localize('deleteButtonLabel', "Delete")
primaryButton: nls.localize('deleteButtonLabel', "&&Delete")
};
}
......@@ -879,7 +879,7 @@ export class ImportFileAction extends BaseFileAction {
let confirm: IConfirmation = {
message: nls.localize('confirmOverwrite', "A file or folder with the same name already exists in the destination folder. Do you want to replace it?"),
detail: nls.localize('irreversible', "This action is irreversible!"),
primaryButton: nls.localize('replaceButtonLabel', "Replace")
primaryButton: nls.localize('replaceButtonLabel', "&&Replace")
};
overwrite = this.messageService.confirm(confirm);
......
......@@ -867,7 +867,7 @@ export class FileDragAndDrop implements Tree.IDragAndDrop {
let confirm: IConfirmation = {
message: nls.localize('confirmOverwriteMessage', "'{0}' already exists in the destination folder. Do you want to replace it?", source.name),
detail: nls.localize('irreversible', "This action is irreversible!"),
primaryButton: nls.localize('replaceButtonLabel', "Replace")
primaryButton: nls.localize('replaceButtonLabel', "&&Replace")
};
if (this.messageService.confirm(confirm)) {
......
......@@ -172,8 +172,8 @@ export class TextFileService extends AbstractTextFileService {
// Windows: Save | Don't Save | Cancel
// Mac/Linux: Save | Cancel | Don't
const save = { label: resourcesToConfirm.length > 1 ? nls.localize('saveAll', "Save All") : nls.localize('save', "Save"), result: ConfirmResult.SAVE };
const dontSave = { label: nls.localize('dontSave', "Don't Save"), result: ConfirmResult.DONT_SAVE };
const save = { label: resourcesToConfirm.length > 1 ? this.mnemonicLabel(nls.localize('saveAll', "&&Save All")) : this.mnemonicLabel(nls.localize('save', "&&Save")), result: ConfirmResult.SAVE };
const dontSave = { label: this.mnemonicLabel(nls.localize('dontSave', "Do&&n't Save")), result: ConfirmResult.DONT_SAVE };
const cancel = { label: nls.localize('cancel', "Cancel"), result: ConfirmResult.CANCEL };
const buttons = [save];
......@@ -198,6 +198,14 @@ export class TextFileService extends AbstractTextFileService {
return buttons[choice].result;
}
private mnemonicLabel(label: string): string {
if (!isWindows) {
return label.replace(/&&/g, ''); // no mnemonic support on mac/linux in buttons yet
}
return label.replace(/&&/g, '&');
}
public saveAll(includeUntitled?: boolean): TPromise<ITextFileOperationResult>;
public saveAll(resources: URI[]): TPromise<ITextFileOperationResult>;
public saveAll(arg1?: any): TPromise<ITextFileOperationResult> {
......
......@@ -435,7 +435,7 @@ export abstract class BaseUndoAction extends GitAction {
detail: count === 1
? nls.localize('confirmUndoAllOne', "There are unstaged changes in {0} file.\n\nThis action is irreversible!", count)
: nls.localize('confirmUndoAllMultiple', "There are unstaged changes in {0} files.\n\nThis action is irreversible!", count),
primaryButton: nls.localize('cleanChangesLabel', "Clean Changes")
primaryButton: nls.localize('cleanChangesLabel', "&&Clean Changes")
};
}
......@@ -444,7 +444,7 @@ export abstract class BaseUndoAction extends GitAction {
return {
message: nls.localize('confirmUndo', "Are you sure you want to clean changes in '{0}'?", label),
detail: nls.localize('irreversible', "This action is irreversible!"),
primaryButton: nls.localize('cleanChangesLabel', "Clean Changes")
primaryButton: nls.localize('cleanChangesLabel', "&&Clean Changes")
};
}
......@@ -977,7 +977,7 @@ export class PublishAction extends GitAction {
const result = this.messageService.confirm({
message: nls.localize('confirmPublishMessage', "Are you sure you want to publish '{0}' to '{1}'?", branchName, remoteName),
primaryButton: nls.localize('confirmPublishMessageButton', "Publish")
primaryButton: nls.localize('confirmPublishMessageButton', "&&Publish")
});
promise = TPromise.as(result ? remoteName : null);
......
......@@ -717,7 +717,7 @@ class TaskService extends EventEmitter implements ITaskService {
if (this._taskSystem && this._taskSystem.isActiveSync()) {
if (this._taskSystem.canAutoTerminate() || this.messageService.confirm({
message: nls.localize('TaskSystem.runningTask', 'There is a task running. Do you want to terminate it?'),
primaryButton: nls.localize('TaskSystem.terminateTask', "Terminate Task")
primaryButton: nls.localize('TaskSystem.terminateTask', "&&Terminate Task")
})) {
return this._taskSystem.terminate().then((response) => {
if (response.success) {
......
......@@ -9,6 +9,7 @@ import {IWindowService} from 'vs/workbench/services/window/electron-browser/wind
import nls = require('vs/nls');
import {WorkbenchMessageService} from 'vs/workbench/services/message/browser/messageService';
import {IConfirmation} from 'vs/platform/message/common/message';
import {isWindows} from 'vs/base/common/platform';
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
import {IKeybindingService} from 'vs/platform/keybinding/common/keybindingService';
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
......@@ -28,7 +29,7 @@ export class MessageService extends WorkbenchMessageService {
public confirm(confirmation: IConfirmation): boolean {
if (!confirmation.primaryButton) {
confirmation.primaryButton = nls.localize('yesButton', "Yes");
confirmation.primaryButton = nls.localize('yesButton', "&&Yes");
}
if (!confirmation.secondaryButton) {
......@@ -39,8 +40,8 @@ export class MessageService extends WorkbenchMessageService {
title: confirmation.title || this.contextService.getConfiguration().env.appName,
message: confirmation.message,
buttons: [
confirmation.primaryButton,
confirmation.secondaryButton
this.mnemonicLabel(confirmation.primaryButton),
this.mnemonicLabel(confirmation.secondaryButton)
],
noLink: true,
cancelId: 1
......@@ -54,4 +55,12 @@ export class MessageService extends WorkbenchMessageService {
return result === 0 ? true : false;
}
private mnemonicLabel(label: string): string {
if (!isWindows) {
return label.replace(/&&/g, ''); // no mnemonic support on mac/linux in buttons yet
}
return label.replace(/&&/g, '&');
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册