Skip to content

Commit

Permalink
FORGE-1570: Fixed scenario where UICommands become wizards
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Feb 13, 2014
1 parent 7613606 commit b225b6a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@
import org.jboss.forge.addon.shell.ui.ShellContext;
import org.jboss.forge.addon.shell.ui.ShellContextImpl;
import org.jboss.forge.addon.ui.command.UICommand;
import org.jboss.forge.addon.ui.controller.CommandController;
import org.jboss.forge.addon.ui.controller.CommandControllerFactory;
import org.jboss.forge.addon.ui.controller.SingleCommandController;
import org.jboss.forge.addon.ui.controller.WizardCommandController;
import org.jboss.forge.addon.ui.util.Commands;
import org.jboss.forge.addon.ui.wizard.UIWizard;

/**
* Forge implementation of {@link CommandRegistry}.
Expand Down Expand Up @@ -128,15 +129,14 @@ private AbstractShellInteraction findCommand(ShellContext shellContext, String c
{
if (commandName.equals(commandManager.getCommandName(shellContext, cmd)))
{
if (cmd instanceof UIWizard)
CommandController controller = commandFactory.createController(shellContext, shell, cmd);
if (controller instanceof WizardCommandController)
{
result = new ShellWizard(commandFactory.createWizardController(shellContext, shell, (UIWizard) cmd),
shellContext, cmdLineUtil, this);
result = new ShellWizard((WizardCommandController) controller, shellContext, cmdLineUtil, this);
}
else
{
result = new ShellSingleCommand(commandFactory.createSingleController(shellContext, shell, cmd),
shellContext, cmdLineUtil);
result = new ShellSingleCommand(controller, shellContext, cmdLineUtil);
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import java.util.List;
import java.util.Map;
import java.util.logging.Level;

import org.jboss.forge.addon.ui.command.UICommand;
import org.jboss.forge.addon.ui.context.UIContext;
Expand All @@ -18,6 +19,7 @@
import org.jboss.forge.addon.ui.metadata.UICommandMetadata;
import org.jboss.forge.addon.ui.output.UIMessage;
import org.jboss.forge.addon.ui.result.Result;
import org.jboss.logmanager.Logger;

/**
* This decorator supresses the pages where no {@link InputComponent} is provided
Expand All @@ -27,6 +29,7 @@
public class NoUIWizardControllerDecorator implements WizardCommandController
{
private final WizardCommandControllerImpl controller;
private static final Logger log = Logger.getLogger(NoUIWizardControllerDecorator.class.getName());

public NoUIWizardControllerDecorator(WizardCommandControllerImpl controller)
{
Expand Down Expand Up @@ -61,9 +64,9 @@ public boolean canMoveToNextStep()
}
}
}
catch (Exception ignored)
catch (Exception e)
{

log.log(Level.SEVERE, "Error while navigating to next step", e);
}
finally
{
Expand Down

0 comments on commit b225b6a

Please sign in to comment.