當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript actions.MenuRegistry類代碼示例

本文整理匯總了TypeScript中vs/platform/actions/common/actions.MenuRegistry的典型用法代碼示例。如果您正苦於以下問題:TypeScript MenuRegistry類的具體用法?TypeScript MenuRegistry怎麽用?TypeScript MenuRegistry使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了MenuRegistry類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: test

	test('group sorting', function () {

		disposables.push(MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
			command: { id: 'one', title: 'FOO' },
			group: '0_hello'
		}));

		disposables.push(MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
			command: { id: 'two', title: 'FOO' },
			group: 'hello'
		}));

		disposables.push(MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
			command: { id: 'three', title: 'FOO' },
			group: 'Hello'
		}));

		disposables.push(MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
			command: { id: 'four', title: 'FOO' },
			group: ''
		}));

		disposables.push(MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
			command: { id: 'five', title: 'FOO' },
			group: 'navigation'
		}));

		const groups = menuService.createMenu(MenuId.ExplorerContext, contextKeyService).getActions();

		assert.equal(groups.length, 5);
		const [one, two, three, four, five] = groups;

		assert.equal(one[0], 'navigation');
		assert.equal(two[0], '0_hello');
		assert.equal(three[0], 'hello');
		assert.equal(four[0], 'Hello');
		assert.equal(five[0], '');
	});
開發者ID:StateFarmIns,項目名稱:vscode,代碼行數:38,代碼來源:menuService.test.ts

示例2: registerAction

function registerAction(desc: IActionDescriptor) {

	const {id, handler, title, category, iconClass, f1, menu, keybinding} = desc;

	// 1) register as command
	CommandsRegistry.registerCommand(id, handler);

	// 2) command palette
	let command = { id, title, iconClass, category };
	if (f1) {
		MenuRegistry.addCommand(command);
	}

	// 3) menus
	if (menu) {
		let {menuId, when, group} = menu;
		MenuRegistry.appendMenuItem(menuId, {
			command,
			when,
			group
		});
	}

	// 4) keybindings
	if (keybinding) {
		let {when, weight, keys} = keybinding;
		KeybindingsRegistry.registerKeybindingRule({
			id,
			when,
			weight,
			primary: keys.primary,
			secondary: keys.secondary,
			linux: keys.linux,
			mac: keys.mac,
			win: keys.win
		});
	}
}
開發者ID:thinhpham,項目名稱:vscode,代碼行數:38,代碼來源:output.contribution.ts

示例3: test

	test('special MenuId palette', function () {

		disposables.push(MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
			command: { id: 'a', title: 'Explicit' }
		}));

		MenuRegistry.addCommand({ id: 'b', title: 'Implicit' });

		let foundA = false;
		let foundB = false;
		for (const item of MenuRegistry.getMenuItems(MenuId.CommandPalette)) {
			if (item.command.id === 'a') {
				assert.equal(item.command.title, 'Explicit');
				foundA = true;
			}
			if (item.command.id === 'b') {
				assert.equal(item.command.title, 'Implicit');
				foundB = true;
			}
		}
		assert.equal(foundA, true);
		assert.equal(foundB, true);
	});
開發者ID:SeanKilleen,項目名稱:vscode,代碼行數:23,代碼來源:menuService.test.ts

示例4: forEach

		forEach(value, entry => {
			if (!schema.isValidMenuItems(entry.value, collector)) {
				return;
			}

			const menu = schema.parseMenuId(entry.key);
			if (!menu) {
				collector.warn(localize('menuId.invalid', "`{0}` is not a valid menu identifier", entry.key));
				return;
			}

			for (let item of entry.value) {
				let command = MenuRegistry.getCommand(item.command);
				let alt = item.alt && MenuRegistry.getCommand(item.alt);

				if (!command) {
					collector.warn(localize('missing.command', "Menu item references a command `{0}` which is not defined in the 'commands' section.", item.command));
				}
				if (item.alt && !alt) {
					collector.warn(localize('missing.altCommand', "Menu item references an alt-command `{0}` which is not defined in the 'commands' section.", item.alt));
				}
				if (item.command === item.alt) {
					collector.info(localize('dupe.command', "Menu item references the same command as default and alt-command"));
				}

				if (item.alt && menu !== MenuId.EditorTitle && item.group !== 'navigation') {
					collector.info(localize('nosupport.altCommand', "Sorry, but currently only the 'navigation' group of the 'editor/title' menu supports alt-commands"));
				}

				MenuRegistry.appendMenuItem(menu, {
					command,
					alt,
					group: item.group || undefined,
					when: KbExpr.deserialize(item.when)
				});
			}
		});
