Ejemplo n.º 1
0
  @Override
  public NavigationResult getSetupFlow(ScaffoldSetupContext setupContext) {
    Project project = setupContext.getProject();
    setProject(setupContext.getProject());
    NavigationResultBuilder builder = NavigationResultBuilder.create();
    List<Class<? extends UICommand>> setupCommands = new ArrayList<>();
    if (!project.hasFacet(JPAFacet.class)) {
      builder.add(JPASetupWizard.class);
    }
    if (!project.hasFacet(CDIFacet.class)) {
      setupCommands.add(CDISetupCommand.class);
    }
    if (!project.hasFacet(EJBFacet.class)) {
      setupCommands.add(EJBSetupWizard.class);
    }
    if (!project.hasFacet(ServletFacet.class)) {
      // TODO: FORGE-1296. Ensure that this wizard only sets up Servlet 3.0+
      setupCommands.add(ServletSetupWizard.class);
    }
    if (!project.hasFacet(FacesFacet.class)) {
      setupCommands.add(FacesSetupWizard.class);
    }

    Metadata compositeSetupMetadata =
        Metadata.forCommand(ScaffoldSetupWizard.class)
            .name("Setup Facets")
            .description("Setup all dependent facets for the Faces scaffold.");
    builder.add(compositeSetupMetadata, setupCommands);
    return builder.build();
  }
Ejemplo n.º 2
0
  @Override
  public List<Resource<?>> setup(ScaffoldSetupContext setupContext) {
    setProject(setupContext.getProject());
    String targetDir = setupContext.getTargetDirectory();
    Resource<?> template = null;
    List<Resource<?>> resources = generateIndex(targetDir, template);
    setupWebXML();

    return resources;
  }
Ejemplo n.º 3
0
 @SuppressWarnings("rawtypes")
 @Override
 public boolean isSetup(ScaffoldSetupContext setupContext) {
   Project project = setupContext.getProject();
   setProject(project);
   String targetDir = setupContext.getTargetDirectory();
   targetDir = targetDir == null ? "" : targetDir;
   if (project.hasAllFacets(
       Arrays.asList(
           WebResourcesFacet.class,
           DependencyFacet.class,
           JPAFacet.class,
           EJBFacet.class,
           CDIFacet.class,
           ServletFacet.class,
           FacesFacet.class))) {
     WebResourcesFacet web = project.getFacet(WebResourcesFacet.class);
     boolean areResourcesInstalled =
         web.getWebResource(targetDir + INDEX_HTML).exists()
             && web.getWebResource(targetDir + INDEX_XHTML).exists()
             && web.getWebResource(ERROR_XHTML).exists()
             && web.getWebResource(ADD_PNG).exists()
             && web.getWebResource(BOOTSTRAP_CSS).exists()
             && web.getWebResource(FALSE_PNG).exists()
             && web.getWebResource(FAVICON_ICO).exists()
             && web.getWebResource(FORGE_LOGO_PNG).exists()
             && web.getWebResource(FORGE_STYLE_CSS).exists()
             && web.getWebResource(REMOVE_PNG).exists()
             && web.getWebResource(SEARCH_PNG).exists()
             && web.getWebResource(TRUE_PNG).exists()
             && web.getWebResource(JBOSS_COMMUNITY_PNG).exists()
             && web.getWebResource(PAGINATOR).exists()
             && getTemplateStrategy().getDefaultTemplate().exists();
     ServletFacet servlet = project.getFacet(ServletFacet.class);
     boolean isWelcomeFileListed = false;
     if (servlet instanceof ServletFacet_3_0) {
       WebAppDescriptor servletConfig = (WebAppDescriptor) servlet.getConfig();
       for (WelcomeFileListType<WebAppDescriptor> welcomeFileList :
           servletConfig.getAllWelcomeFileList()) {
         for (String welcomeFile : welcomeFileList.getAllWelcomeFile()) {
           if (welcomeFile.equals(INDEX_HTML)) {
             isWelcomeFileListed = true;
             break;
           }
         }
       }
     } else if (servlet instanceof ServletFacet_3_1) {
       org.jboss.shrinkwrap.descriptor.api.webapp31.WebAppDescriptor servletConfig =
           (org.jboss.shrinkwrap.descriptor.api.webapp31.WebAppDescriptor) servlet.getConfig();
       for (org.jboss.shrinkwrap.descriptor.api.webcommon31.WelcomeFileListType<
               org.jboss.shrinkwrap.descriptor.api.webapp31.WebAppDescriptor>
           welcomeFileList : servletConfig.getAllWelcomeFileList()) {
         for (String welcomeFile : welcomeFileList.getAllWelcomeFile()) {
           if (welcomeFile.equals(INDEX_HTML)) {
             isWelcomeFileListed = true;
             break;
           }
         }
       }
     }
     return areResourcesInstalled && isWelcomeFileListed;
   }
   return false;
 }