@Override public Result execute(UIExecutionContext context) throws Exception { Project project = getSelectedProject(context); Optional<VertxMavenFacet> maybeFacet = project.getFacetAsOptional(VertxMavenFacet.class); VertxMavenFacet facet; if (!maybeFacet.isPresent()) { super.facet.setFaceted(project); super.facet.install(); facet = super.facet; } else { facet = maybeFacet.get(); } if (dependencies.hasValue()) { List<VertxDependency> deps = Lists.toList(dependencies.getValue()); facet.addDependencies(deps); List<String> artifactIds = deps.stream().map(VertxDependency::getArtifactId) .collect(Collectors.toList()); return Results.success("Vert.x Dependency '" + artifactIds + "' were successfully added to the project descriptor"); } return Results.success(); }
@Override public void initializeUI(UIBuilder builder) throws Exception { InputComponentFactory inputFactory = builder.getInputComponentFactory(); httpPort = inputFactory.createInput("httpPort", Integer.class) .setLabel("HTTP Port").setDescription("HTTP Port Wildfly will listen to") .setDefaultValue(WildFlySwarmConfiguration.HTTP_PORT_DEFAULT_VALUE); contextPath = inputFactory.createInput("contextPath", String.class) .setLabel("Context Path").setDescription("The context path of the web application") .setDefaultValue(WildFlySwarmConfiguration.CONTEXT_PATH_DEFAULT_VALUE); portOffset = inputFactory.createInput("portOffset", Integer.class) .setLabel("HTTP Port Offset").setDescription("HTTP Port Offset") .setDefaultValue(WildFlySwarmConfiguration.PORT_OFFSET_DEFAULT_VALUE); Project project = Projects.getSelectedProject(getProjectFactory(), builder.getUIContext()); if (project != null) { project.getFacetAsOptional(WildFlySwarmFacet.class) .ifPresent((facet) -> { WildFlySwarmConfiguration config = facet.getConfiguration(); httpPort.setDefaultValue(config.getHttpPort()); contextPath.setDefaultValue(config.getContextPath()); portOffset.setDefaultValue(config.getPortOffset()); }); } builder.add(httpPort).add(contextPath).add(portOffset); }