org.jboss.forge.addon.ui.output.UIOutput Java Examples

The following examples show how to use org.jboss.forge.addon.ui.output.UIOutput. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RunCommand.java    From thorntail-addon with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Result execute(UIExecutionContext context)
{
   Project project = getSelectedProject(context);
   UIOutput output = context.getUIContext().getProvider().getOutput();
   PackagingFacet packagingFacet = project.getFacet(PackagingFacet.class);
   try
   {
      packagingFacet.createBuilder().addArguments("thorntail:run").runTests(false).build(output.out(),
               output.err());
   }
   catch (BuildException ie)
   {
      if (!(ie.getCause() instanceof InterruptedException))
      {
         return Results.fail("Error while running the build", ie.getCause());
      }
   }
   return Results.success();
}
 
Example #2
Source File: AbstractDevOpsCommand.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
public PrintStream getOut() {
    UIOutput output = getOutput();
    if (output != null) {
        return output.out();
    } else {
        return System.out;
    }
}
 
Example #3
Source File: AbstractKubernetesCommand.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
public PrintStream getOut() {
    UIOutput output = getOutput();
    if (output != null) {
        return output.out();
    } else {
        return System.out;
    }
}
 
Example #4
Source File: ListFractionsCommand.java    From thorntail-addon with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Result execute(UIExecutionContext executionContext) {
    UIProvider provider = executionContext.getUIContext().getProvider();
    UIOutput output = provider.getOutput();
    PrintStream out = output.out();
    for (FractionDescriptor fraction : ThorntailFacet.getAllFractionDescriptors()) {
        if (!fraction.isInternal()) {
            String msg = String.format("%s: %s (%s)", fraction.getArtifactId(), fraction.getName(),
                    fraction.getDescription());
            out.println(msg);
        }
    }
    return Results.success();
}
 
Example #5
Source File: RestUIProvider.java    From fabric8-forge with Apache License 2.0 4 votes vote down vote up
@Override
public UIOutput getOutput() {
    return output;
}
 
Example #6
Source File: RestUIProvider.java    From fabric8-forge with Apache License 2.0 4 votes vote down vote up
@Override
public UIOutput getOutput() {
	return output;
}
 
Example #7
Source File: AbstractDevOpsCommand.java    From fabric8-forge with Apache License 2.0 4 votes vote down vote up
public UIOutput getOutput() {
    UIProvider provider = getUiProvider();
    return provider != null ? provider.getOutput() : null;
}
 
Example #8
Source File: AbstractKubernetesCommand.java    From fabric8-forge with Apache License 2.0 4 votes vote down vote up
public UIOutput getOutput() {
    UIProvider provider = getUiProvider();
    return provider != null ? provider.getOutput() : null;
}
 
Example #9
Source File: DetectFractionsCommand.java    From thorntail-addon with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public Result execute(UIExecutionContext executionContext) throws Exception
{
   UIProgressMonitor progressMonitor = executionContext.getProgressMonitor();
   UIOutput output = executionContext.getUIContext().getProvider().getOutput();
   FractionUsageAnalyzer analyzer = ThorntailFacet.getFractionUsageAnalyzer();
   DirectoryResource value = inputDir.getValue();
   analyzer.source(value.getUnderlyingResourceObject());
   Project project = getSelectedProject(executionContext);
   int total = 1;
   if (build.getValue())
      total++;
   if (depend.getValue())
      total++;
   progressMonitor.beginTask("Detecting fractions", total);
   if (build.getValue())
   {
      PackagingFacet packaging = project.getFacet(PackagingFacet.class);
      progressMonitor.setTaskName("Building the project...");
      FileResource<?> finalArtifact = packaging.createBuilder().build(output.out(), output.err())
               .reify(FileResource.class);
      analyzer.source(finalArtifact.getUnderlyingResourceObject());
      progressMonitor.worked(1);
   }
   Collection<FractionDescriptor> detectedFractions = analyzer.detectNeededFractions();
   output.info(output.out(), "Detected fractions: " + detectedFractions);
   progressMonitor.worked(1);
   if (depend.getValue() && detectedFractions.size() > 0)
   {
      progressMonitor.setTaskName("Adding missing fractions as project dependencies...");
      ThorntailFacet facet = project.getFacet(ThorntailFacet.class);
      detectedFractions.removeAll(facet.getInstalledFractions());
      // detectedFractions.remove(fractionList.getFractionDescriptor(Swarm.DEFAULT_FRACTION_GROUPID, "container"));
      if (detectedFractions.isEmpty())
      {
         output.warn(output.out(), "Project already contains all the installed fractions. Doing nothing.");
      }
      else
      {
         output.info(output.out(), "Installing the following dependencies: " + detectedFractions);
         facet.installFractions(detectedFractions);
      }
      progressMonitor.worked(1);
   }
   progressMonitor.done();
   return Results.success();
}
 
