Java Code Examples for org.jboss.forge.addon.projects.Project#hasFacet()
The following examples show how to use
org.jboss.forge.addon.projects.Project#hasFacet() .
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: NewIntegrationTestClassCommand.java From fabric8-forge with Apache License 2.0 | 6 votes |
@Override public void initializeUI(final UIBuilder builder) throws Exception { super.initializeUI(builder); Project project = getCurrentSelectedProject(builder.getUIContext()); if (project.hasFacet(JavaSourceFacet.class)) { JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class); targetPackage.setCompleter(new TestPackageNameCompleter(facet)); } targetPackage.addValidator(new PackageNameValidator()); targetPackage.setDefaultValue("io.fabric8.itests"); className.addValidator(new ClassNameValidator(false)); className.setDefaultValue(new Callable<String>() { @Override public String call() throws Exception { return "IntegrationTestKT"; } }); builder.add(targetPackage).add(className).add(profile).add(integrationTestWildcard).add(itestPlugin); }
Example 2
Source File: AbstractCamelProjectCommand.java From fabric8-forge with Apache License 2.0 | 6 votes |
protected CurrentLineCompleter createCurrentLineCompleter(int lineNumber, String file, UIContext context) throws Exception { Project project = getSelectedProject(context); JavaSourceFacet sourceFacet = null; ResourcesFacet resourcesFacet = null; WebResourcesFacet webResourcesFacet = null; if (project.hasFacet(JavaSourceFacet.class)) { sourceFacet = project.getFacet(JavaSourceFacet.class); } if (project.hasFacet(ResourcesFacet.class)) { resourcesFacet = project.getFacet(ResourcesFacet.class); } if (project.hasFacet(WebResourcesFacet.class)) { webResourcesFacet = project.getFacet(WebResourcesFacet.class); } String relativeFile = asRelativeFile(context, file); return new CurrentLineCompleter(lineNumber, relativeFile, sourceFacet, resourcesFacet, webResourcesFacet); }
Example 3
Source File: AbstractCamelProjectCommand.java From fabric8-forge with Apache License 2.0 | 6 votes |
protected FileResource getXmlResourceFile(Project project, String xmlResourceName) { if (xmlResourceName == null) { return null; } ResourcesFacet facet = null; WebResourcesFacet webResourcesFacet = null; if (project.hasFacet(ResourcesFacet.class)) { facet = project.getFacet(ResourcesFacet.class); } if (project.hasFacet(WebResourcesFacet.class)) { webResourcesFacet = project.getFacet(WebResourcesFacet.class); } FileResource file = facet != null ? facet.getResource(xmlResourceName) : null; if (file == null || !file.exists()) { file = webResourcesFacet != null ? webResourcesFacet.getWebResource(xmlResourceName) : null; } return file; }
Example 4
Source File: AbstractCamelProjectCommand.java From fabric8-forge with Apache License 2.0 | 6 votes |
protected String asRelativeFile(UIContext context, String currentFile) { Project project = getSelectedProject(context); JavaSourceFacet javaSourceFacet = null; ResourcesFacet resourcesFacet = null; WebResourcesFacet webResourcesFacet = null; if (project.hasFacet(JavaSourceFacet.class)) { javaSourceFacet = project.getFacet(JavaSourceFacet.class); } if (project.hasFacet(ResourcesFacet.class)) { resourcesFacet = project.getFacet(ResourcesFacet.class); } if (project.hasFacet(WebResourcesFacet.class)) { webResourcesFacet = project.getFacet(WebResourcesFacet.class); } return asRelativeFile(currentFile, javaSourceFacet, resourcesFacet, webResourcesFacet); }
Example 5
Source File: NewIntegrationTestClassCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public boolean isEnabled(UIContext context) { // must be fabric8 and java project boolean answer = isFabric8Project(getSelectedProjectOrNull(context)); if (answer) { Project project = getCurrentSelectedProject(context); answer = project.hasFacet(JavaSourceFacet.class); } return answer; }
Example 6
Source File: AbstractCamelProjectCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
protected XmlEndpointsCompleter createXmlEndpointsCompleter(Project project, Function<String, Boolean> filter) { ResourcesFacet resourcesFacet = null; WebResourcesFacet webResourcesFacet = null; if (project.hasFacet(ResourcesFacet.class)) { resourcesFacet = project.getFacet(ResourcesFacet.class); } if (project.hasFacet(WebResourcesFacet.class)) { webResourcesFacet = project.getFacet(WebResourcesFacet.class); } return new XmlEndpointsCompleter(resourcesFacet, webResourcesFacet, filter); }
Example 7
Source File: AbstractCamelProjectCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
protected XmlFileCompleter createXmlFileCompleter(Project project, Function<String, Boolean> filter) { ResourcesFacet resourcesFacet = null; WebResourcesFacet webResourcesFacet = null; if (project.hasFacet(ResourcesFacet.class)) { resourcesFacet = project.getFacet(ResourcesFacet.class); } if (project.hasFacet(WebResourcesFacet.class)) { webResourcesFacet = project.getFacet(WebResourcesFacet.class); } return new XmlFileCompleter(resourcesFacet, webResourcesFacet, filter); }
Example 8
Source File: AbstractCamelProjectCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
protected SpringBootConfigurationFileCompleter createSpringBootConfigurationFileCompleter(UIContext context, Function<String, Boolean> filter) { Project project = getSelectedProject(context); ResourcesFacet resourcesFacet = null; if (project.hasFacet(ResourcesFacet.class)) { resourcesFacet = project.getFacet(ResourcesFacet.class); } return new SpringBootConfigurationFileCompleter(resourcesFacet, filter); }
Example 9
Source File: CamelGetOverviewCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { Project project = getSelectedProject(context); // does the project already have camel? Dependency core = findCamelCoreDependency(project); if (core == null) { return Results.fail("The project does not include camel-core"); } ProjectDto camelProject = new ProjectDto(); ResourcesFacet resourcesFacet = project.getFacet(ResourcesFacet.class); WebResourcesFacet webResourcesFacet = null; if (project.hasFacet(WebResourcesFacet.class)) { webResourcesFacet = project.getFacet(WebResourcesFacet.class); } // use value choices instead of completer as that works better in web console XmlEndpointsCompleter xmlEndpointCompleter = new XmlEndpointsCompleter(resourcesFacet, webResourcesFacet, null); JavaSourceFacet javaSourceFacet = project.getFacet(JavaSourceFacet.class); // use value choices instead of completer as that works better in web console RouteBuilderEndpointsCompleter javaEndpointsCompleter = new RouteBuilderEndpointsCompleter(javaSourceFacet, null); camelProject.addEndpoints(javaEndpointsCompleter.getEndpoints()); camelProject.addEndpoints(xmlEndpointCompleter.getEndpoints()); CamelCurrentComponentsFinder componentsFinder = new CamelCurrentComponentsFinder(getCamelCatalog(), project); List<ComponentDto> currentComponents = componentsFinder.findCurrentComponents(); camelProject.setComponents(currentComponents); String result = formatResult(camelProject); return Results.success(result); }
Example 10
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 11
Source File: AngularScaffoldProvider.java From angularjs-addon with Eclipse Public License 1.0 | 5 votes |
@Override public NavigationResult getSetupFlow(ScaffoldSetupContext setupContext) { Project project = setupContext.getProject(); NavigationResultBuilder builder = NavigationResultBuilder.create(); List<Class<? extends UICommand>> setupCommands = new ArrayList<>(); if (!project.hasFacet(JPAFacet.class)) { builder.add(JPASetupWizard.class); } if (!project.hasFacet(CDIFacet.class)) { setupCommands.add(CDISetupCommand.class); } if (!project.hasFacet(EJBFacet.class)) { setupCommands.add(EJBSetupWizard.class); } if (!project.hasFacet(ServletFacet.class)) { // TODO: FORGE-1296. Ensure that this wizard only sets up Servlet 3.0+ setupCommands.add(ServletSetupWizard.class); } if (!project.hasFacet(RestFacet.class)) { setupCommands.add(RestSetupWizard.class); } if (setupCommands.size() > 0) { Metadata compositeSetupMetadata = Metadata.forCommand(setupCommands.get(0)) .name("Setup Facets") .description("Setup all dependent facets for the AngularJS scaffold."); builder.add(compositeSetupMetadata, setupCommands); } return builder.build(); }