Skip to content

Commit

Permalink
Enums cannot appear in targetEntity list
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Apr 16, 2014
1 parent e2ffaca commit 8b8d27a
Showing 1 changed file with 46 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,22 @@ public Iterable<String> getCompletionProposals(final UIContext context, final In
{
}
}
for (JavaResource resource : getProjectEnums(project))
{
try
{
JavaSource<?> javaSource = resource.getJavaType();
String qualifiedName = javaSource.getQualifiedName();
if (Strings.isNullOrEmpty(value) || qualifiedName.startsWith(value))
{
options.add(qualifiedName);
}
}
catch (FileNotFoundException ignored)
{
}
}

}
return options;
}
Expand Down Expand Up @@ -266,31 +282,25 @@ private void setupEntities(UIContext context)
}
}

/**
* @param project
* @return entities
*/
private List<JavaResource> getProjectEntities(Project project)
{
final List<JavaResource> entities = new ArrayList<>();
if (project != null)
{
project.getFacet(JavaSourceFacet.class).visitJavaSources(new JavaResourceVisitor()
{

@Override
public void visit(VisitContext context, JavaResource resource)
{
try
{
JavaSource<?> javaSource = resource.getJavaType();
if (javaSource.hasAnnotation(Entity.class) || javaSource.hasAnnotation(MappedSuperclass.class)
|| javaSource.isEnum())
if (javaSource.hasAnnotation(Entity.class) || javaSource.hasAnnotation(MappedSuperclass.class))
{
entities.add(resource);
}
}
catch (FileNotFoundException e)
catch (ResourceException | FileNotFoundException e)
{
// ignore
}
Expand All @@ -300,6 +310,34 @@ public void visit(VisitContext context, JavaResource resource)
return entities;
}

private List<JavaResource> getProjectEnums(Project project)
{
final List<JavaResource> enums = new ArrayList<>();
if (project != null)
{
project.getFacet(JavaSourceFacet.class).visitJavaSources(new JavaResourceVisitor()
{
@Override
public void visit(VisitContext context, JavaResource resource)
{
try
{
JavaSource<?> javaSource = resource.getJavaType();
if (javaSource.isEnum())
{
enums.add(resource);
}
}
catch (ResourceException | FileNotFoundException e)
{
// ignore
}
}
});
}
return enums;
}

private void setupRelationshipType()
{
relationshipType.setItemLabelConverter(new Converter<RelationshipType, String>()
Expand Down

0 comments on commit 8b8d27a

Please sign in to comment.