/** * Returns the action group which is appropriate for placing the action for executing the given * command. If appropriate action group doesn't exist it will be created and added to the right * place. */ private DefaultActionGroup getActionGroupForCommand(CommandImpl command) { String goalId = command.getGoal(); if (isNullOrEmpty(goalId)) { goalId = goalRegistry.getDefaultGoal().getId(); } DefaultActionGroup commandGoalPopUpGroup = goalPopUpGroups.get(goalId); if (commandGoalPopUpGroup == null) { commandGoalPopUpGroup = goalPopUpGroupFactory.create(goalId); actionManager.registerAction(GOAL_ACTION_GROUP_ID_PREFIX + goalId, commandGoalPopUpGroup); goalPopUpGroups.put(goalId, commandGoalPopUpGroup); commandsActionGroup.add(commandGoalPopUpGroup); } return commandGoalPopUpGroup; }
/** * Removes action for executing the given command and removes the appropriate action group in case * it's empty. */ private void removeAction(CommandImpl command) { Action commandAction = commandActions.remove(command.getName()); if (commandAction != null) { removeAction(commandAction); // remove action from it's action group String goalId = command.getGoal(); if (isNullOrEmpty(goalId)) { goalId = goalRegistry.getDefaultGoal().getId(); } DefaultActionGroup goalPopUpGroup = goalPopUpGroups.get(goalId); if (goalPopUpGroup != null) { goalPopUpGroup.remove(commandAction); } } } }
@Override protected void initialize() { String goal = editedCommand.getGoal(); initialGoal = isNullOrEmpty(goal) ? goalRegistry.getDefaultGoal().getId() : goal; view.setAvailableGoals(goalRegistry.getAllGoals()); view.setGoal(initialGoal); }