/** * Groups the given {@code commands} by its goal. * * @return map that contains the given {@code commands} grouped by its goal */ public Map<CommandGoal, List<CommandImpl>> groupCommandsByGoal(List<CommandImpl> commands) { final Map<CommandGoal, List<CommandImpl>> commandsByGoal = new HashMap<>(); for (CommandImpl command : commands) { final String goalId = command.getGoal(); final CommandGoal commandGoal = goalRegistry.getGoalForId(goalId); commandsByGoal.computeIfAbsent(commandGoal, key -> new ArrayList<>()).add(command); } return commandsByGoal; }
/** Set the specified goal name for the currently edited command. */ private void setGoal(String goalName) { editedCommand.setGoal(goalName); Set<CommandGoal> allGoals = goalRegistry.getAllGoals(); allGoals.add(goalRegistry.getGoalForId(goalName)); view.setAvailableGoals(allGoals); view.setGoal(goalName); notifyDirtyStateChanged(); }
@Inject GoalPopUpGroup( @Assisted String goalId, ActionManager actionManager, CommandGoalRegistry goalRegistry, IconRegistry iconRegistry) { super(actionManager); this.iconRegistry = iconRegistry; commandGoal = goalRegistry.getGoalForId(goalId); setPopup(true); // set icon final SVGResource commandTypeIcon = getCommandGoalIcon(); if (commandTypeIcon != null) { getTemplatePresentation().setImageElement(new SVGImage(commandTypeIcon).getElement()); } }