@Override public String getCategoryId() throws NotDefinedException { try { return command.getCategory().getId(); } catch (final org.eclipse.core.commands.common.NotDefinedException e) { throw new NotDefinedException(e); } }
protected static String getText(Object obj) { if (obj instanceof Command) { Command com = (Command) obj; try { return com.getName(); } catch (NotDefinedException e) { return com.getId(); } } else if (obj instanceof Category) { Category cat = (Category) obj; try { return cat.getName(); } catch (NotDefinedException e) { return cat.getId(); } } return ""; //$NON-NLS-1$ }
@Override public final void categoryChanged(CategoryEvent categoryEvent) { if (categoryEvent.isDefinedChanged()) { final Category category = categoryEvent.getCategory(); final String categoryId = category.getId(); final boolean categoryIdAdded = category.isDefined(); if (categoryIdAdded) { definedCategoryIds.add(categoryId); } else { definedCategoryIds.remove(categoryId); } if (isListenerAttached()) { fireCommandManagerChanged(new CommandManagerEvent(this, null, false, false, categoryId, categoryIdAdded, true)); } } }
/** * @param commandManager */ private void generateCategories(MApplication application, CommandManager commandManager) { for (Category cat : commandManager.getDefinedCategories()) { if (categories.containsKey(cat.getId())) { continue; } try { MCategory catModel = modelService.createModelElement(MCategory.class); catModel.setElementId(cat.getId()); catModel.setName(cat.getName()); catModel.setDescription(cat.getDescription()); application.getCategories().add(catModel); categories.put(catModel.getElementId(), catModel); } catch (NotDefinedException e) { // Since we asked for defined commands, this shouldn't be an // issue WorkbenchPlugin.log(e); } } }
@Override public void categoryChanged(CategoryEvent categoryEvent) { if (categoryEvent.isDefinedChanged()) { final Category category = categoryEvent.getCategory(); final String categoryId = category.getId(); final boolean categoryIdAdded = category.isDefined(); if (categoryIdAdded) { definedCategoryIds.add(categoryId); } else { definedCategoryIds.remove(categoryId); } if (isListenerAttached()) { fireCommandManagerChanged(new CommandManagerEvent(this, null, false, false, categoryId, categoryIdAdded, true)); } } }
@Override public final void categoryChanged(CategoryEvent categoryEvent) { if (categoryEvent.isDefinedChanged()) { final Category category = categoryEvent.getCategory(); final String categoryId = category.getId(); final boolean categoryIdAdded = category.isDefined(); if (categoryIdAdded) { definedCategoryIds.add(categoryId); } else { definedCategoryIds.remove(categoryId); } if (isListenerAttached()) { fireCommandManagerChanged(new CommandManagerEvent(this, null, false, false, categoryId, categoryIdAdded, true)); } } }
String categoryId = command.getCategory().getId(); Collection commandIds = (Collection) commandIdsByCategoryId .get(categoryId); if (commandIdsByCategoryId.containsKey(category.getId())) { String name = category.getName(); Collection categories = (Collection) categoriesByName categoryIdsByUniqueName.put(name, category.getId()); categoryUniqueNamesById.put(category.getId(), name); } else { while (iterator2.hasNext()) { Util.translateString(RESOURCE_BUNDLE, "uniqueName"), new Object[] { name, //$NON-NLS-1$ category.getId() }); categoryIdsByUniqueName.put(uniqueName, category .getId()); categoryUniqueNamesById.put(category.getId(), uniqueName);
final MCategory categoryModel = categories.get(cmd.getCategory().getId());
@SuppressWarnings("restriction") @Override public void commandManagerChanged(CommandManagerEvent commandManagerEvent) { if (commandManagerEvent.isCommandChanged()) { if (commandManagerEvent.isCommandDefined()) { final String commandId = commandManagerEvent.getCommandId(); if (findCommand(commandId) != null) { return; } final Command command = commandManagerEvent.getCommandManager().getCommand( commandId); if (command.getHandler() == null) { command.setHandler(HandlerServiceImpl.getHandler(commandId)); } try { MCategory categoryModel = findCategory(command.getCategory().getId()); final MCommand createdCommand = createCommand(command, modelService, categoryModel); application.getCommands().add(createdCommand); } catch (NotDefinedException e) { Activator.getDefault().getLogService() .log(0, "Failed to create command " + commandId, e); //$NON-NLS-1$ } } } } };