Example #10
Source File: WindupCommand.java    From windup with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public Result execute(UIExecutionContext context) throws Exception
{
    if (!this.promptMessages.isEmpty())
    {
        for (ValidationResult message : promptMessages)
        {
            UIOutput output = context.getUIContext().getProvider().getOutput();
            output.warn(output.out(), message.getMessage());
        }

        if (context.getPrompt().promptBoolean("Would you like to continue?", true) == false)
        {
            return Results.fail("Aborted by the user.");
        }
    }

    WindupConfiguration windupConfiguration = new WindupConfiguration();
    for (Entry<ConfigurationOption, InputComponent<?, ?>> entry : this.inputOptions.entrySet())
    {
        ConfigurationOption option = entry.getKey();
        String name = option.getName();
        Object value = getValueForInput(option, entry.getValue());
        windupConfiguration.setOptionValue(name, value);
    }

    windupConfiguration.useDefaultDirectories();

    Boolean overwrite = (Boolean) windupConfiguration.getOptionMap().get(OverwriteOption.NAME);
    if (overwrite == null)
    {
        overwrite = false;
    }

    if (!overwrite && pathNotEmpty(windupConfiguration.getOutputDirectory().toFile()))
    {
        String promptMsg = "Overwrite all contents of \"" + windupConfiguration.getOutputDirectory().toString()
                    + "\" (anything already in the directory will be deleted)?";
        if (!context.getPrompt().promptBoolean(promptMsg, false))
        {
            String outputPath = windupConfiguration.getOutputDirectory().toString();
            return Results.fail("Files exist in " + outputPath + ", but --overwrite not specified. Aborting!");
        }
    }

    /*
     * Put this in the context for debugging, and unit tests (or anything else that needs it).
     */
    context.getUIContext().getAttributeMap().put(WindupConfiguration.class, windupConfiguration);

    FileUtils.deleteQuietly(windupConfiguration.getOutputDirectory().toFile());
    Path graphPath = windupConfiguration.getOutputDirectory().resolve("graph");
    try (GraphContext graphContext = graphContextFactory.create(graphPath, true))
    {
        context.getUIContext().getAttributeMap().put(GraphContext.class, graphContext);
        UIProgressMonitor uiProgressMonitor = context.getProgressMonitor();
        WindupProgressMonitor progressMonitor = new WindupProgressMonitorAdapter(uiProgressMonitor);
        windupConfiguration
                    .setProgressMonitor(progressMonitor)
                    .setGraphContext(graphContext);
        processor.execute(windupConfiguration);

        uiProgressMonitor.done();

        Path indexHtmlPath = windupConfiguration.getOutputDirectory().resolve("index.html").normalize().toAbsolutePath();
        return Results.success("Report created: " + indexHtmlPath + System.getProperty("line.separator")
                    + "              Access it at this URL: " + indexHtmlPath.toUri());
    }
}