org.jboss.forge.addon.projects.facets.WebResourcesFacet Java Examples
The following examples show how to use
org.jboss.forge.addon.projects.facets.WebResourcesFacet.
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: 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 #2
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 #3
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 #4
Source File: AngularScaffoldProvider.java From angularjs-addon with Eclipse Public License 1.0 | 6 votes |
@Override public List<Resource<?>> setup(ScaffoldSetupContext setupContext) { setProject(setupContext.getProject()); String targetDir = setupContext.getTargetDirectory(); targetDir = (targetDir == null) ? "" : targetDir; // Setup static resources. ArrayList<Resource<?>> result = new ArrayList<>(); WebResourcesFacet web = project.getFacet(WebResourcesFacet.class); ProcessingStrategy strategy = new CopyResourcesStrategy(web); for (ScaffoldResource scaffoldResource : getStatics(targetDir, strategy)) { result.add(scaffoldResource.generate()); } return result; }
Example #5
Source File: CurrentLineCompleter.java From fabric8-forge with Apache License 2.0 | 5 votes |
public CurrentLineCompleter(int lineNumber, String relativeFile, final JavaSourceFacet sourceFacet, final ResourcesFacet resourcesFacet, final WebResourcesFacet webFacet) throws Exception { this.lineNumber = lineNumber; this.relativeFile = relativeFile; this.sourceFacet = sourceFacet; this.resourcesFacet = resourcesFacet; this.webFacet = webFacet; this.line = getCurrentCursorLineText(); LOG.info("Created CurrentLineCompleter[lineNumber=" + lineNumber + ",relativeFile=" + relativeFile + ",line=" + line + "]"); }
Example #6
Source File: ProcessTemplateStrategy.java From angularjs-addon with Eclipse Public License 1.0 | 5 votes |
public ProcessTemplateStrategy(WebResourcesFacet web, ResourceFactory resourceFactory, Project project, TemplateFactory templateFactory, Map<String, Object> dataModel) { this.web = web; this.resourceFactory = resourceFactory; this.project = project; this.templateFactory = templateFactory; this.dataModel = dataModel; }
Example #7
Source File: SearchTemplateStrategy.java From angularjs-addon with Eclipse Public License 1.0 | 5 votes |
public SearchTemplateStrategy(WebResourcesFacet web, ResourceFactory resourceFactory, Project project, TemplateFactory templateFactory, Map<String, Object> dataModel) { this.web = web; this.resourceFactory = resourceFactory; this.project = project; this.templateFactory = templateFactory; this.dataModel = dataModel; }
Example #8
Source File: AngularScaffoldProvider.java From angularjs-addon with Eclipse Public License 1.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public boolean isSetup(ScaffoldSetupContext setupContext) { Project project = setupContext.getProject(); String targetDir = setupContext.getTargetDirectory(); targetDir = targetDir == null ? "" : targetDir; if (project.hasAllFacets(WebResourcesFacet.class, DependencyFacet.class, JPAFacet.class, EJBFacet.class, CDIFacet.class, RestFacet.class)) { WebResourcesFacet web = project.getFacet(WebResourcesFacet.class); boolean areResourcesInstalled = web.getWebResource(targetDir + GLYPHICONS_SVG).exists() && web.getWebResource(targetDir + GLYPHICONS_EOT).exists() && web.getWebResource(targetDir + GLYPHICONS_SVG).exists() && web.getWebResource(targetDir + GLYPHICONS_TTF).exists() && web.getWebResource(targetDir + GLYPHICONS_WOFF).exists() && web.getWebResource(targetDir + GLYPHICONS_WOFF2).exists() && web.getWebResource(targetDir + FORGE_LOGO_PNG).exists() && web.getWebResource(targetDir + ANGULAR_RESOURCE_JS).exists() && web.getWebResource(targetDir + ANGULAR_ROUTE_JS).exists() && web.getWebResource(targetDir + ANGULAR_JS).exists() && web.getWebResource(targetDir + MODERNIZR_JS).exists() && web.getWebResource(targetDir + JQUERY_JS).exists() && web.getWebResource(targetDir + BOOTSTRAP_JS).exists() && web.getWebResource(targetDir + OFFCANVAS_JS).exists() && web.getWebResource(targetDir + MAIN_CSS).exists() && web.getWebResource(targetDir + BOOTSTRAP_CSS).exists() && web.getWebResource(targetDir + BOOTSTRAP_THEME_CSS).exists() && web.getWebResource(targetDir + LANDING_VIEW).exists(); return areResourcesInstalled; } return false; }
Example #9
Source File: DetailTemplateStrategy.java From angularjs-addon with Eclipse Public License 1.0 | 5 votes |
public DetailTemplateStrategy(WebResourcesFacet web, ResourceFactory resourceFactory, Project project, TemplateFactory templateFactory, Map<String, Object> dataModel) { this.web = web; this.resourceFactory = resourceFactory; this.project = project; this.templateFactory = templateFactory; this.dataModel = dataModel; }
Example #10
Source File: ThorntailProjectType.java From thorntail-addon with Eclipse Public License 1.0 | 5 votes |
/** * Same as JavaWebProjectType */ @Override public Iterable<Class<? extends ProjectFacet>> getRequiredFacets() { List<Class<? extends ProjectFacet>> result = new ArrayList<Class<? extends ProjectFacet>>(7); result.add(MetadataFacet.class); result.add(PackagingFacet.class); result.add(DependencyFacet.class); result.add(ResourcesFacet.class); result.add(WebResourcesFacet.class); result.add(JavaSourceFacet.class); result.add(JavaCompilerFacet.class); return result; }
Example #11
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 #12
Source File: FunktionProjectType.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public Iterable<Class<? extends ProjectFacet>> getRequiredFacets() { List<Class<? extends ProjectFacet>> result = new ArrayList<Class<? extends ProjectFacet>>(7); result.add(MetadataFacet.class); result.add(PackagingFacet.class); result.add(DependencyFacet.class); result.add(ResourcesFacet.class); result.add(WebResourcesFacet.class); result.add(JavaSourceFacet.class); result.add(JavaCompilerFacet.class); return result; }
Example #13
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 #14
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 #15
Source File: SpringBootProjectType.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public Iterable<Class<? extends ProjectFacet>> getRequiredFacets() { List<Class<? extends ProjectFacet>> result = new ArrayList<Class<? extends ProjectFacet>>(7); result.add(MetadataFacet.class); result.add(PackagingFacet.class); result.add(DependencyFacet.class); result.add(ResourcesFacet.class); result.add(WebResourcesFacet.class); result.add(JavaSourceFacet.class); result.add(JavaCompilerFacet.class); return result; }
Example #16
Source File: XmlWebResourcesCamelEndpointsVisitor.java From fabric8-forge with Apache License 2.0 | 4 votes |
public XmlWebResourcesCamelEndpointsVisitor(WebResourcesFacet facet, List<CamelEndpointDetails> endpoints, Function<String, Boolean> filter) { this.facet = facet; this.endpoints = endpoints; this.filter = filter; }
Example #17
Source File: CopyResourcesStrategy.java From angularjs-addon with Eclipse Public License 1.0 | 4 votes |
public CopyResourcesStrategy(WebResourcesFacet web) { this.web = web; }
Example #18
Source File: XmlWebResourcesCamelFilesVisitor.java From fabric8-forge with Apache License 2.0 | 4 votes |
public XmlWebResourcesCamelFilesVisitor(WebResourcesFacet facet, Set<String> files, Set<String> directories, Function<String, Boolean> filter) { this.facet = facet; this.files = files; this.directories = directories; this.filter = filter; }
Example #19
Source File: AngularScaffoldProvider.java From angularjs-addon with Eclipse Public License 1.0 | 4 votes |
@Override public List<Resource<?>> generateFrom(ScaffoldGenerationContext generationContext) { setProject(generationContext.getProject()); String targetDir = generationContext.getTargetDirectory(); targetDir = (targetDir == null) ? "" : targetDir; List<Resource<?>> result = new ArrayList<>(); Collection<Resource<?>> resources = generationContext.getResources(); for (Resource<?> resource : resources) { JavaSource<?> javaSource = null; if (resource instanceof JavaResource) { JavaResource javaResource = (JavaResource) resource; try { javaSource = javaResource.getJavaType(); } catch (FileNotFoundException fileEx) { throw new IllegalStateException(fileEx); } } else { continue; } JavaClassSource entity = (JavaClassSource) javaSource; String resourceRootPath = getRootResourcePath(project); // Fetch the REST resource path from the existing JAX-RS resource if found. String entityResourcePath = parseResourcePath(entity); // If the path is not available, construct a default one from the JPA entity name // We'll let the user resolve the incorrect path later, // if needed through regeneration of the JAX-RS resources. String entityName = entity.getName(); if (entityResourcePath == null || entityResourcePath.isEmpty()) { entityResourcePath = inflector.pluralize(entityName.toLowerCase()); } entityResourcePath = trimSlashes(entityResourcePath); // Inspect the JPA entity and obtain a list of inspection results. Every inspected property is represented as a // Map<String,String> and all such inspection results are collated into a list. MetawidgetInspectorFacade metawidgetInspectorFacade = new MetawidgetInspectorFacade(project); InspectionResultProcessor angularResultEnhancer = new InspectionResultProcessor(project, metawidgetInspectorFacade); List<Map<String, String>> inspectionResults = metawidgetInspectorFacade.inspect(entity); String entityId = angularResultEnhancer.fetchEntityId(entity, inspectionResults); inspectionResults = angularResultEnhancer.enhanceResults(entity, inspectionResults); MetadataFacet metadata = project.getFacet(MetadataFacet.class); // TODO: Provide a 'utility' class for allowing transliteration across language naming schemes // We need this to use contextual naming schemes instead of performing toLowerCase etc. in FTLs. // Prepare the Freemarker data model Map<String, Object> dataModel = new HashMap<>(); dataModel.put("entityName", entityName); dataModel.put("pluralizedEntityName", inflector.pluralize(entityName)); dataModel.put("entityId", entityId); dataModel.put("properties", inspectionResults); dataModel.put("projectId", StringUtils.camelCase(metadata.getProjectName())); dataModel.put("projectTitle", StringUtils.uncamelCase(metadata.getProjectName())); dataModel.put("resourceRootPath", resourceRootPath); dataModel.put("resourcePath", entityResourcePath); dataModel.put("parentDirectories", getParentDirectories(targetDir)); // Process the Freemarker templates with the Freemarker data model and retrieve the generated resources from // the registry. WebResourcesFacet web = project.getFacet(WebResourcesFacet.class); ProcessingStrategy strategy = new ProcessTemplateStrategy(web, resourceFactory, project, templateFactory, dataModel); List<ScaffoldResource> scaffoldResources = getEntityTemplates(targetDir, entityName, strategy); scaffoldResources.add(new ScaffoldResource("/views/detail.html.ftl", targetDir + "/views/" + entityName + "/detail.html", new DetailTemplateStrategy(web, resourceFactory, project, templateFactory, dataModel))); scaffoldResources.add(new ScaffoldResource("/views/search.html.ftl", targetDir + "/views/" + entityName + "/search.html", new SearchTemplateStrategy(web, resourceFactory, project, templateFactory, dataModel))); for (ScaffoldResource scaffoldResource : scaffoldResources) { result.add(scaffoldResource.generate()); } } List<Resource<?>> indexResources = generateIndex(targetDir); result.addAll(indexResources); return result; }