private void notifyCommandRemoved(CommandImpl command) { eventBus.fireEvent(new CommandRemovedEvent(command)); }
@Override public void onCommandRemoved(CommandRemovedEvent event) { if (event.getCommand().getName().equals(editedCommand.getName())) { editorAgent.closeEditor(this); commandRemovedHandlerRegistration.removeHandler(); } } }
@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()); }); }
@Override protected void initializeEditor(EditorAgent.OpenEditorCallback callback) { commandRemovedHandlerRegistration = eventBus.addHandler(CommandRemovedEvent.getType(), this); final VirtualFile file = getEditorInput().getFile(); if (file instanceof CommandFileNode) { // make a copy of the given command to avoid modifying of the provided command editedCommand = new CommandImpl(((CommandFileNode) file).getData()); initializePages(); pages.forEach(page -> view.addPage(page.getView(), page.getTitle())); callback.onEditorOpened(this); } else { callback.onInitializationFailed(); } }
eventBus.addHandler(CommandRemovedEvent.getType(), e -> removeAction(e.getCommand())); eventBus.addHandler( CommandUpdatedEvent.getType(),
eventBus.addHandler(CommandRemovedEvent.getType(), e -> refreshView()); eventBus.addHandler(CommandUpdatedEvent.getType(), e -> refreshView()); eventBus.addHandler(CommandsLoadedEvent.getType(), e -> refreshView());