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
}