Skip to content

Commit

Permalink
Modified the generator for JBDS based Forge wizards.
Browse files Browse the repository at this point in the history
The index file is now constructed by parsing the view directory names instead of relying on the names supplied by the scaffold-x plugin. This is done because the JBDS 7 wizard invokes the plugin multiple times, supplying an entity each time.
  • Loading branch information
VineetReynolds committed Jul 11, 2013
1 parent bfb1f88 commit 2af85ec
Showing 1 changed file with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
import org.jboss.forge.project.facets.WebResourceFacet;
import org.jboss.forge.project.facets.events.InstallFacets;
import org.jboss.forge.resources.DirectoryResource;
import org.jboss.forge.resources.FileResource;
import org.jboss.forge.resources.Resource;
import org.jboss.forge.resources.ResourceFilter;
import org.jboss.forge.resources.java.JavaResource;
import org.jboss.forge.scaffoldx.metawidget.MetawidgetInspectorFacade;
import org.jboss.forge.scaffoldx.AccessStrategy;
Expand Down Expand Up @@ -151,9 +153,35 @@ public List<Resource<?>> setup(String targetDir, boolean overwrite, boolean inst
*/
public List<Resource<?>> generateIndex(List<JavaClass> filteredClasses, String targetDir, boolean overwrite) {
ArrayList<Resource<?>> result = new ArrayList<Resource<?>>();

/*
* TODO: Revert this change at a later date, if necessary. This is currently done to ensure that entities are picked up
* during invocation of the plugin from the Forge wizard in JBDS.
*/
ResourceFilter filter = new ResourceFilter()
{
@Override
public boolean accept(Resource<?> resource)
{
FileResource<?> file = (FileResource<?>) resource;

if (!file.isDirectory()
|| file.getName().equals("resources")
|| file.getName().equals("WEB-INF")
|| file.getName().equals("META-INF"))
{
return false;
}

return true;
}
};

WebResourceFacet web = this.project.getFacet(WebResourceFacet.class);
List<Resource<?>> resources = web.getWebResource(targetDir + "/views/").listResources(filter);
List<String> entityNames = new ArrayList<String>();
for (JavaClass klass : filteredClasses) {
entityNames.add(klass.getName());
for (Resource<?> resource : resources) {
entityNames.add(resource.getName());
}

Map<String, Object> root = new HashMap<String, Object>();
Expand Down

0 comments on commit 2af85ec

Please sign in to comment.