org.jboss.forge.addon.projects.Projects Java Examples
The following examples show how to use
org.jboss.forge.addon.projects.Projects.
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: SetupCommand.java From thorntail-addon with Eclipse Public License 1.0 | 5 votes |
@Override public void initializeUI(UIBuilder builder) { InputComponentFactory inputFactory = builder.getInputComponentFactory(); httpPort = inputFactory.createInput("httpPort", Integer.class) .setLabel("HTTP Port").setDescription("HTTP Port Thorntail will listen to") .setDefaultValue(ThorntailConfiguration.HTTP_PORT_DEFAULT_VALUE); contextPath = inputFactory.createInput("contextPath", String.class) .setLabel("Context Path").setDescription("The context path of the web application") .setDefaultValue(ThorntailConfiguration.CONTEXT_PATH_DEFAULT_VALUE); portOffset = inputFactory.createInput("portOffset", Integer.class) .setLabel("HTTP Port Offset").setDescription("HTTP Port Offset") .setDefaultValue(ThorntailConfiguration.PORT_OFFSET_DEFAULT_VALUE); Project project = Projects.getSelectedProject(getProjectFactory(), builder.getUIContext()); if (project != null) { project.getFacetAsOptional(ThorntailFacet.class) .ifPresent((facet) -> { ThorntailConfiguration config = facet.getConfiguration(); httpPort.setDefaultValue(config.getHttpPort()); contextPath.setDefaultValue(config.getContextPath()); portOffset.setDefaultValue(config.getPortOffset()); }); } builder.add(httpPort).add(contextPath).add(portOffset); }
Example #2
Source File: AddFractionCommand.java From thorntail-addon with Eclipse Public License 1.0 | 5 votes |
@Override public void initializeUI(UIBuilder builder) throws Exception { InputComponentFactory factory = builder.getInputComponentFactory(); fractionElements = factory.createSelectMany("fractions", FractionDescriptor.class) .setLabel("Fraction List") .setDescription("Fraction list"); UIContext uiContext = builder.getUIContext(); if (uiContext.getProvider().isGUI()) { fractionElements.setItemLabelConverter(FractionDescriptor::getName); } else { fractionElements.setItemLabelConverter(FractionDescriptor::getArtifactId); } Project project = Projects.getSelectedProject(getProjectFactory(), uiContext); final Collection<FractionDescriptor> fractions; if (project != null && project.hasFacet(ThorntailFacet.class)) { fractions = project.getFacet(ThorntailFacet.class).getFractions(); } else { fractions = ThorntailFacet.getAllFractionDescriptors(); } final List<FractionDescriptor> nonInternalfractions = fractions.stream() .filter(f -> !f.isInternal()) .collect(Collectors.toList()); fractionElements.setValueChoices(nonInternalfractions); builder.add(fractionElements); }
Example #3
Source File: AbstractFabricProjectCommand.java From fabric8-forge with Apache License 2.0 | 4 votes |
protected Project getSelectedProjectOrNull(UIContext context) { return Projects.getSelectedProject(this.getProjectFactory(), context); }
Example #4
Source File: AbstractDevOpsCommand.java From fabric8-forge with Apache License 2.0 | 4 votes |
protected Project getSelectedProjectOrNull(UIContext context) { return Projects.getSelectedProject(this.getProjectFactory(), context); }
Example #5
Source File: AbstractCamelProjectCommand.java From fabric8-forge with Apache License 2.0 | 4 votes |
protected Project getSelectedProjectOrNull(UIContext context) { return Projects.getSelectedProject(this.getProjectFactory(), context); }
Example #6
Source File: GetPropertiesCommand.java From fabric8-forge with Apache License 2.0 | 4 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { CommandHelpers.putComponentValuesInAttributeMap(context, inputComponents); UIContext uiContext = context.getUIContext(); Map<Object, Object> map = uiContext.getAttributeMap(); List<String> classNames = (List<String>) map.get("classNames"); if (classNames == null || classNames.size() == 0) { return Results.fail("No className field provided"); } Project project = Projects.getSelectedProject(getProjectFactory(), uiContext); // force build PackagingFacet packaging = project.getFacet(PackagingFacet.class); ProjectBuilder builder = packaging.createBuilder(); builder.runTests(false); builder.addArguments("clean", "compile"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream stdout = new PrintStream(baos, true); try { builder.build(stdout, stdout); } catch (BuildException be) { // no point in continuing the operation return Results.fail("Failed to build project: " + be + "\n\n" + baos.toString()); } ClassLoaderFacet classLoaderFacet = project.getFacet(ClassLoaderFacet.class); URLClassLoader classLoader = classLoaderFacet.getClassLoader(); Map<String, List<Object>> answer = new HashMap<String, List<Object>>(); for (String className : classNames) { List<Object> props = new ArrayList<Object>(); Class clazz; try { clazz = classLoader.loadClass(className); BeanInfo beanInfo = java.beans.Introspector.getBeanInfo(clazz); PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); for (PropertyDescriptor propertyDescriptor : propertyDescriptors) { // ignore the class property if (propertyDescriptor.getName().equals("class")) { continue; } PropertyDTO info = new PropertyDTO(propertyDescriptor); props.add(info); } } catch (Exception e) { props.add("Failed to load class, error: " + e.getMessage()); } answer.put(className, props); } classLoader.close(); String result = toJson(answer); return Results.success(result); }
Example #7
Source File: JSONRestResourceFromEntityCommand.java From angularjs-addon with Eclipse Public License 1.0 | 4 votes |
private Project getSelectedProject(UIContext context) { return Projects.getSelectedProject(projectFactory, context); }
Example #8
Source File: ScaffoldableEntitySelectionWizard.java From angularjs-addon with Eclipse Public License 1.0 | 4 votes |
private Project getSelectedProject(UIContext uiContext) { return Projects.getSelectedProject(projectFactory, uiContext); }