Package org.jboss.forge.scaffold

Examples of org.jboss.forge.scaffold.ScaffoldProvider


            final PipeOut out,
            @Option(name = "scaffoldType", required = false,
                     completer = ScaffoldProviderCompleter.class) final String scaffoldType,
            @Option(flagOnly = true, name = "overwrite") final boolean overwrite)
   {
      ScaffoldProvider provider = getScaffoldType(scaffoldType);
      List<Resource<?>> generatedResources = provider.setup(overwrite);

      // TODO give plugins a chance to react to generated resources, use event bus?
      if (!generatedResources.isEmpty())
         generatedEvent.fire(new ScaffoldGeneratedResources(provider, prepareResources(generatedResources)));
   }
View Full Code Here


            final PipeOut out,
            @Option(name = "scaffoldType", required = false,
                     completer = ScaffoldProviderCompleter.class) final String scaffoldType,
            @Option(flagOnly = true, name = "overwrite") final boolean overwrite)
   {
      ScaffoldProvider provider = getScaffoldType(scaffoldType);
      List<Resource<?>> generatedResources = provider.generateIndex(overwrite);

      // TODO give plugins a chance to react to generated resources, use event bus?
      if (!generatedResources.isEmpty())
         generatedEvent.fire(new ScaffoldGeneratedResources(provider, prepareResources(generatedResources)));
   }
View Full Code Here

            @Option(name = "scaffoldType", required = false,
                     completer = ScaffoldProviderCompleter.class) final String scaffoldType,
            final PipeOut out,
            @Option(flagOnly = true, name = "overwrite") final boolean overwrite)
   {
      ScaffoldProvider provider = getScaffoldType(scaffoldType);
      List<Resource<?>> generatedResources = provider.generateTemplates(overwrite);

      // TODO give plugins a chance to react to generated resources, use event bus?
      if (!generatedResources.isEmpty())
         generatedEvent.fire(new ScaffoldGeneratedResources(provider, prepareResources(generatedResources)));
   }
View Full Code Here

         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());
   }
View Full Code Here

      {
         ShellMessages.error(out, "Must specify a domain entity on which to operate.");
         return;
      }

      ScaffoldProvider provider = getScaffoldType(scaffoldType);

      for (JavaResource jr : javaTargets)
      {
         JavaClass entity = (JavaClass) (jr).getJavaSource();
         List<Resource<?>> generatedResources = provider.generateFromEntity(entity, overwrite);

         // TODO give plugins a chance to react to generated resources, use event bus?
         if (!generatedResources.isEmpty())
            generatedEvent.fire(new ScaffoldGeneratedResources(provider, prepareResources(generatedResources)));
View Full Code Here

            @Option(name = "scaffoldType", required = false,
                     completer = ScaffoldProviderCompleter.class) final String scaffoldType,
            @Option(flagOnly = true, name = "overwrite") final boolean overwrite,
            @Option(name = "usingTemplate") final Resource<?> template)
   {
      ScaffoldProvider provider = getScaffoldType(scaffoldType);
      verifyTemplate(provider, template);
      List<Resource<?>> generatedResources = provider.setup(template, overwrite);

      // TODO give plugins a chance to react to generated resources, use event bus?
      if (!generatedResources.isEmpty())
         generatedEvent.fire(new ScaffoldGeneratedResources(provider, prepareResources(generatedResources)));
   }
View Full Code Here

            @Option(name = "scaffoldType", required = false,
                     completer = ScaffoldProviderCompleter.class) final String scaffoldType,
            @Option(flagOnly = true, name = "overwrite") final boolean overwrite,
            @Option(name = "usingTemplate") final Resource<?> template)
   {
      ScaffoldProvider provider = getScaffoldType(scaffoldType);
      verifyTemplate(provider, template);
      List<Resource<?>> generatedResources = provider.generateIndex(template, overwrite);

      // TODO give plugins a chance to react to generated resources, use event bus?
      if (!generatedResources.isEmpty())
         generatedEvent.fire(new ScaffoldGeneratedResources(provider, prepareResources(generatedResources)));
   }
View Full Code Here

            @Option(name = "scaffoldType", required = false,
                     completer = ScaffoldProviderCompleter.class) final String scaffoldType,
            final PipeOut out,
            @Option(flagOnly = true, name = "overwrite") final boolean overwrite)
   {
      ScaffoldProvider provider = getScaffoldType(scaffoldType);
      List<Resource<?>> generatedResources = provider.generateTemplates(overwrite);

      // TODO give plugins a chance to react to generated resources, use event bus?
      if (!generatedResources.isEmpty())
         generatedEvent.fire(new ScaffoldGeneratedResources(provider, prepareResources(generatedResources)));
   }
View Full Code Here

      {
         ShellMessages.error(out, "Must specify a domain @Entity on which to operate.");
         return;
      }

      ScaffoldProvider provider = getScaffoldType(scaffoldType);
      verifyTemplate(provider, template);

      for (JavaResource jr : javaTargets)
      {
         JavaClass entity = (JavaClass) (jr).getJavaSource();
         List<Resource<?>> generatedResources = provider.generateFromEntity(template, entity, overwrite);

         // TODO give plugins a chance to react to generated resources, use event bus?
         if (!generatedResources.isEmpty())
            generatedEvent.fire(new ScaffoldGeneratedResources(provider, prepareResources(generatedResources)));
View Full Code Here

   }

   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());
   }
View Full Code Here

TOP

Related Classes of org.jboss.forge.scaffold.ScaffoldProvider

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.