開發者ID:baltth,項目名稱:vscode,代碼行數:37,代碼來源:menusExtensionPoint.ts

示例5: test

	test('in group sorting, by title and order', function () {

		disposables.push(MenuRegistry.appendMenuItem(testMenuId, {
			command: { id: 'a', title: 'aaa' },
			group: 'Hello',
			order: 10
		}));

		disposables.push(MenuRegistry.appendMenuItem(testMenuId, {
			command: { id: 'b', title: 'fff' },
			group: 'Hello'
		}));

		disposables.push(MenuRegistry.appendMenuItem(testMenuId, {
			command: { id: 'c', title: 'zzz' },
			group: 'Hello',
			order: -1
		}));

		disposables.push(MenuRegistry.appendMenuItem(testMenuId, {
			command: { id: 'd', title: 'yyy' },
			group: 'Hello',
			order: -1
		}));

		const groups = menuService.createMenu(testMenuId, contextKeyService).getActions();

		assert.equal(groups.length, 1);
		const [, actions] = groups[0];

		assert.equal(actions.length, 4);
		const [one, two, three, four] = actions;
		assert.equal(one.id, 'd');
		assert.equal(two.id, 'c');
		assert.equal(three.id, 'b');
		assert.equal(four.id, 'a');
	});
開發者ID:developers23,項目名稱:vscode,代碼行數:37,代碼來源:menuService.test.ts

示例6: preferencesMenuRegistration

function preferencesMenuRegistration() {
	MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, {
		group: '1_settings',
		command: {
			id: 'workbench.action.openSettings',
			title: nls.localize({ key: 'miOpenSettings', comment: ['&& denotes a mnemonic'] }, "&&Settings")
		},
		order: 1
	});

	MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, {
		group: '2_keybindings',
		command: {
			id: 'workbench.action.openGlobalKeybindings',
			title: nls.localize({ key: 'miOpenKeymap', comment: ['&& denotes a mnemonic'] }, "&&Keyboard Shortcuts")
		},
		order: 1
	});

	MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, {
		group: '2_keybindings',
		command: {
			id: 'workbench.extensions.action.showRecommendedKeymapExtensions',
			title: nls.localize({ key: 'miOpenKeymapExtensions', comment: ['&& denotes a mnemonic'] }, "&&Keymap Extensions")
		},
		order: 2
	});

	MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, {
		group: '3_snippets',
		command: {
			id: 'workbench.action.openSnippets',
			title: nls.localize({ key: 'miOpenSnippets', comment: ['&& denotes a mnemonic'] }, "User &&Snippets")
		},
		order: 1
	});

	MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, {
		group: '4_themes',
		command: {
			id: 'workbench.action.selectTheme',
			title: nls.localize({ key: 'miSelectColorTheme', comment: ['&& denotes a mnemonic'] }, "&&Color Theme")
		},
		order: 1
	});

	MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, {
		group: '4_themes',
		command: {
			id: 'workbench.action.selectIconTheme',
			title: nls.localize({ key: 'miSelectIconTheme', comment: ['&& denotes a mnemonic'] }, "File &&Icon Theme")
		},
		order: 2
	});
}
開發者ID:liunian,項目名稱:vscode,代碼行數:55,代碼來源:menubar.contribution.ts

示例7: 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

