Java Code Examples for org.jboss.forge.addon.parser.java.facets.JavaSourceFacet#getJavaResource()
The following examples show how to use
org.jboss.forge.addon.parser.java.facets.JavaSourceFacet#getJavaResource() .
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: ScaffoldableEntitySelectionWizard.java From angularjs-addon with Eclipse Public License 1.0 | 5 votes |
@Override public NavigationResult next(UINavigationContext context) throws Exception { UIContext uiContext = context.getUIContext(); Map<Object, Object> attributeMap = uiContext.getAttributeMap(); ResourceCollection resourceCollection = new ResourceCollection(); if (targets.getValue() != null) { for (JavaClassSource klass : targets.getValue()) { Project project = getSelectedProject(uiContext); JavaSourceFacet javaSource = project.getFacet(JavaSourceFacet.class); Resource<?> resource = javaSource.getJavaResource(klass); if (resource != null) { resourceCollection.addToCollection(resource); } } } attributeMap.put(ResourceCollection.class, resourceCollection); Boolean shouldGenerateRestResources = generateRestResources.getValue(); if (shouldGenerateRestResources.equals(Boolean.TRUE)) { return Results.navigateTo(JSONRestResourceFromEntityCommand.class); } return null; }
Example 2
Source File: InspectionResultProcessor.java From angularjs-addon with Eclipse Public License 1.0 | 5 votes |
private JavaClassSource getJavaClass(String qualifiedType) { JavaSourceFacet java = this.project.getFacet(JavaSourceFacet.class); try { JavaResource resource = java.getJavaResource(qualifiedType); JavaClassSource javaClass = resource.getJavaType(); return javaClass; } catch (FileNotFoundException fileEx) { throw new RuntimeException(fileEx); } }
Example 3
Source File: InspectionResultProcessorTest.java From angularjs-addon with Eclipse Public License 1.0 | 5 votes |
private void generateOneToOneField(String fieldName, String type, String inverseFieldName, FetchType fetchType, boolean required, Iterable<CascadeType> cascadeTypes) throws Exception { JavaSourceFacet java = project.getFacet(JavaSourceFacet.class); JavaResource entityClassResource = java.getJavaResource(entityClass); projectHelper.createOneToOneField(project, entityClassResource, fieldName, type, inverseFieldName, fetchType, required, cascadeTypes); entityClass = getJavaClassFor(entityClass.getName()); }
Example 4
Source File: InspectionResultProcessorTest.java From angularjs-addon with Eclipse Public License 1.0 | 5 votes |
private void generateManyToOneField(String fieldName, String type, String inverseFieldName, FetchType fetchType, boolean required, Iterable<CascadeType> cascadeTypes) throws Exception { JavaSourceFacet java = project.getFacet(JavaSourceFacet.class); JavaResource entityClassResource = java.getJavaResource(entityClass); projectHelper.createManyToOneField(project, entityClassResource, fieldName, type, inverseFieldName, fetchType, required, cascadeTypes); entityClass = getJavaClassFor(entityClass.getName()); }
Example 5
Source File: InspectionResultProcessorTest.java From angularjs-addon with Eclipse Public License 1.0 | 5 votes |
private void generateOneToManyField(String fieldName, String type, String inverseFieldName, FetchType fetchType, Iterable<CascadeType> cascadeTypes) throws Exception { JavaSourceFacet java = project.getFacet(JavaSourceFacet.class); JavaResource entityClassResource = java.getJavaResource(entityClass); projectHelper.createOneToManyField(project, entityClassResource, fieldName, type, inverseFieldName, fetchType, cascadeTypes); entityClass = getJavaClassFor(entityClass.getName()); }
Example 6
Source File: InspectionResultProcessorTest.java From angularjs-addon with Eclipse Public License 1.0 | 5 votes |
private void generateManyToManyField(String fieldName, String type, String inverseFieldName, FetchType fetchType, Iterable<CascadeType> cascadeTypes) throws Exception { JavaSourceFacet java = project.getFacet(JavaSourceFacet.class); JavaResource entityClassResource = java.getJavaResource(entityClass); projectHelper.createManyToManyField(project, entityClassResource, fieldName, type, inverseFieldName, fetchType, cascadeTypes); entityClass = getJavaClassFor(entityClass.getName()); }
Example 7
Source File: CamelNewRouteBuilderCommand.java From fabric8-forge with Apache License 2.0 | 4 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { Project project = getSelectedProject(context); JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class); // does the project already have camel? Dependency core = findCamelCoreDependency(project); if (core == null) { return Results.fail("The project does not include camel-core"); } // do we already have a class with the name String fqn = targetPackage.getValue() != null ? targetPackage.getValue() + "." + name.getValue() : name.getValue(); JavaResource existing = facet.getJavaResource(fqn); if (existing != null && existing.exists()) { return Results.fail("A class with name " + fqn + " already exists"); } // need to parse to be able to extends another class final JavaClassSource javaClass = Roaster.create(JavaClassSource.class); javaClass.setName(name.getValue()); if (targetPackage.getValue() != null) { javaClass.setPackage(targetPackage.getValue()); } javaClass.setSuperType("RouteBuilder"); javaClass.addImport("org.apache.camel.builder.RouteBuilder"); boolean cdi = CamelCommandsHelper.isCdiProject(getSelectedProject(context)); boolean spring = CamelCommandsHelper.isSpringProject(getSelectedProject(context)); if (cdi) { javaClass.addAnnotation("javax.inject.Singleton"); } else if (spring) { javaClass.addAnnotation("org.springframework.stereotype.Component"); } javaClass.addMethod() .setPublic() .setReturnTypeVoid() .setName("configure") .addThrows(Exception.class).setBody(""); JavaResource javaResource = facet.saveJavaSource(javaClass); // if we are in an GUI editor then open the file if (isRunningInGui(context.getUIContext())) { context.getUIContext().setSelection(javaResource); } return Results.success("Created new RouteBuilder class " + name.getValue()); }