/** * Fetch registered action from command manager and constructs actions which should be registered * in action manager and context menus. */ private void registerActions() { commandManagerProvider.get().getCommands().forEach(ExecuteCommandActionManager.this::addAction); }
@Override public Set<CommandGoal> getAllGoals() { Set<CommandGoal> goals = getAllPredefinedGoals(); goals.addAll( commandManagerProvider .get() .getCommands() .stream() .map(command -> getGoalForId(command.getGoal())) .collect(toSet())); return goals; }
private void refreshView() { final Map<CommandGoal, List<CommandImpl>> commandsByGoals = new HashMap<>(); // all predefined command goals must be shown in the view // so populate map by all registered command goals for (CommandGoal goal : goalRegistry.getAllPredefinedGoals()) { commandsByGoals.put(goal, new ArrayList<>()); } commandsByGoals.putAll(commandUtils.groupCommandsByGoal(commandManager.getCommands())); view.setCommands(commandsByGoals); } }
@Override public void onFilterChanged(String filterValue) { final List<CommandImpl> filteredCommands = commandManager.getCommands(); if (!filterValue.isEmpty()) { filteredCommands.removeIf(command -> !containsIgnoreCase(command.getName(), filterValue)); } view.setCommands(commandUtils.groupCommandsByGoal(filteredCommands)); }
commandManagerProvider .get() .getCommands() .stream() .map(CommandImpl::getName)
public void showDialog() { view.showDialog(); view.setCommands(commandUtils.groupCommandsByGoal(commandManager.getCommands())); }
@Inject public ExecuteCommandPresenter( ExecuteCommandView view, CommandManager commandManager, Provider<CommandExecutor> commandExecutorProvider, CommandCreationGuide commandCreationGuide, RunGoal runGoal, DebugGoal debugGoal, EventBus eventBus) { this.view = view; this.commandExecutorProvider = commandExecutorProvider; this.commandCreationGuide = commandCreationGuide; view.setDelegate(this); goals = new HashSet<>(); goals.add(runGoal); goals.add(debugGoal); eventBus.addHandler( CommandsLoadedEvent.getType(), e -> commandManager.getCommands().forEach(view::addCommand)); eventBus.addHandler(CommandAddedEvent.getType(), e -> view.addCommand(e.getCommand())); eventBus.addHandler(CommandRemovedEvent.getType(), e -> view.removeCommand(e.getCommand())); eventBus.addHandler( CommandUpdatedEvent.getType(), e -> { view.removeCommand(e.getInitialCommand()); view.addCommand(e.getUpdatedCommand()); }); }