private ScopeType promptForScope(Dependency dep) { boolean answer = prompt.promptBoolean("Should the dependency be packaged with your application (not provided by the server)?", false); return answer ? ScopeType.COMPILE : ScopeType.PROVIDED; } }
private Dependency promptVersion(final DependencyFacet deps, final Dependency dependency, DependencyFilter filter) { Dependency result = dependency; final List<Dependency> versions = deps.resolveAvailableVersions(DependencyQueryBuilder.create(dependency) .setFilter(filter == null ? new NonSnapshotDependencyFilter() : filter)); if (versions.size() > 0) { Dependency deflt = versions.get(versions.size() - 1); result = prompt.promptChoiceTyped("Use which version of '" + dependency.getArtifactId() + "' ?", versions, deflt); } return result; } }
if (activatorChoice == null || activatorChoice.equals("")) activatorType = prompt.promptEnum("How do you want to activate REST resources in your application ?", RestActivatorType.class, RestActivatorType.WEB_XML); String rootpath = prompt.prompt("What root path do you want to use for your resources?", "/rest"); projectConfiguration.setProperty(RestFacet.ROOTPATH, rootpath); String pkg = prompt.promptCommon("In what package do you want to store the Application class?", PromptType.JAVA_PACKAGE, project.getFacet(MetadataFacet.class).getTopLevelPackage() + ".rest"); String restApplication = prompt.prompt("How do you want to name the Application class?", "RestApplication"); projectConfiguration.setProperty(RestApplicationFacet.REST_APPLICATIONCLASS_PACKAGE, pkg); projectConfiguration.setProperty(RestApplicationFacet.REST_APPLICATIONCLASS_NAME, restApplication);
&& prompt.promptBoolean("The JPA provider [" + jpap + "], also supplies extended APIs. Install these as well?", false)) if (!versions.isEmpty()) Dependency choice = prompt.promptChoiceTyped("Install which version of [" + dependency + "]?", versions, versions.get(versions.size() - 1));
@Command("new-plugin") public void newPlugin(final PipeOut out, @Option(required = true, name = "named", description = "The plugin name") final String pluginName, @Option(name = "alias", description = "The plugin alias") final String alias) throws FileNotFoundException { String pluginAlias = Strings.isNullOrEmpty(alias) ? pluginName.replaceAll("([^A-Za-z0-9-])|[Plugin]", "").toLowerCase() : alias; if (Strings.isNullOrEmpty(pluginAlias)) { throw new RuntimeException("You should specify a valid alias for this plugin"); } JavaSourceFacet java = project.getFacet(JavaSourceFacet.class); String className = canonicalize(pluginName); String packg = prompt.promptCommon( "In which package you'd like to create [" + className + "], or enter for default", PromptType.JAVA_PACKAGE, java.getBasePackage()); Map<Object, Object> context = new HashMap<Object, Object>(); context.put("name", className); context.put("alias", pluginAlias); CompiledTemplateResource pluginSource = compiler.compileResource(getClass().getResourceAsStream( "/org/jboss/forge/dev/PluginTemplate.jv")); CompiledTemplateResource testSource = compiler.compileResource(getClass().getResourceAsStream( "/org/jboss/forge/dev/PluginTemplateTest.jv")); JavaResource pluginResource = java.saveJavaSource(JavaParser.parse(JavaClass.class, pluginSource.render(context)) .setPackage(packg)); java.saveTestJavaSource(JavaParser.parse(JavaClass.class, testSource.render(context)).setPackage(packg)); pickup.fire(new PickupResource(pluginResource)); }
String computedPath = proposedResourcePath.startsWith("/") ? "forge" + proposedResourcePath : "forge/" + proposedResourcePath; proposedResourcePath = prompt.prompt("Provide a different URI path value for the generated resource.", computedPath); resourceTypeVisitor.setProposedPath(proposedResourcePath);
@Command("new-bean") public void newBean( @Option(required = true, name = "type") final JavaResource resource, @Option(required = true, name = "scoped") final BeanScope scope, @Option(required = false, name = "overwrite") final boolean overwrite ) throws FileNotFoundException { if (resource.exists() && !overwrite) { throw new RuntimeException("Type already exists [" + resource.getFullyQualifiedName() + "] Re-run with '--overwrite' to continue."); } JavaSourceFacet java = project.getFacet(JavaSourceFacet.class); JavaClass javaClass = JavaParser.create(JavaClass.class); javaClass.setName(java.calculateName(resource)); javaClass.setPackage(java.calculatePackage(resource)); if (BeanScope.CUSTOM == scope) { String annoType = prompt.promptCommon("Enter the qualified custom scope type:", PromptType.JAVA_CLASS); javaClass.addAnnotation(annoType); } else if (BeanScope.DEPENDENT != scope) { javaClass.addAnnotation(scope.getAnnotation()); } java.saveJavaSource(javaClass); pickup.fire(new PickupResource(java.getJavaResource(javaClass))); }
private void installMetaModelGenerator() { if (!project.hasFacet(PersistenceMetaModelFacet.class) && prompt.promptBoolean("Do you want to install a JPA 2 metamodel generator?", false)) { request.fire(new InstallFacets(PersistenceMetaModelFacet.class)); } }
private Dependency promptVersion(Dependency dependency) { DependencyFacet dependencyFacet = project.getFacet(DependencyFacet.class); Dependency result = dependency; List<Dependency> versions = dependencyFacet.resolveAvailableVersions(DependencyQueryBuilder.create(dependency) .setFilter(new NonSnapshotDependencyFilter())); if (versions.size() > 0) { Dependency deflt = versions.get(versions.size() - 1); result = prompt.promptChoiceTyped("Use which version of '" + dependency.getArtifactId() + "' ?", versions, deflt); } return result; }
((FileResource<?>) target).setContents(output.toString()); else if (prompt.promptBoolean("File exists. Overwrite with blank view?"))
.promptChoiceTyped( "Multiple persistence units were detected. Which persistence unit do you want to inject in the REST resources?", unitNames, unitNames.get(0));
/** * Registers the nested DTO created for a JPA entity * * @param entity The JPA entity * @param nestedDTO The nested DTO created for the JPA entity */ public void addNestedDTO(JavaClass entity, JavaClass nestedDTO) { JavaSourceFacet java = this.project.getFacet(JavaSourceFacet.class); DTOPair dtoPair = dtos.containsKey(entity) ? dtos.get(entity) : new DTOPair(); if (nestedDTO != null) { try { if (!java.getJavaResource(nestedDTO).exists() || prompt.promptBoolean("DTO [" + nestedDTO.getQualifiedName() + "] already, exists. Overwrite?")) { dtoPair.nestedDTO = java.saveJavaSource(nestedDTO); } } catch (FileNotFoundException fileEx) { throw new RuntimeException(fileEx); } } dtos.put(entity, dtoPair); }
public static Resource<?> createOrOverwrite(final ShellPrompt prompt, final FileResource<?> resource, final String contents, final boolean overwrite) { if (!resource.exists() || overwrite || prompt.promptBoolean("[" + resource.getFullyQualifiedName() + "] File exists, overwrite?")) { resource.createNewFile(); resource.setContents(contents); return resource; } return null; }
public static Resource<?> createOrOverwrite(final ShellPrompt prompt, final FileResource<?> resource, final InputStream contents, final boolean overwrite) { if (!resource.exists() || overwrite || prompt.promptBoolean("[" + resource.getFullyQualifiedName() + "] File exists, overwrite?")) { resource.createNewFile(); resource.setContents(contents); return resource; } return null; }
public static Resource<?> createOrOverwrite(final ShellPrompt prompt, final FileResource<?> resource, final InputStream contents, final boolean overwrite) { if (!resource.exists() || overwrite || prompt.promptBoolean("[" + resource.getFullyQualifiedName() + "] File exists, overwrite?")) { resource.createNewFile(); resource.setContents(contents); return resource; } return null; }
public static Resource<?> createOrOverwrite(final ShellPrompt prompt, final FileResource<?> resource, final String contents, final boolean overwrite) { if (!resource.exists() || overwrite || prompt.promptBoolean("[" + resource.getFullyQualifiedName() + "] File exists, overwrite?")) { resource.createNewFile(); resource.setContents(contents); return resource; } return null; }
/** * Registers the root DTO created for a JPA entity * * @param entity The JPA entity * @param rootDTO The root DTO created for the JPA entity */ public void addRootDTO(JavaClass entity, JavaClass rootDTO) { JavaSourceFacet java = this.project.getFacet(JavaSourceFacet.class); DTOPair dtoPair = dtos.containsKey(entity) ? dtos.get(entity) : new DTOPair(); if (rootDTO != null) { try { if (!java.getJavaResource(rootDTO).exists() || prompt.promptBoolean("DTO [" + rootDTO.getQualifiedName() + "] already, exists. Overwrite?")) { dtoPair.rootDTO = java.saveJavaSource(rootDTO); } } catch (FileNotFoundException fileEx) { throw new RuntimeException(fileEx); } } dtos.put(entity, dtoPair); }
protected Node removeConflictingErrorPages(final ServletFacet servlet) { Node webXML = XMLParser.parse(servlet.getConfigFile().getResourceInputStream()); Node root = webXML.getRoot(); List<Node> errorPages = root.get("error-page"); for (String code : Arrays.asList("404", "500")) { for (Node errorPage : errorPages) { if (code.equals(errorPage.getSingle("error-code").getText()) && this.prompt.promptBoolean("Your web.xml already contains an error page for " + code + " status codes, replace it?")) { root.removeChild(errorPage); } } } return webXML; }
if (!project.hasFacet(CDIFacet.class)) if (prompt.promptBoolean("Do you also want to install CDI?", true)) int majorVersion = Integer.parseInt(servletVersion.split("[.]")[0]); if (majorVersion < 3 || prompt.promptBoolean("Do you also want to install the Faces servlet and mapping?", false))
if (prompt.promptBoolean("Your annotation has syntax errors, create anyway?", true))