Package org.jboss.forge.addon.ui.controller

Examples of org.jboss.forge.addon.ui.controller.WizardCommandController


   public void testValidateProjectName() throws Exception
   {
      File tempDir = OperatingSystemUtils.createTempDir();
      try
      {
         WizardCommandController wizard = testHarness.createWizardController(NewProjectWizard.class);
         wizard.initialize();
         Assert.assertFalse(wizard.canMoveToNextStep());
         wizard.setValueFor("named", "Test Project Name Invalid");
         wizard.setValueFor("targetLocation", tempDir);
         wizard.setValueFor("topLevelPackage", "org.example");
         wizard.setValueFor("type", "mock");

         Assert.assertFalse(wizard.isValid());
         Assert.assertFalse(wizard.canExecute());

         wizard.setValueFor("named", "Test-Project-Name-Valid");

         Assert.assertTrue(wizard.isValid());
         Assert.assertTrue(wizard.canExecute());

         File targetDirectory = new File(tempDir, "Test-Project-Name-Valid");
         Assert.assertFalse(targetDirectory.exists());
         wizard.execute();

         Assert.assertTrue(targetDirectory.exists());
      }
      finally
      {
View Full Code Here


   private CommandLineParser populate(ShellContext shellContext, String line,
            final Map<String, InputComponent<?, ?>> allInputs, Map<String, InputComponent<?, ?>> lastPage)
            throws Exception
   {
      WizardCommandController controller = getController();
      Map<String, InputComponent<?, ?>> pageInputs = new LinkedHashMap<>(controller.getInputs());
      allInputs.putAll(pageInputs);
      CommandLineParser parser = commandLineUtil.generateParser(controller, shellContext, allInputs);
      CommandLine cmdLine = parser.parse(line, true);
      Map<String, InputComponent<?, ?>> populatedInputs = commandLineUtil.populateUIInputs(cmdLine, allInputs);

      // Second pass to ensure disabled fields are set
      parser = commandLineUtil.generateParser(controller, shellContext, allInputs);
      cmdLine = parser.parse(line, true);
      populatedInputs = commandLineUtil.populateUIInputs(cmdLine, allInputs);
     
      boolean inputsChanged = false;
      for (String input : pageInputs.keySet())
      {
         // TODO: May not work correctly with Subflows
         if (populatedInputs.containsKey(input))
         {
            // Trim inputs from last page, because information from the current page was provided
            lastPage.keySet().removeAll(populatedInputs.keySet());
            allInputs.keySet().removeAll(lastPage.keySet());
            inputsChanged = true;
            break;
         }
      }

      if (controller.canMoveToNextStep())
      {
         controller.next().initialize();
         parser = populate(shellContext, line, allInputs, pageInputs);
      }
      else if (inputsChanged)
      {
         parser = commandLineUtil.generateParser(controller, shellContext, allInputs);
View Full Code Here

   private CommandLineParser populate(ShellContext shellContext, String line,
            final Map<String, InputComponent<?, ?>> allInputs, Map<String, InputComponent<?, ?>> lastPage)
            throws Exception
   {
      WizardCommandController controller = getController();
      Map<String, InputComponent<?, ?>> pageInputs = new HashMap<>(controller.getInputs());
      allInputs.putAll(pageInputs);
      CommandLineParser parser = commandLineUtil.generateParser(controller, shellContext, allInputs);
      CommandLine cmdLine = parser.parse(line, true);
      Map<String, InputComponent<?, ?>> populatedInputs = commandLineUtil.populateUIInputs(cmdLine, allInputs);
      boolean inputsChanged = false;
      for (String input : pageInputs.keySet())
      {
         // TODO: May not work correctly with Subflows
         if (populatedInputs.containsKey(input))
         {
            // Trim inputs from last page, because information from the current page was provided
            lastPage.keySet().removeAll(populatedInputs.keySet());
            allInputs.keySet().removeAll(lastPage.keySet());
            inputsChanged = true;
            break;
         }
      }

      if (controller.canMoveToNextStep())
      {
         controller.next().initialize();
         parser = populate(shellContext, line, allInputs, pageInputs);
      }
      else if (inputsChanged)
      {
         parser = commandLineUtil.generateParser(controller, shellContext, allInputs);
View Full Code Here

   private CommandLineParser populate(ShellContext shellContext, String line,
            final Map<String, InputComponent<?, ?>> allInputs, Map<String, InputComponent<?, ?>> lastPage)
            throws Exception
   {
      WizardCommandController controller = getController();
      Map<String, InputComponent<?, ?>> pageInputs = new LinkedHashMap<>(controller.getInputs());
      allInputs.putAll(pageInputs);
      CommandLineParser parser = commandLineUtil.generateParser(controller, shellContext, allInputs);
      CommandLine cmdLine = parser.parse(line, true);
      Map<String, InputComponent<?, ?>> populatedInputs = commandLineUtil.populateUIInputs(cmdLine, allInputs);

      // Second pass to ensure disabled fields are set
      parser = commandLineUtil.generateParser(controller, shellContext, allInputs);
      cmdLine = parser.parse(line, true);
      populatedInputs = commandLineUtil.populateUIInputs(cmdLine, allInputs);

      boolean inputsChanged = false;
      for (String input : pageInputs.keySet())
      {
         // TODO: May not work correctly with Subflows
         if (populatedInputs.containsKey(input))
         {
            // Trim inputs from last page, because information from the current page was provided
            lastPage.keySet().removeAll(populatedInputs.keySet());
            allInputs.keySet().removeAll(lastPage.keySet());
            inputsChanged = true;
            break;
         }
      }

      if (controller.canMoveToNextStep())
      {
         controller.next().initialize();
         parser = populate(shellContext, line, allInputs, pageInputs);
      }
      else if (inputsChanged)
      {
         parser = commandLineUtil.generateParser(controller, shellContext, allInputs);
View Full Code Here

   }

   @Override
   public void promptRequiredMissingValues(ShellImpl shell)
   {
      WizardCommandController controller = getController();
      promptRequiredMissingValues(shell, controller.getInputs().values());
      while (controller.canMoveToNextStep())
      {
         try
         {
            controller.next().initialize();
         }
         catch (Exception e)
         {
            // TODO: Log this
            break;
         }
         promptRequiredMissingValues(shell, controller.getInputs().values());
      }
   }
View Full Code Here

TOP

Related Classes of org.jboss.forge.addon.ui.controller.WizardCommandController

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.