@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void initializeUI(UIBuilder builder) throws Exception
{
UIContext context = builder.getUIContext();
Project project = getSelectedProject(context);
JPAFacet<PersistenceCommonDescriptor> persistenceFacet = project.getFacet(JPAFacet.class);
JavaSourceFacet javaSourceFacet = project.getFacet(JavaSourceFacet.class);
List<String> persistenceUnits = new ArrayList<>();
List<PersistenceUnitCommon> allUnits = persistenceFacet.getConfig().getAllPersistenceUnit();
for (PersistenceUnitCommon persistenceUnit : allUnits)
{
persistenceUnits.add(persistenceUnit.getName());
}
if (!persistenceUnits.isEmpty())
{
persistenceUnit.setValueChoices(persistenceUnits).setDefaultValue(persistenceUnits.get(0));
}
// TODO: May detect where @Path resources are located
packageName.setDefaultValue(javaSourceFacet.getBasePackage() + ".rest");
RestResourceGenerator defaultResourceGenerator = null;
for (RestResourceGenerator generator : resourceGenerators)
{
if (generator.getName().equals(RestGenerationConstants.JPA_ENTITY))
{
defaultResourceGenerator = generator;
}
}
generator.setDefaultValue(defaultResourceGenerator);
if (context.getProvider().isGUI())
{
generator.setItemLabelConverter(new Converter<RestResourceGenerator, String>()
{
@Override
public String convert(RestResourceGenerator source)