use of org.eclipse.core.commands.Category in project eclipse.platform.ui by eclipse-platform.
the class DefineCommandsTest method testCreateWithTwoContexts.
@Test
public void testCreateWithTwoContexts() {
IEclipseContext localContext = workbenchContext.createChild("Level1");
ECommandService cs = localContext.get(ECommandService.class);
assertNotNull(cs);
assertNotNull(cs.defineCategory(TEST_CAT1, "CAT1", null));
Category category = cs.getCategory(TEST_CAT1);
assertNotNull("need category", category);
assertNotNull("command1", cs.defineCommand(TEST_ID1, "ID1", null, category, null));
assertNotNull("command2", cs.defineCommand(TEST_ID2, "ID2", null, category, null));
cs = workbenchContext.get(ECommandService.class);
Command cmd1 = cs.getCommand(TEST_ID1);
assertNotNull("get command1", cmd1);
try {
assertEquals("ID1", cmd1.getName());
} catch (NotDefinedException e) {
fail(e.getMessage());
}
assertNotNull("get command2", cs.getCommand(TEST_ID2));
}
use of org.eclipse.core.commands.Category in project eclipse.platform.ui by eclipse-platform.
the class HeadlessApplicationTest method createApplication.
private MApplication createApplication(IEclipseContext appContext, String appURI) throws Exception {
URI initialWorkbenchDefinitionInstance = URI.createPlatformPluginURI(appURI, true);
ResourceSet set = new ResourceSetImpl();
set.getPackageRegistry().put("http://MApplicationPackage/", ApplicationPackageImpl.eINSTANCE);
Resource resource = set.getResource(initialWorkbenchDefinitionInstance, true);
MApplication application = (MApplication) resource.getContents().get(0);
application.setContext(appContext);
// XXX
appContext.set(MApplication.class, application);
appContext.set(EModelService.class, new ModelServiceImpl(appContext));
ECommandService cs = appContext.get(ECommandService.class);
Category cat = cs.defineCategory(MApplication.class.getName(), "Application Category", // $NON-NLS-1$
null);
List<MCommand> commands = application.getCommands();
for (MCommand cmd : commands) {
String id = cmd.getElementId();
String name = cmd.getCommandName();
cs.defineCommand(id, name, null, cat, null);
}
// take care of generating the contexts.
List<MWindow> windows = application.getChildren();
for (MWindow window : windows) {
E4Workbench.initializeContext(appContext, window);
}
processPartContributions(application.getContext(), resource);
renderer = createPresentationEngine(getEngineURI());
return application;
}
use of org.eclipse.core.commands.Category in project eclipse.platform.ui by eclipse-platform.
the class HandlerTest method defineCommands.
private void defineCommands(IEclipseContext appContext) {
ECommandService cmdService = (ECommandService) appContext.get(ECommandService.class.getName());
Category category = cmdService.defineCategory("cat." + HELP_COMMAND_ID, "Help Category", null);
cmdService.defineCommand(HELP_COMMAND_ID, "Help Command", null, category, null);
cmdService.defineCommand(HELP_COMMAND1_ID, "Help 1 Command", null, category, null);
}
Aggregations