@Override public Result execute(UIExecutionContext shellContext) throws Exception { UIContext uiContext = shellContext.getUIContext(); UISelection<Resource<?>> selection = uiContext.getInitialSelection(); Resource<?> currentResource = selection.get(); if (currentResource != null) { UIOutput output = uiContext.getProvider().getOutput(); output.out().println(currentResource.getFullyQualifiedName()); } return Results.success(); }
@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()); } }
@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 { UIContext uiContext = context.getUIContext(); Shell shell = (Shell) uiContext.getProvider(); shell.getConsole().stop(); forge.stop(); uiContext.getAttributeMap().put("org.jboss.forge.exit", Boolean.TRUE); return Results.success(); } }
@Override public Result execute(UIExecutionContext context) throws Exception { UIContext uiContext = context.getUIContext(); Project project = getSelectedProject(uiContext); JavaSourceFacet javaSourceFacet = project.getFacet(JavaSourceFacet.class); SOURCETYPE source = buildJavaSource(javaSourceFacet); JavaResource javaResource; if (source.hasSyntaxErrors()) { UIOutput output = uiContext.getProvider().getOutput(); PrintStream err = output.err(); err.println("Syntax Errors:"); for (SyntaxError error : source.getSyntaxErrors()) { err.println(error); } err.println(); return Results.fail("Syntax Errors found. See above"); } else { SOURCETYPE decorated = delegate.decorateSource(context, project, source); if (decorated != null) source = decorated; javaResource = javaSourceFacet.saveJavaSource(source); } uiContext.setSelection(javaResource); return Results.success(getType() + " " + source.getQualifiedName() + " was created"); }
@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 { 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 Result result = Results.success("Project named '" + named.getValue() + "' has been created."); DirectoryResource targetDir = getTargetDirectory(); boolean overwriteDir = overwrite.getValue() || useTargetLocationRoot.getValue(); if (targetDir.mkdirs() || overwriteDir) ProjectType value = type.getValue(); ProjectFactory projectFactory = SimpleContainer.getServices(getClass().getClassLoader(), ProjectFactory.class) .get(); ProjectProvider buildSystemValue = buildSystem.getValue(); Project project = projectFactory.createProject(targetDir, buildSystemValue); if (project != null) 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);
@Override public Result execute(UIExecutionContext context) throws Exception Result result = Results.fail("Error executing script."); UIContext uiContext = context.getUIContext(); Resource<?> currentResource = (Resource<?>) uiContext.getInitialSelection().get(); final UIOutput output = uiContext.getProvider().getOutput(); if (command.hasValue()) String[] commands = command.getValue().split(" "); ProcessBuilder processBuilder = new ProcessBuilder(commands); Object currentDir = currentResource.getUnderlyingResourceObject(); if (returnCode == 0) result = Results.success(); result = Results.fail("Error while executing native command. See output for more details"); .stdout(output.out()).stderr(output.err()).timeout(timeout.getValue()).build(); result = (Result) scriptEngine.eval(resource.getContents(), scriptContext); selectedResource = (Resource<?>) scriptContext uiContext.setSelection(selectedResource);
@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());
private void configureStack(InputComponentFactory factory, final UIContext context) { NoStackFacet defaultStack = SimpleContainer.getServices(getClass().getClassLoader(), NoStackFacet.class) .get(); Imported<StackFacet> stacks = SimpleContainer.getServices(getClass().getClassLoader(), StackFacet.class); final List<StackFacet> list = Lists.toList(stacks); Collections.sort(list, new StackFacetComparator()); stack = factory.createSelectOne("stack", StackFacet.class) .setLabel("Stack") .setDescription("The technology stack to be used in this project") .setValueChoices(() -> list.stream() .filter((stackFacet) -> (type.hasValue() || type.hasDefaultValue()) && type.getValue().supports(stackFacet.getStack())) .collect(Collectors.toSet())) // Enable stack field only if any stack is available .setEnabled(() -> Sets.toSet(stack.getValueChoices()).size() > 1) .setDefaultValue(defaultStack) .setItemLabelConverter((facet) -> context.getProvider().isGUI() ? facet.getStack().getName() : Commands.shellifyOptionValue(facet.getStack().getName())); }
@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 void postCommandExecuted(UICommand command, UIExecutionContext context, Result result) Map<Object, Object> attributeMap = context.getUIContext().getAttributeMap(); String skipProjectBuild = Objects.toString(attributeMap.get(PROJECT_BUILDSTATUS_SKIP_FLAG), null); Imported<ProjectFactory> services = SimpleContainer UIContext uiContext = context.getUIContext(); Project project = Projects.getSelectedProject(projectFactory, uiContext.getSelection()); if (project != null && project.hasFacet(PackagingFacet.class)) PackagingFacet facet = project.getFacet(PackagingFacet.class); BuildResult buildResult = facet.getBuildResult(); if (buildResult != null && !buildResult.isSuccess()) UIOutput output = uiContext.getProvider().getOutput(); PrintStream err = output.err(); output.error(err, String.format("Project '%s' has errors", project.getRoot())); for (BuildMessage message : buildResult.getMessages())
@Override public void initializeUI(UIBuilder builder) throws Exception { final List<String> choices = getExistingModules(); // Workaround FORGE-1639 final boolean isGui = builder.getUIContext().getProvider().isGUI(); final String createNew = (isGui) ? CREATE_A_NEW_MODULE_GUI : CREATE_A_NEW_MODULE_CLI; choices.add(createNew); moduleSelect.setValueChoices(choices); moduleSelect.setDefaultValue(createNew); builder.add(moduleSelect); }
@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 void initializeUI(UIBuilder builder) throws Exception { boolean gui = builder.getUIContext().getProvider().isGUI(); InputComponentFactory factory = builder.getInputComponentFactory(); this.addon = factory.createSelectOne("addon", AddonDescriptor.class) .setLabel("Addon") .setRequired(true) .setNote(() -> addon.hasValue() ? addon.getValue().getDescription() : null) .setValueChoices(AddonDescriptorCatalogRegistry.INSTANCE.find("")) .setItemLabelConverter(gui ? AddonDescriptor::getName : AddonDescriptor::getId); builder.add(addon); }
@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 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(); }
private void configureProjectTypeInput(InputComponentFactory factory, final UIContext uiContext) type = factory.createSelectOne("type", ProjectType.class).setLabel("Project type").setRequired(true); if (uiContext.getProvider().isGUI()) type.setItemLabelConverter((source) -> source.getType());
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();