@Override public Result execute(UIExecutionContext shellContext) throws Exception { StringBuilder sb = new StringBuilder(); Iterable<String> value = arguments.getValue(); if (value != null) { for (String val : value) { sb.append(val).append(' '); } } shellContext.getUIContext().getProvider().getOutput().out().println(sb); return Results.success(); } }
@Override public Result execute(UIExecutionContext context) { final Result result; Project project = getSelectedProject(context.getUIContext()); DependencyFacet deps = project.getFacet(DependencyFacet.class); String name = named.getValue(); String urlValue = url.getValue(); if (deps.hasRepository(urlValue)) { result = Results.fail("Repository exists [" + url + "]"); } else { deps.addRepository(name, urlValue); result = Results.success("Added repository [" + name + "->" + urlValue + "]"); } return result; }
@Override public NavigationResult next(UINavigationContext context) throws Exception { applyUIValues(context.getUIContext()); final DatabaseType database = dbType.getValue(); if (!isNotEmbeddedDB(database)) { return Results.navigateTo(FinishJPASetupCommand.class); } else { if (dataSourceName.hasValue()) { // if we specified a datasource, use it return Results.navigateTo(AddJNDIDatasourceCommand.class); } else { // otherwise, we're using the DB URL, so deal with it return Results.navigateTo(AddDBURLCommand.class); } } }
@Override public Result execute(UIExecutionContext context) throws Exception { Map<Object, Object> attributeMap = context.getUIContext().getAttributeMap(); LOG.info("devops tab has attributes:: " + attributeMap); try { return Results.success(""); } catch (IllegalArgumentException e) { return Results.fail(e.getMessage()); } }
private Result verifyProject(final Project project) { final Collection<String> problems = getProblems(project); if (problems.isEmpty()) { return Results.success(); } else { final StringBuilder messageBuilder = new StringBuilder(); messageBuilder.append(String.format( "There are some problems with your project (%s) preventing the installation of Errai with this Addon.", project.getRootDirectory().getUnderlyingResourceObject().getAbsolutePath())); for (final String problem : problems) { messageBuilder.append(problem); } return Results.fail(messageBuilder.toString()); } }
@Override public Result execute(UIExecutionContext context) throws Exception { Project project = getSelectedProject(context); UIOutput output = context.getUIContext().getProvider().getOutput(); PackagingFacet packagingFacet = project.getFacet(PackagingFacet.class); try { packagingFacet.createBuilder().addArguments("wildfly-swarm: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(); }
@Override public Result execute(UIExecutionContext context) throws Exception { UIContext uiContext = context.getUIContext(); Project project = (Project) uiContext.getAttributeMap().get(Project.class); if (project == null) { project = getSelectedProject(context.getUIContext()); MetadataFacet metadataFacet = project.getFacet(MetadataFacet.class); File folder = project.getRoot().reify(DirectoryResource.class).getUnderlyingResourceObject(); String fabric8Deps = csbFabric8.toString(); String bootVersion = springBootVersion.getValue() + ".RELEASE"; return Results.success("Created new Spring Boot project in directory: " + folder.getName());
@Override public Result execute(UIExecutionContext context) throws Exception Result result = Results.success("Project named '" + named.getValue() + "' has been created."); DirectoryResource targetDir = getTargetDirectory(); boolean overwriteDir = overwrite.getValue() || useTargetLocationRoot.getValue(); if (targetDir.mkdirs() || overwriteDir) PackagingFacet packagingFacet = project.getFacet(PackagingFacet.class); if (finalName.hasValue()) facetFactory.install(project, stack.getValue()); result = Results.aggregate( Arrays.asList(result, Results.success("Stack '" + stackFacet.getStack().getName() + "' installed in project"))); uiContext.setSelection(project.getRoot()); uiContext.getAttributeMap().put(Project.class, project); result = Results.fail("Could not create project of type: [" + value + "]"); result = Results.fail("Could not create target location: " + targetDir);
@Override public Result execute(UIExecutionContext context) throws Exception UIContext uiContext = context.getUIContext(); UIOutput uiOutput = uiContext.getProvider().getOutput(); Project project = (Project) uiContext.getAttributeMap().get(Project.class); if (project == null) project = getSelectedProject(context.getUIContext()); String bootVersion = springBootVersion.getValue(); final Integer portValue = port.getValue(); if (portValue != 8080) { final Properties properties = new Properties(); final Boolean createStatic = createStaticContent.getValue(); if (createStatic) { final ResourcesFacet resourcesFacet = project.getFacet(ResourcesFacet.class); final FileResource<?> staticDir = resourcesFacet.getResource("static"); if (!staticDir.exists()) { return Results.success( "Created new Spring Boot project in directory: " + folder.getName());
@Override public Result execute(UIExecutionContext context) throws Exception { GitIgnoreFacet facet = getSelectedProject(context).getFacet(GitIgnoreFacet.class); GitIgnoreResource resource = gitIgnoreResource(context.getUIContext()); StringBuffer buffer = new StringBuffer(); for (String template : templates.getValue().split(" ")) { String content = facet.contentOf(template); buffer.append(content).append("\n"); } String content = buffer.toString(); resource.setContents(content); StringBuilder resultString = new StringBuilder(); resultString.append("Wrote to .gitignore. Content:").append("\n"); resultString.append(content).append("\n"); context.getUIContext().setSelection(resource); return Results.success(resultString.toString()); }
@Override public Result execute(UIExecutionContext context) throws Exception { DatabaseType chosenDbType = dbType.getValue(); String chosenScope = scope.getValue(); String chosenVersion = version.getValue(); if (chosenVersion == null) { List<String> versions = getVersionsFor(chosenDbType); if (!versions.isEmpty()) { chosenVersion = versions.get(versions.size() - 1); } } if (chosenVersion == null) { return Results.fail("No version specified or found for " + chosenDbType.getDriverCoordinate()); } Project project = getSelectedProject(context); DependencyBuilder dependency = DependencyBuilder.create() .setCoordinate(chosenDbType.getDriverCoordinate()) .setVersion(chosenVersion) .setScopeType(chosenScope); DependencyFacet dependencyFacet = project.getFacet(DependencyFacet.class); dependencyFacet.addDirectDependency(dependency); return Results.success("JDBC Driver Dependency " + dependency + " installed"); }
@Override public Result execute(UIExecutionContext context) throws Exception { AddonProjectConfigurator configurator = SimpleContainer .getServices(getClass().getClassLoader(), AddonProjectConfigurator.class).get(); Project project = getSelectedProject(context); AddonId addonId = AddonId.fromCoordinates(addon.getValue()); configurator.installSelectedAddons(project, Collections.singleton(addonId), false); return Results.success("Addon " + addonId + " added as a dependency to project " + project.getFacet(MetadataFacet.class).getProjectName()); }
@Override public Result execute(UIExecutionContext context) throws Exception Resource<?> currentResource = (Resource<?>) context.getUIContext().getInitialSelection().get(); for (String file : arguments.getValue()) return Results.fail(file + ": no such file or directory"); boolean forceOption = force.getValue(); boolean recurse = recursive.getValue(); UIPrompt prompt = context.getPrompt(); UIOutput output = context.getUIContext().getProvider().getOutput(); for (String file : arguments.getValue()) context.getUIContext().setSelection(currentResource); return Results.success();
@Override public Result execute(UIExecutionContext context) throws Exception UIContext uiContext = context.getUIContext(); Resource<?> currentResource = (Resource<?>) uiContext.getInitialSelection().get(); Iterator<String> it = arguments.getValue() == null ? Collections.<String> emptyList().iterator() : arguments .getValue().iterator(); Result result = Results.success(); UIOutput output = uiContext.getProvider().getOutput(); while (it.hasNext()) result = Results.fail(); if (color.getValue()) result = Results.fail();
@Override public Result execute(UIExecutionContext executionContext) throws Exception UIProgressMonitor progressMonitor = executionContext.getProgressMonitor(); UIOutput output = executionContext.getUIContext().getProvider().getOutput(); FractionUsageAnalyzer analyzer = WildFlySwarmFacet.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()) WildFlySwarmFacet facet = project.getFacet(WildFlySwarmFacet.class); detectedFractions.removeAll(facet.getInstalledFractions()); return Results.success();
@Override public Result execute(UIExecutionContext context) throws Exception { JavaResource javaResource = (JavaResource) context.getUIContext().getInitialSelection().get(); JavaClassSource commandClass = javaResource.getJavaType(); commandClass = createCommand(commandClass, named.getValue(), categories.getValue()); javaResource.setContents(commandClass); return Results.success("Annotated UICommand created"); }
@Override public Result execute(UIExecutionContext context) throws Exception UIOutput output = context.getUIContext().getProvider().getOutput(); PrintStream out = output.out(); if (named.hasValue()) .getArchetypeCatalogFactory(named.getValue()); if (archetypeCatalogFactory != null) return Results.success();
@Override public Result execute(UIExecutionContext uiExecutionContext) throws Exception { Project project = getSelectedProject(uiExecutionContext.getUIContext()); facet.setFaceted(project); if (! facet.isInstalled()) { return Results.fail("The project is not a vert.x project, execute 'vertx-setup' before adding a verticle."); } String verticleType = type.getValue(); if (verticleType == null || verticleType.isEmpty()) { verticleType = detectVerticleTypeFromVerticleName(name.getValue()); System.out.println("Verticle Type (detected) : " + verticleType); } String packageName = null; String verticleName = name.getValue(); if (verticleType.equalsIgnoreCase("java")) { packageName = extractPackageName(name.getValue()); verticleName = extractJavaClassName(name.getValue()); } String fileName = verticles.createNewVerticle(facet.getFaceted(), verticleName, packageName, verticleType, main.getValue()); return Results.success("Verticle " + fileName + " created"); }
@Override public Result execute(UIExecutionContext context) throws Exception { AddonProjectConfigurator addonProjectFactory = SimpleContainer .getServices(getClass().getClassLoader(), AddonProjectConfigurator.class).get(); final Project project = (Project) context.getUIContext().getAttributeMap().get(Project.class); Set<AddonId> dependencyAddons = new TreeSet<>(); if (addons.hasValue() || addons.hasDefaultValue()) { for (AddonId id : addons.getValue()) { dependencyAddons.add(id); } } dependencyAddons.add(furnaceContainer.getValue()); if (splitProjects.getValue()) { addonProjectFactory.setupComplexAddonProject(project, dependencyAddons); } else { addonProjectFactory.setupSimpleAddonProject(project, dependencyAddons); } return Results.success(); }
UIProvider provider = context.getUIContext().getProvider(); UIOutput output = provider.getOutput(); UIPrompt prompt = context.getPrompt(); PrintStream out = output.out(); DirectoryResource forgeHome = getForgeHome(); if (updateDir.exists()) return Results.fail( "There is an update pending. Restart Forge for the update to take effect. To abort this update, type 'forge-update-abort'"); return Results.success();