generatedEvent.fire(new ScaffoldGeneratedResources(provider, prepareResources(generatedResources)));
}
private ScaffoldProvider getScaffoldType(String scaffoldType)
{
ScaffoldProvider scaffoldImpl = null;
List<Facet> facets = project.getFacets();
List<ScaffoldProvider> detected = new ArrayList<ScaffoldProvider>();
for (Facet facet : facets) {
if (facet instanceof ScaffoldProvider)
{
detected.add((ScaffoldProvider) facet);
scaffoldImpl = (ScaffoldProvider) facet;
}
}
List<String> typeNames = new ArrayList<String>();
for (ScaffoldProvider sp : detected) {
typeNames.add(ConstraintInspector.getName(sp.getClass()));
}
if (detected.size() > 1)
{
// FIXME This needs to show the facet name!!!
String name = prompt.promptChoiceTyped("Use which scaffold provider?", typeNames,
typeNames.get(typeNames.size() - 1));
for (ScaffoldProvider sp : detected) {
if (name.equals(ConstraintInspector.getName(sp.getClass())))
{
scaffoldImpl = sp;
break;
}
}
}
if ((scaffoldType == null)
&& prompt.promptBoolean("No scaffold type was selected, use default (Metawidget & JSF)?"))
{
scaffoldType = "metawidget";
}
else if (scaffoldType == null)
{
throw new RuntimeException("Re-run with --scaffoldType {...}");
}
for (ScaffoldProvider type : impls)
{
if (ConstraintInspector.getName(type.getClass()).equals(scaffoldType))
{
scaffoldImpl = type;
}
}
if (!project.hasFacet(scaffoldImpl.getClass())
&& prompt.promptBoolean("Scaffold provider [" + scaffoldType + "] is not installed. Install it?"))
{
installFacets.fire(new InstallFacets(scaffoldImpl.getClass()));
}
else if (!project.hasFacet(scaffoldImpl.getClass()))
{
throw new RuntimeException("Aborted.");
}
if (project.hasFacet(WebResourceFacet.class))
{
FileResource<?> favicon = project.getFacet(WebResourceFacet.class).getWebResource("/favicon.ico");
if (!favicon.exists())
{
favicon.setContents(getClass().getResourceAsStream("/org/jboss/forge/scaffold/favicon.ico"));
}
}
return project.getFacet(scaffoldImpl.getClass());
}