Package org.jboss.forge.addon.parser.java.resources

Examples of org.jboss.forge.addon.parser.java.resources.JavaResource


   private JavaResource getJavaResource(final DirectoryResource sourceDir, final String relativePath)
   {
      String path = relativePath.trim().endsWith(".java")
               ? relativePath.substring(0, relativePath.lastIndexOf(".java")) : relativePath;
      path = path.replace(".", File.separator) + ".java";
      JavaResource target = sourceDir.getChildOfType(JavaResource.class, path);
      return target;
   }
View Full Code Here


   private JavaClass<?> tryGetJavaClass(Project project, String qualifiedFieldType)
   {
      try
      {
         JavaResource javaResource = project.getFacet(JavaSourceFacet.class).getJavaResource(qualifiedFieldType);
         JavaClass<?> javaClass = javaResource.getJavaType();
         return javaClass;
      }
      catch (ClassCastException fileEx)
      {
         // Ignore, since the source file may not be a JavaClass
View Full Code Here

   }

   @Override
   public Result execute(UIExecutionContext context) throws Exception
   {
      JavaResource resource = enumClass.getValue();
      JavaEnumSource source = resource.getJavaType();
      Project project = getSelectedProject(context.getUIContext());
      JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class);
      for (String enumConstant : arguments.getValue())
      {
         source.addEnumConstant(enumConstant);
View Full Code Here

            if (onMethod.getValue() != null || onProperty.getValue() != null)
            {
               return false;
            }

            JavaResource javaResource = targetClass.getValue();

            if (javaResource != null)
            {
               return ResourceUtil.filterByType(JavaFieldResource.class, javaResource.listResources()).size() > 0;
            }
            return false;
         }
      });

      onMethod.setEnabled(new Callable<Boolean>()
      {
         @Override
         public Boolean call()
         {
            if (onMethod.getValue() != null || onProperty.getValue() != null)
            {
               return false;
            }

            JavaResource javaResource = targetClass.getValue();

            if (javaResource != null)
            {
               return ResourceUtil.filterByType(JavaMethodResource.class, javaResource.listResources()).size() > 0;
            }
            return false;
         }
      });

      onProperty.setValueChoices(new Callable<Iterable<JavaFieldResource>>()
      {
         @Override
         public Iterable<JavaFieldResource> call()
         {
            JavaResource javaResource = targetClass.getValue();
            if (javaResource != null)
               return ResourceUtil.filterByType(JavaFieldResource.class, javaResource.listResources());
            return Collections.emptyList();
         }
      });

      onMethod.setValueChoices(new Callable<Iterable<JavaMethodResource>>()
      {
         @Override
         public Iterable<JavaMethodResource> call()
         {
            JavaResource javaResource = targetClass.getValue();
            if (javaResource != null)
               return ResourceUtil.filterByType(JavaMethodResource.class, javaResource.listResources());
            return Collections.emptyList();
         }
      });

      onProperty.setItemLabelConverter(new Converter<JavaFieldResource, String>()
      {
         @Override
         public String convert(JavaFieldResource source)
         {
            return (source == null ? null : source.getUnderlyingResourceObject().getName());
         }
      });

      onMethod.setItemLabelConverter(new Converter<JavaMethodResource, String>()
      {
         @Override
         public String convert(JavaMethodResource source)
         {
            return (source == null ? null : source.getUnderlyingResourceObject().getName());
         }
      });

      annotation.setCompleter(new UICompleter<String>()
      {
         @Override
         public Iterable<String> getCompletionProposals(UIContext context, InputComponent<?, String> input, String value)
         {
            Project project = getSelectedProject(builder.getUIContext());
            List<JavaResource> javaClasses = projectOperations.getProjectAnnotations(project);
            List<String> projectAnnotations = new ArrayList<>();
            for (JavaResource javaResource : javaClasses)
            {
               try
               {
                  projectAnnotations.add(javaResource.getJavaType().getCanonicalName());
               }
               catch (FileNotFoundException | ResourceException ignored)
               {
                  // don't mind
               }
View Full Code Here

      {
         @Override
         public Iterable<String> call() throws Exception
         {
            List<String> strings = new ArrayList<>();
            JavaResource javaResource = targetClass.getValue();
            JavaClassSource targetClass = javaResource.getJavaType();
            List<PropertySource<JavaClassSource>> properties = targetClass.getProperties();
            for (PropertySource<JavaClassSource> property : properties)
            {
               strings.add(property.getName());
            }
View Full Code Here

   }

   @Override
   public Result execute(UIExecutionContext context) throws Exception
   {
      JavaResource javaResource = targetClass.getValue();
      JavaClassSource targetClass = javaResource.getJavaType();
      GetSetMethodGenerator generator;
      if (builderPattern.getValue())
      {
         generator = new BuilderGetSetMethodGenerator();
      }
View Full Code Here

   }

   @Override
   public Result execute(UIExecutionContext context) throws Exception
   {
      JavaResource javaResource = targetClass.getValue();
      String fieldNameStr = named.getValue();
      JavaClassSource targetClass = javaResource.getJavaType();
      FieldSource<JavaClassSource> field = targetClass.getField(fieldNameStr);
      String action = (field == null) ? "created" : "updated";
      if (field != null)
      {
         UIPrompt prompt = context.getPrompt();
View Full Code Here

   @Override
   public JavaResource newEntity(DirectoryResource target, String entityName, String entityPackage,
            GenerationType idStrategy, String tableName)
   {
      JavaClassSource javaClass = createJavaEntityClass(entityName, entityPackage, idStrategy, tableName);
      JavaResource javaResource = getJavaResource(target, javaClass.getName());
      javaResource.setContents(javaClass);
      return javaResource;
   }
View Full Code Here

  
   @Override
   public JavaResource newEmbeddableEntity(DirectoryResource target, String entityName, String entityPackage)
   {
      JavaClassSource javaClass = createJavaEmbeddableClass(entityName, entityPackage);
      JavaResource javaResource = getJavaResource(target, javaClass.getName());
      javaResource.setContents(javaClass);
      return javaResource;
   }
View Full Code Here

   private JavaResource getJavaResource(final DirectoryResource sourceDir, final String relativePath)
   {
      String path = relativePath.trim().endsWith(".java")
               ? relativePath.substring(0, relativePath.lastIndexOf(".java")) : relativePath;
      path = path.replace(".", File.separator) + ".java";
      JavaResource target = sourceDir.getChildOfType(JavaResource.class, path);
      return target;
   }
View Full Code Here

TOP

Related Classes of org.jboss.forge.addon.parser.java.resources.JavaResource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.