本文整理汇总了TypeScript中vs/platform/commands/common/commands.CommandsRegistry类的典型用法代码示例。如果您正苦于以下问题:TypeScript CommandsRegistry类的具体用法?TypeScript CommandsRegistry怎么用?TypeScript CommandsRegistry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CommandsRegistry类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: test
test('convert without title and binding to entry', () => {
CommandsRegistry.registerCommand('command_without_keybinding', () => { });
prepareKeybindingService();
return testObject.resolve({}).then(() => {
const actual = testObject.fetch('').filter(element => element.keybindingItem.command === 'command_without_keybinding')[0];
assert.equal(actual.keybindingItem.command, 'command_without_keybinding');
assert.equal(actual.keybindingItem.commandLabel, '');
assert.equal(actual.keybindingItem.commandDefaultLabel, null);
assert.equal(actual.keybindingItem.keybinding, null);
assert.equal(actual.keybindingItem.when, '');
});
});
开发者ID:JarnoNijboer,项目名称:vscode,代码行数:13,代码来源:keybindingsEditorModel.test.ts
示例2: appendSaveConflictEditorTitleAction
function appendSaveConflictEditorTitleAction(id: string, title: string, iconPath: { dark: string; light?: string; }, order: number, command: ICommandHandler): void {
// Command
CommandsRegistry.registerCommand(id, command);
// Action
MenuRegistry.appendMenuItem(MenuId.EditorTitle, {
command: { id, title, iconPath },
when: ContextKeyExpr.equals(CONFLICT_RESOLUTION_CONTEXT, true),
group: 'navigation',
order
});
}
开发者ID:sameer-coder,项目名称:vscode,代码行数:13,代码来源:fileActions.contribution.ts
示例3: setTimeout
setTimeout(() => {
// Register the command after some time
actualOrder.push('registering command');
let reg = CommandsRegistry.registerCommand(event.substr('onCommand:'.length), () => {
actualOrder.push('executing command');
});
disposables.push(reg);
setTimeout(() => {
// Resolve the activation event after some more time
actualOrder.push('resolving activation event');
resolve();
}, 10);
}, 10);
开发者ID:PKRoma,项目名称:vscode,代码行数:14,代码来源:commandService.test.ts
示例4: _registerWorkbenchCommandFromAction
private _registerWorkbenchCommandFromAction(descriptor: SyncActionDescriptor, alias: string, category?: string): IDisposable {
let registrations: IDisposable[] = [];
// command
registrations.push(CommandsRegistry.registerCommand(descriptor.id, this._createCommandHandler(descriptor)));
// keybinding
const when = descriptor.keybindingContext;
const weight = (typeof descriptor.keybindingWeight === 'undefined' ? KeybindingsRegistry.WEIGHT.workbenchContrib() : descriptor.keybindingWeight);
const keybindings = descriptor.keybindings;
KeybindingsRegistry.registerKeybindingRule({
id: descriptor.id,
weight: weight,
when: when,
primary: keybindings && keybindings.primary,
secondary: keybindings && keybindings.secondary,
win: keybindings && keybindings.win,
mac: keybindings && keybindings.mac,
linux: keybindings && keybindings.linux
});
// menu item
// TODO@Rob slightly weird if-check required because of
// https://github.com/Microsoft/vscode/blob/master/src/vs/workbench/parts/search/electron-browser/search.contribution.ts#L266
if (descriptor.label) {
let idx = alias.indexOf(': ');
let categoryOriginal;
if (idx > 0) {
categoryOriginal = alias.substr(0, idx);
alias = alias.substr(idx + 2);
}
const command = {
id: descriptor.id,
title: { value: descriptor.label, original: alias },
category: category && { value: category, original: categoryOriginal }
};
MenuRegistry.addCommand(command);
registrations.push(MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command }));
}
// TODO@alex,joh
// support removal of keybinding rule
// support removal of command-ui
return combinedDisposable(registrations);
}
开发者ID:AlexxNica,项目名称:sqlopsstudio,代码行数:49,代码来源:actions.ts
示例5: test
test('!onReady, but executeCommand', function () {
let callCounter = 0;
let reg = CommandsRegistry.registerCommand('bar', () => callCounter += 1);
let service = new CommandService(new InstantiationService(), new class extends NullExtensionService {
whenInstalledExtensionsRegistered() {
return new Promise<boolean>(_resolve => { /*ignore*/ });
}
}, new NullLogService());
service.executeCommand('bar');
assert.equal(callCounter, 1);
reg.dispose();
});
开发者ID:joelday,项目名称:vscode,代码行数:15,代码来源:commandService.test.ts
示例6: registerWorkbenchCommandFromAction
private registerWorkbenchCommandFromAction(descriptor: SyncActionDescriptor, alias: string, category?: string, when?: ContextKeyExpr): IDisposable {
const registrations = new DisposableStore();
// command
registrations.add(CommandsRegistry.registerCommand(descriptor.id, this.createCommandHandler(descriptor)));
// keybinding
const weight = (typeof descriptor.keybindingWeight === 'undefined' ? KeybindingWeight.WorkbenchContrib : descriptor.keybindingWeight);
const keybindings = descriptor.keybindings;
KeybindingsRegistry.registerKeybindingRule({
id: descriptor.id,
weight: weight,
when: (descriptor.keybindingContext || when ? ContextKeyExpr.and(descriptor.keybindingContext, when) : null),
primary: keybindings ? keybindings.primary : 0,
secondary: keybindings && keybindings.secondary,
win: keybindings && keybindings.win,
mac: keybindings && keybindings.mac,
linux: keybindings && keybindings.linux
});
// menu item
// TODO@Rob slightly weird if-check required because of
// https://github.com/Microsoft/vscode/blob/master/src/vs/workbench/contrib/search/electron-browser/search.contribution.ts#L266
if (descriptor.label) {
let idx = alias.indexOf(': ');
let categoryOriginal = '';
if (idx > 0) {
categoryOriginal = alias.substr(0, idx);
alias = alias.substr(idx + 2);
}
const command: ICommandAction = {
id: descriptor.id,
title: { value: descriptor.label, original: alias },
category: category ? { value: category, original: categoryOriginal } : undefined
};
MenuRegistry.addCommand(command);
registrations.add(MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command, when }));
}
// TODO@alex,joh
// support removal of keybinding rule
// support removal of command-ui
return registrations;
}
开发者ID:PKRoma,项目名称:vscode,代码行数:48,代码来源:actions.ts
示例7: test
test('!onReady, but executeCommand', function () {
let callCounter = 0;
let reg = CommandsRegistry.registerCommand('bar', () => callCounter += 1);
let resolve: Function;
let service = new CommandService(new InstantiationService(), new class extends SimpleExtensionService {
onReady() {
return new TPromise<boolean>(_resolve => { resolve = _resolve; });
}
});
return service.executeCommand('bar').then(() => {
reg.dispose();
assert.equal(callCounter, 1);
});
});
开发者ID:armanio123,项目名称:vscode,代码行数:17,代码来源:commandService.test.ts
示例8: test
test('dispose calls unregister', function () {
let lastUnregister: string;
const shape = new class extends mock<MainThreadCommandsShape>() {
$registerCommand(id: string): void {
//
}
$unregisterCommand(id: string): void {
lastUnregister = id;
}
};
const commands = new ExtHostCommands(SingleProxyRPCProtocol(shape), undefined, new NullLogService());
commands.registerCommand(true, 'foo', (): any => { }).dispose();
assert.equal(lastUnregister, 'foo');
assert.equal(CommandsRegistry.getCommand('foo'), undefined);
});
开发者ID:AllureFer,项目名称:vscode,代码行数:19,代码来源:extHostCommands.test.ts
示例9: test
test('dispose calls unregister', function () {
let lastUnregister: string;
const shape = new class extends mock<MainThreadCommandsShape>() {
$registerCommand(id: string): TPromise<any> {
return undefined;
}
$unregisterCommand(id: string): TPromise<any> {
lastUnregister = id;
return undefined;
}
};
const commands = new ExtHostCommands(OneGetThreadService(shape), undefined, new NoopLogService());
commands.registerCommand('foo', (): any => { }).dispose();
assert.equal(lastUnregister, 'foo');
assert.equal(CommandsRegistry.getCommand('foo'), undefined);
});
开发者ID:AlexxNica,项目名称:sqlopsstudio,代码行数:20,代码来源:extHostCommands.test.ts
示例10: registerWorkspaceActions
(function registerWorkspaceActions(): void {
const workspacesCategory = nls.localize('workspaces', "Workspaces");
registry.registerWorkbenchAction(new SyncActionDescriptor(AddRootFolderAction, AddRootFolderAction.ID, AddRootFolderAction.LABEL), 'Workspaces: Add Folder to Workspace...', workspacesCategory, SupportsWorkspacesContext);
registry.registerWorkbenchAction(new SyncActionDescriptor(GlobalRemoveRootFolderAction, GlobalRemoveRootFolderAction.ID, GlobalRemoveRootFolderAction.LABEL), 'Workspaces: Remove Folder from Workspace...', workspacesCategory);
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenWorkspaceAction, OpenWorkspaceAction.ID, OpenWorkspaceAction.LABEL), 'Workspaces: Open Workspace...', workspacesCategory, SupportsWorkspacesContext);
registry.registerWorkbenchAction(new SyncActionDescriptor(SaveWorkspaceAsAction, SaveWorkspaceAsAction.ID, SaveWorkspaceAsAction.LABEL), 'Workspaces: Save Workspace As...', workspacesCategory, SupportsWorkspacesContext);
registry.registerWorkbenchAction(new SyncActionDescriptor(DuplicateWorkspaceInNewWindowAction, DuplicateWorkspaceInNewWindowAction.ID, DuplicateWorkspaceInNewWindowAction.LABEL), 'Workspaces: Duplicate Workspace in New Window', workspacesCategory);
CommandsRegistry.registerCommand(OpenWorkspaceConfigFileAction.ID, serviceAccessor => {
serviceAccessor.get(IInstantiationService).createInstance(OpenWorkspaceConfigFileAction, OpenWorkspaceConfigFileAction.ID, OpenWorkspaceConfigFileAction.LABEL).run();
});
MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
command: {
id: OpenWorkspaceConfigFileAction.ID,
title: { value: `${workspacesCategory}: ${OpenWorkspaceConfigFileAction.LABEL}`, original: 'Workspaces: Open Workspace Configuration File' },
},
when: WorkbenchStateContext.isEqualTo('workspace')
});
})();
开发者ID:joelday,项目名称:vscode,代码行数:21,代码来源:main.contribution.ts
注:本文中的vs/platform/commands/common/commands.CommandsRegistry类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论