当前位置: 首页>>代码示例>>Java>>正文


Java Resource类代码示例

本文整理汇总了Java中org.jboss.forge.addon.resource.Resource的典型用法代码示例。如果您正苦于以下问题:Java Resource类的具体用法?Java Resource怎么用?Java Resource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Resource类属于org.jboss.forge.addon.resource包,在下文中一共展示了Resource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findPom

import org.jboss.forge.addon.resource.Resource; //导入依赖的package包/类
public static PomFileXml findPom(UIContext context, String project, File pomFile) {
    if (pomFile == null) {
        DirectoryResource initialDir = (DirectoryResource) context.getInitialSelection().get();
        if (initialDir != null) {
            Resource<?> child = initialDir.getChild(project + "/pom.xml");
            if (child.exists()) {
                pomFile = ResourceUtil.getContextFile(child);
            }
        }
    }
    if (Files.isFile(pomFile)) {
        Document doc = null;
        try {
            doc = CheStackDetector.parseXmlFile(pomFile);
        } catch (Exception e) {
            LOG.debug("Failed to parse " + pomFile + " with: " + e, e);
        }
        return new PomFileXml(pomFile, doc);
    }
    return null;
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:22,代码来源:MavenHelpers.java

示例2: addGroovyVerticle

import org.jboss.forge.addon.resource.Resource; //导入依赖的package包/类
private String addGroovyVerticle(Project project, String verticleName, boolean isMain) {
  // Add groovy resource
  CustomResourceFacet groovy = new CustomResourceFacet(project, "groovy");
  if (!groovy.isInstalled()) {
    groovy.install();
  }
  Resource<URL> urlResource = resourceFactory.create(VertxMavenFacet.class.getResource("verticle.groovy"));
  if (!verticleName.endsWith(".groovy")) {
    verticleName += ".groovy";
  }
  FileResource<?> resource = groovy.createResource(urlResource.getContents().toCharArray(), verticleName);

  // Update pom if it's main
  if (isMain) {
    ForgeUtils.addPropertyToProject(project, "vertx.verticle", verticleName);
  }

  // Add groovy dependency if not there
  ForgeUtils.getOrAddDependency(project, "io.vertx", "vertx-lang-groovy");

  return resource.getFullyQualifiedName();
}
 
开发者ID:cescoffier,项目名称:vertx-forge-addon,代码行数:23,代码来源:Verticles.java

示例3: addJavascriptVerticle

import org.jboss.forge.addon.resource.Resource; //导入依赖的package包/类
private String addJavascriptVerticle(Project project, String verticleName, boolean isMain) {
  // Add groovy resource
  CustomResourceFacet groovy = new CustomResourceFacet(project, "javascript");
  if (!groovy.isInstalled()) {
    groovy.install();
  }
  Resource<URL> urlResource = resourceFactory.create(VertxMavenFacet.class.getResource("verticle.js"));
  if (!verticleName.endsWith(".js")) {
    verticleName += ".js";
  }
  FileResource<?> resource = groovy.createResource(urlResource.getContents().toCharArray(), verticleName);

  // Update pom if it's main
  if (isMain) {
    ForgeUtils.addPropertyToProject(project, "vertx.verticle", verticleName);
  }

  // Add groovy dependency if not there
  ForgeUtils.getOrAddDependency(project, "io.vertx", "vertx-lang-js");

  return resource.getFullyQualifiedName();
}
 
开发者ID:cescoffier,项目名称:vertx-forge-addon,代码行数:23,代码来源:Verticles.java

示例4: addRubyVerticle

import org.jboss.forge.addon.resource.Resource; //导入依赖的package包/类
private String addRubyVerticle(Project project, String verticleName, boolean isMain) {
  // Add groovy resource
  CustomResourceFacet ruby = new CustomResourceFacet(project, "ruby");
  if (!ruby.isInstalled()) {
    ruby.install();
  }
  Resource<URL> urlResource = resourceFactory.create(VertxMavenFacet.class.getResource("verticle.rb"));

  if (!verticleName.endsWith(".rb")) {
    verticleName += ".rb";
  }
  FileResource<?> resource = ruby.createResource(urlResource.getContents().toCharArray(), verticleName);

  // Update pom if it's main
  if (isMain) {
    ForgeUtils.addPropertyToProject(project, "vertx.verticle", verticleName);
  }

  // Add groovy dependency if not there
  ForgeUtils.getOrAddDependency(project, "io.vertx", "vertx-lang-ruby");

  return resource.getFullyQualifiedName();
}
 
开发者ID:cescoffier,项目名称:vertx-forge-addon,代码行数:24,代码来源:Verticles.java

示例5: processInclude

import org.jboss.forge.addon.resource.Resource; //导入依赖的package包/类
private String processInclude(Map<String, Object> dataModel)
{
   Resource<?> resource = resourceFactory.create(getClass().getResource(
            SCAFFOLD_DIR + source));
   if (project.hasFacet(TemplateFacet.class))
   {
      TemplateFacet templates = project.getFacet(TemplateFacet.class);
      Resource<?> templateResource = templates.getResource(source);
      if (templateResource.exists())
      {
         resource = templateResource;
      }
   }

   Template template = templateFactory.create(resource, FreemarkerTemplate.class);
   String output = null;
   try
   {
      output = template.process(dataModel);
   }
   catch (IOException ioEx)
   {
      throw new IllegalStateException(ioEx);
   }
   return output;
}
 
开发者ID:forge,项目名称:angularjs-addon,代码行数:27,代码来源:DetailTemplateStrategy.java

示例6: setup

import org.jboss.forge.addon.resource.Resource; //导入依赖的package包/类
@Override
public List<Resource<?>> setup(ScaffoldSetupContext setupContext)
{
   setProject(setupContext.getProject());
   String targetDir = setupContext.getTargetDirectory();
   targetDir = (targetDir == null) ? "" : targetDir;

   // Setup static resources.
   ArrayList<Resource<?>> result = new ArrayList<>();
   WebResourcesFacet web = project.getFacet(WebResourcesFacet.class);
   ProcessingStrategy strategy = new CopyResourcesStrategy(web);
   for (ScaffoldResource scaffoldResource : getStatics(targetDir, strategy))
   {
      result.add(scaffoldResource.generate());
   }

   return result;
}
 
开发者ID:forge,项目名称:angularjs-addon,代码行数:19,代码来源:AngularScaffoldProvider.java

示例7: execute

import org.jboss.forge.addon.resource.Resource; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Resource<?> execute(ScaffoldResource scaffoldResource)
{
   List<Map<String, String>> properties = (List<Map<String, String>>) dataModel.get("properties");
   StringBuilder searchFormProperties = new StringBuilder();
   for (Map<String, String> property : properties)
   {
      dataModel.put("property", property);
      Include includeFile = new Include(SEARCH_FORM_INPUT);
      String output = includeFile.processInclude(dataModel);
      searchFormProperties.append(output).append('\n');
   }
   Include searchResultsInclude = new Include(SEARCH_RESULTS);
   Include searchResultsPaginatorInclude = new Include(SEARCH_RESULTS_PAGINATOR);
   String searchResults = searchResultsInclude.processInclude(dataModel);
   String searchResultsPaginator = searchResultsPaginatorInclude.processInclude(dataModel);
   dataModel.put("searchFormProperties", searchFormProperties.toString());
   dataModel.put("searchResults", searchResults);
   dataModel.put("searchResultsPaginator", searchResultsPaginator);
   ProcessTemplateStrategy strategy = new ProcessTemplateStrategy(web, resourceFactory, project,
            templateFactory, dataModel);
   return strategy.execute(scaffoldResource);
}
 
开发者ID:forge,项目名称:angularjs-addon,代码行数:25,代码来源:SearchTemplateStrategy.java

示例8: testGenerateSearchResultsPaginator

import org.jboss.forge.addon.resource.Resource; //导入依赖的package包/类
@Test
public void testGenerateSearchResultsPaginator() throws Exception
{
   Map<String, String> idProperties = new HashMap<String, String>();
   idProperties.put("name", "id");
   idProperties.put("hidden", "true");
   idProperties.put("type", "number");

   Map<String, Object> root = new HashMap<String, Object>();
   root.put("entityName", "SampleEntity");
   root.put("property", idProperties);
   Resource<URL> templateResource = resourceFactory.create(getClass().getResource(
            Deployments.BASE_PACKAGE_PATH + Deployments.SEARCH_RESULTS_PAGINATOR_INCLUDE));
   Template processor = processorFactory.create(templateResource, FreemarkerTemplate.class);
   String output = processor.process(root);
   assertThat(output, IsEqual.equalTo(PAGINATOR_OUTPUT));
}
 
开发者ID:forge,项目名称:angularjs-addon,代码行数:18,代码来源:FreemarkerClientPartialsSearchResultsPaginatorTest.java

示例9: testGenerateBasicStringProperty

import org.jboss.forge.addon.resource.Resource; //导入依赖的package包/类
@Test
public void testGenerateBasicStringProperty() throws Exception
{
   Map<String, Object> root = createInspectionResultWrapper(ENTITY_NAME, BASIC_STRING_PROP);

   Resource<URL> templateResource = resourceFactory.create(getClass().getResource(
            Deployments.BASE_PACKAGE_PATH + Deployments.BASIC_PROPERTY_DETAIL_INCLUDE));
   Template processor = processorFactory.create(templateResource, FreemarkerTemplate.class);
   String output = processor.process(root);
   Document html = Jsoup.parseBodyFragment(output);
   assertThat(output.trim(), not(equalTo("")));

   Elements container = html.select("div.form-group");
   assertThat(container, notNullValue());
   assertThat(container.attr("ng-class"), not(equalTo("")));

   Elements formInputElement = html.select("div.form-group input");
   assertThat(formInputElement.attr("id"), equalTo("fullName"));
   assertThat(formInputElement.attr("type"), equalTo("text"));
   assertThat(formInputElement.attr("ng-model"), equalTo(StringUtils.camelCase(ENTITY_NAME) + "." + "fullName"));
}
 
开发者ID:forge,项目名称:angularjs-addon,代码行数:22,代码来源:FreemarkerClientPartialsBasicPropertyTest.java

示例10: testGenerateBasicStringPropertyWithMaxlength

import org.jboss.forge.addon.resource.Resource; //导入依赖的package包/类
@Test
public void testGenerateBasicStringPropertyWithMaxlength() throws Exception
{
   Map<String, Object> root = createInspectionResultWrapper(ENTITY_NAME, STRING_PROP_WITH_MAX_LEN);

   Resource<URL> templateResource = resourceFactory.create(getClass().getResource(
            Deployments.BASE_PACKAGE_PATH + Deployments.BASIC_PROPERTY_DETAIL_INCLUDE));
   Template processor = processorFactory.create(templateResource, FreemarkerTemplate.class);
   String output = processor.process(root);
   Document html = Jsoup.parseBodyFragment(output);
   assertThat(output.trim(), not(equalTo("")));

   Elements container = html.select("div.form-group");
   assertThat(container, notNullValue());
   assertThat(container.attr("ng-class"), not(equalTo("")));

   Elements formInputElement = html.select("div.form-group input");
   assertThat(formInputElement.attr("id"), equalTo("fullName"));
   assertThat(formInputElement.attr("type"), equalTo("text"));
   assertThat(formInputElement.attr("ng-model"), equalTo(StringUtils.camelCase(ENTITY_NAME) + "." + "fullName"));
   assertThat(formInputElement.attr("ng-maxlength"), equalTo("100"));
}
 
开发者ID:forge,项目名称:angularjs-addon,代码行数:23,代码来源:FreemarkerClientPartialsBasicPropertyTest.java

示例11: testGenerateBasicStringPropertyWithMinlength

import org.jboss.forge.addon.resource.Resource; //导入依赖的package包/类
@Test
public void testGenerateBasicStringPropertyWithMinlength() throws Exception
{
   Map<String, Object> root = createInspectionResultWrapper(ENTITY_NAME, STRING_PROP_WITH_MIN_LEN);

   Resource<URL> templateResource = resourceFactory.create(getClass().getResource(
            Deployments.BASE_PACKAGE_PATH + Deployments.BASIC_PROPERTY_DETAIL_INCLUDE));
   Template processor = processorFactory.create(templateResource, FreemarkerTemplate.class);
   String output = processor.process(root);
   Document html = Jsoup.parseBodyFragment(output);
   assertThat(output.trim(), not(equalTo("")));

   Elements container = html.select("div.form-group");
   assertThat(container, notNullValue());
   assertThat(container.attr("ng-class"), not(equalTo("")));

   Elements formInputElement = html.select("div.form-group input");
   assertThat(formInputElement.attr("id"), equalTo("fullName"));
   assertThat(formInputElement.attr("type"), equalTo("text"));
   assertThat(formInputElement.attr("ng-model"), equalTo(StringUtils.camelCase(ENTITY_NAME) + "." + "fullName"));
   assertThat(formInputElement.attr("ng-minlength"), equalTo("5"));
}
 
开发者ID:forge,项目名称:angularjs-addon,代码行数:23,代码来源:FreemarkerClientPartialsBasicPropertyTest.java

示例12: testGenerateBasicNumberProperty

import org.jboss.forge.addon.resource.Resource; //导入依赖的package包/类
@Test
public void testGenerateBasicNumberProperty() throws Exception
{
   Map<String, Object> root = createInspectionResultWrapper(ENTITY_NAME, NUMBER_PROP);

   Resource<URL> templateResource = resourceFactory.create(getClass().getResource(
            Deployments.BASE_PACKAGE_PATH + Deployments.BASIC_PROPERTY_DETAIL_INCLUDE));
   Template processor = processorFactory.create(templateResource, FreemarkerTemplate.class);
   String output = processor.process(root);
   Document html = Jsoup.parseBodyFragment(output);
   assertThat(output.trim(), not(equalTo("")));

   Elements container = html.select("div.form-group");
   assertThat(container, notNullValue());
   assertThat(container.attr("ng-class"), not(equalTo("")));

   Elements formInputElement = html.select("div.form-group input");
   assertThat(formInputElement.attr("id"), equalTo("score"));
   assertThat(formInputElement.attr("type"), equalTo("number"));
   assertThat(formInputElement.attr("ng-model"), equalTo(StringUtils.camelCase(ENTITY_NAME) + "." + "score"));
}
 
开发者ID:forge,项目名称:angularjs-addon,代码行数:22,代码来源:FreemarkerClientPartialsBasicPropertyTest.java

示例13: testGenerateBasicNumberPropertyWithMinConstraint

import org.jboss.forge.addon.resource.Resource; //导入依赖的package包/类
@Test
public void testGenerateBasicNumberPropertyWithMinConstraint() throws Exception
{
   Map<String, Object> root = createInspectionResultWrapper(ENTITY_NAME, NUMBER_PROP_WITH_MIN_VAL);

   Resource<URL> templateResource = resourceFactory.create(getClass().getResource(
            Deployments.BASE_PACKAGE_PATH + Deployments.BASIC_PROPERTY_DETAIL_INCLUDE));
   Template processor = processorFactory.create(templateResource, FreemarkerTemplate.class);
   String output = processor.process(root);
   Document html = Jsoup.parseBodyFragment(output);
   assertThat(output.trim(), not(equalTo("")));

   Elements container = html.select("div.form-group");
   assertThat(container, notNullValue());
   assertThat(container.attr("ng-class"), not(equalTo("")));

   Elements formInputElement = html.select("div.form-group input");
   assertThat(formInputElement.attr("id"), equalTo("score"));
   assertThat(formInputElement.attr("type"), equalTo("number"));
   assertThat(formInputElement.attr("min"), equalTo("0"));
   assertThat(formInputElement.attr("ng-model"), equalTo(StringUtils.camelCase(ENTITY_NAME) + "." + "score"));
}
 
开发者ID:forge,项目名称:angularjs-addon,代码行数:23,代码来源:FreemarkerClientPartialsBasicPropertyTest.java

示例14: testGenerateBasicNumberPropertyWithMaxConstraint

import org.jboss.forge.addon.resource.Resource; //导入依赖的package包/类
@Test
public void testGenerateBasicNumberPropertyWithMaxConstraint() throws Exception
{
   Map<String, Object> root = createInspectionResultWrapper(ENTITY_NAME, NUMBER_PROP_WITH_MAX_VAL);

   Resource<URL> templateResource = resourceFactory.create(getClass().getResource(
            Deployments.BASE_PACKAGE_PATH + Deployments.BASIC_PROPERTY_DETAIL_INCLUDE));
   Template processor = processorFactory.create(templateResource, FreemarkerTemplate.class);
   String output = processor.process(root);
   Document html = Jsoup.parseBodyFragment(output);
   assertThat(output.trim(), not(equalTo("")));

   Elements container = html.select("div.form-group");
   assertThat(container, notNullValue());
   assertThat(container.attr("ng-class"), not(equalTo("")));

   Elements formInputElement = html.select("div.form-group input");
   assertThat(formInputElement.attr("id"), equalTo("score"));
   assertThat(formInputElement.attr("type"), equalTo("number"));
   assertThat(formInputElement.attr("max"), equalTo("100"));
   assertThat(formInputElement.attr("ng-model"), equalTo(StringUtils.camelCase(ENTITY_NAME) + "." + "score"));
}
 
开发者ID:forge,项目名称:angularjs-addon,代码行数:23,代码来源:FreemarkerClientPartialsBasicPropertyTest.java

示例15: testGenerateBasicDateProperty

import org.jboss.forge.addon.resource.Resource; //导入依赖的package包/类
@Test
public void testGenerateBasicDateProperty() throws Exception
{
   Map<String, Object> root = createInspectionResultWrapper(ENTITY_NAME, DATE_PROP);

   Resource<URL> templateResource = resourceFactory.create(getClass().getResource(
            Deployments.BASE_PACKAGE_PATH + Deployments.BASIC_PROPERTY_DETAIL_INCLUDE));
   Template processor = processorFactory.create(templateResource, FreemarkerTemplate.class);
   String output = processor.process(root);
   Document html = Jsoup.parseBodyFragment(output);
   assertThat(output.trim(), not(equalTo("")));

   Elements container = html.select("div.form-group");
   assertThat(container, notNullValue());
   assertThat(container.attr("ng-class"), not(equalTo("")));

   Elements formInputElement = html.select("div.form-group date");
   assertThat(formInputElement.attr("id"), equalTo("dateOfBirth"));
   assertThat(formInputElement.attr("ng-model"), equalTo(StringUtils.camelCase(ENTITY_NAME) + "." + "dateOfBirth"));
}
 
开发者ID:forge,项目名称:angularjs-addon,代码行数:21,代码来源:FreemarkerClientPartialsBasicPropertyTest.java


注:本文中的org.jboss.forge.addon.resource.Resource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。