/** * @param bindingTables * @param id * @return true if this BT already exists */ private boolean contains(List<MBindingTable> bindingTables, String id) { for (MBindingTable bt : bindingTables) { if (id.equals(bt.getBindingContext().getElementId())) { return true; } } return false; }
private void gatherTables(List<MBindingTable> bindingTables) { for (MBindingTable table : bindingTables) { tables.put(table.getBindingContext().getElementId(), table); keys.addAll(table.getBindings()); } }
private void gatherCommands(List<MCommand> commandList) { for (MCommand cmd : commandList) { commands.put(cmd.getElementId(), cmd); } }
/** * @param handler * @param context */ private void processActiveHandler(MHandler handler, IEclipseContext context) { MCommand command = handler.getCommand(); if (command != null) { String commandId = command.getElementId(); if (handler.getObject() == null) { IContributionFactory contributionFactory = (IContributionFactory) context .get(IContributionFactory.class.getName()); handler.setObject(contributionFactory.create(handler.getContributionURI(), context)); } EHandlerService handlerService = (EHandlerService) context.get(EHandlerService.class .getName()); handlerService.activateHandler(commandId, handler.getObject()); } }
private MBindingTable createTable(MApplication application, String contextId) { MBindingTable table = CommandsFactoryImpl.eINSTANCE.createBindingTable(); table.setBindingContext(getBindingContext(application, contextId)); table.setElementId(contextId); application.getBindingTables().add(table); tables.put(table.getBindingContext().getElementId(), table); return table; }
private void defineBinding(BindingTable bindingTable, Context bindingContext, MKeyBinding binding) { String keySequence = binding.getKeySequence(); if( keySequence != null ) { Binding keyBinding = createBinding(bindingContext, binding.getCommand(), binding.getParameters(), keySequence, binding); if (keyBinding != null && !binding.getTags().contains(EBindingService.DELETED_BINDING_TAG)) { bindingTable.addBinding(keyBinding); } } }
private void gatherContexts(MBindingContext ctx) { if (ctx == null) { return; } contexts.put(ctx.getElementId(), ctx); gatherContexts(ctx.getChildren()); } }
private void removeBindings() { for (MKeyBinding key : keys) { if (!key.getTags().contains("type:user")) { //$NON-NLS-1$ EObject obj = ((EObject) key).eContainer(); if (obj instanceof MBindingTable) { MBindingTable table = (MBindingTable) obj; table.getBindings().remove(key); } } } }
public MBindingContext getBindingContext(MApplication application, String id) { // cache MBindingContext result = contexts.get(id); if (result == null) { // search result = searchContexts(id, application.getRootContext()); if (result == null) { // create result = MCommandsFactory.INSTANCE.createBindingContext(); result.setElementId(id); result.setName("Auto::" + id); //$NON-NLS-1$ application.getRootContext().add(result); } if (result != null) { contexts.put(id, result); } } return result; }
private void createCategory(MCategory catModel) { Category category = commandService.getCategory(catModel.getElementId()); if (!category.isDefined()) { category.define(localize(catModel.getName(), catModel), localize(catModel.getDescription(), catModel)); } }
private void undefineContext(MBindingContext current) { Context context = contextManager.getContext(current.getElementId()); context.undefine(); }
protected MCategory findCategory(String id) { final List<MCategory> categories = application.getCategories(); for (MCategory cat : categories) { if (id.equals(cat.getElementId())) { return cat; } } return null; }
protected MCommand findCommand(String commandId) { for (MCommand cmd : application.getCommands()) { if (commandId.equals(cmd.getElementId())) { return cmd; } } return null; }
/** * @param bindingTable */ private void defineBindingTable(MBindingTable bindingTable) { final Context bindingContext = this.contextManager.getContext(bindingTable.getBindingContext().getElementId()); BindingTable table = this.bindingTables.getTable(bindingTable.getBindingContext().getElementId()); if (table == null && bindingContext != null) { table = new BindingTable(bindingContext); this.bindingTables.addTable(table); } for (MKeyBinding binding : bindingTable.getBindings()) { defineBinding(table, bindingContext, binding); } }
/** * @param ctx */ private void gatherContexts(MBindingContext ctx) { if (ctx == null) { return; } contexts.put(ctx.getElementId(), ctx); gatherContexts(ctx.getChildren()); }
public MBindingContext getBindingContext(String id) { // cache MBindingContext result = bindingContexts.get(id); if (result == null) { // search result = searchContexts(id, application.getRootContext()); if (result == null) { // create result = MCommandsFactory.INSTANCE.createBindingContext(); result.setElementId(id); result.setName("Auto::" + id); //$NON-NLS-1$ application.getRootContext().add(result); } if (result != null) { bindingContexts.put(id, result); } } return result; }
public MCommand getCommand(String elementId) { if (elementIdToCommandMap == null) { Map<String, MCommand> result = new HashMap<String, MCommand>(); for (MCommand command : getCommands()) { MCommand otherCommand = result.put(command.getElementId(), command); if (otherCommand != null) { result.put(command.getElementId(), otherCommand); } } elementIdToCommandMap = result; } return elementIdToCommandMap.get(elementId); }
private MBindingContext searchContexts(String id, List<MBindingContext> rootContext) { for (MBindingContext context : rootContext) { if (context.getElementId().equals(id)) { return context; } MBindingContext result = searchContexts(id, context.getChildren()); if (result != null) { return result; } } return null; }
public MBindingContext getBindingContext(String id) { // cache MBindingContext result = bindingContexts.get(id); if (result == null) { // search result = searchContexts(id, application.getRootContext()); if (result == null) { // create result = MCommandsFactory.INSTANCE.createBindingContext(); result.setElementId(id); result.setName("Auto::" + id); //$NON-NLS-1$ application.getRootContext().add(result); } if (result != null) { bindingContexts.put(id, result); } } return result; }
public MCommand getCommand(String elementId) { if (elementIdToCommandMap == null) { Map<String, MCommand> result = new HashMap<String, MCommand>(); for (MCommand command : getCommands()) { MCommand otherCommand = result.put(command.getElementId(), command); if (otherCommand != null) { result.put(command.getElementId(), otherCommand); } } elementIdToCommandMap = result; } return elementIdToCommandMap.get(elementId); }