示例8: handleCommand

	function handleCommand(userFriendlyCommand: schema.IUserFriendlyCommand, extension: IExtensionPointUser<any>) {

		if (!schema.isValidCommand(userFriendlyCommand, extension.collector)) {
			return;
		}

		const { icon, category, title, command } = userFriendlyCommand;

		let absoluteIcon: { dark: URI; light?: URI; };
		if (icon) {
			if (typeof icon === 'string') {
				absoluteIcon = { dark: resources.joinPath(extension.description.extensionLocation, icon) };
			} else {
				absoluteIcon = {
					dark: resources.joinPath(extension.description.extensionLocation, icon.dark),
					light: resources.joinPath(extension.description.extensionLocation, icon.light)
				};
			}
		}

		if (MenuRegistry.addCommand({ id: command, title, category, iconLocation: absoluteIcon })) {
			extension.collector.info(localize('dup', "Command `{0}` appears multiple times in the `commands` section.", userFriendlyCommand.command));
		}
	}
開發者ID:burhandodhy,項目名稱:azuredatastudio,代碼行數:24,代碼來源:menusExtensionPoint.ts

示例9: writeFile

					].join('\n');
					return writeFile(snippetPath, defaultContent).then(() => {
						return openFile(snippetPath);
					}, (err) => {
						errors.onUnexpectedError(nls.localize('openSnippet.errorOnCreate', 'Unable to create {0}', snippetPath));
					});
				});
			}
			return TPromise.as(null);
		});
	});

	MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
		command: {
			id,
			title: { value: nls.localize('openSnippet.label', "Open User Snippets"), original: 'Preferences: Open User Snippets' },
			category: nls.localize('preferences', "Preferences")
		}
	});
}


const schemaId = 'vscode://schemas/snippets';
const schema: IJSONSchema = {
	'id': schemaId,
	'defaultSnippets': [{
		'label': nls.localize('snippetSchema.json.default', "Empty snippet"),
		'body': { '${1:snippetName}': { 'prefix': '${2:prefix}', 'body': '${3:snippet}', 'description': '${4:description}' } }
	}],
	'type': 'object',
	'description': nls.localize('snippetSchema.json', 'User snippet configuration'),
開發者ID:armanio123,項目名稱:vscode,代碼行數:31,代碼來源:snippets.contribution.ts

示例10: appendToCommandPalette

appendToCommandPalette(REVERT_FILE_COMMAND_ID, nls.localize('revert', "Revert File"), category);
appendToCommandPalette(COMPARE_WITH_SAVED_COMMAND_ID, nls.localize('compareActiveWithSaved', "Compare Active File with Saved"), category);
appendToCommandPalette(REVEAL_IN_OS_COMMAND_ID, REVEAL_IN_OS_LABEL, category);
appendToCommandPalette(SAVE_FILE_AS_COMMAND_ID, SAVE_FILE_AS_LABEL, category);
appendToCommandPalette(CLOSE_EDITOR_COMMAND_ID, nls.localize('closeEditor', "Close Editor"), nls.localize('view', "View"));


// Menu registration - open editors

const openToSideCommand = {
	id: OPEN_TO_SIDE_COMMAND_ID,
	title: nls.localize('openToSide', "Open to the Side")
};
MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
	group: 'navigation',
	order: 10,
	command: openToSideCommand,
	when: ResourceContextKey.HasResource
});

const revealInOsCommand = {
	id: REVEAL_IN_OS_COMMAND_ID,
	title: isWindows ? nls.localize('revealInWindows', "Reveal in Explorer") : isMacintosh ? nls.localize('revealInMac', "Reveal in Finder") : nls.localize('openContainer', "Open Containing Folder")
};
MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
	group: 'navigation',
	order: 20,
	command: revealInOsCommand,
	when: ResourceContextKey.Scheme.isEqualTo('file')
});

const copyPathCommand = {
開發者ID:servicesgpr,項目名稱:vscode,代碼行數:32,代碼來源:fileActions.contribution.ts


注:本文中的vs/platform/actions/common/actions.MenuRegistry類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。