Package com.google.gwt.dev.resource

Examples of com.google.gwt.dev.resource.Resource


    try {
      // Look for the requested file on the public path.
      //
      ModuleDef moduleDef = getModuleDef(logger, moduleName);
      if (shouldAutoGenerateResources()) {
        Resource publicResource = moduleDef.findPublicFile(partialPath);
        if (publicResource != null) {
          foundResource = publicResource.getURL();
        }

        if (foundResource == null) {
          // Look for public generated files
          File shellDir = getShellWorkDirs().getShellPublicGenDir(moduleDef);
View Full Code Here


    URL foundResource = null;
    try {
      // Look for the requested file on the public path.
      //
      ModuleDef moduleDef = getModuleDef(logger, moduleName);
      Resource publicResource = moduleDef.findPublicFile(partialPath);
      if (publicResource != null) {
        foundResource = publicResource.getURL();
      }

      if (foundResource == null) {
        // Look for generated files
        File shellDir = new File(getOutputDir(), GWTShell.GWT_SHELL_PATH
View Full Code Here

        if (pathPrefix.allows(path)) {
          assert (path.startsWith(pathPrefix.getPrefix()));
          if (pathPrefix.shouldReroot()) {
            String rerootedPath = pathPrefix.getRerootedPath(path);
            // Try to reuse the same wrapper.
            Resource exposed = exposedResourceMap.get(rerootedPath);
            if (exposed instanceof ResourceWrapper) {
              ResourceWrapper exposedWrapper = (ResourceWrapper) exposed;
              if (exposedWrapper.resource == resource) {
                externalMap.put(rerootedPath, exposedWrapper);
                ++hitCount;
View Full Code Here

    }

    String partialPath = path.substring(moduleContext.length());

    // Try to get the resource from the application's public path
    Resource publicResource = moduleDef.findPublicFile(partialPath);
    if (publicResource != null) {
      return publicResource.getURL();
    }

    // Otherwise try the path but rooted in the shell's output directory
    File shellDir = new File(outDir, GWTShell.GWT_SHELL_PATH + File.separator
        + moduleDef.getName());
View Full Code Here

      if (cudRef != null) {
        cud = cudRef.get();
      }
    }
    if (cud == null) {
      Resource classSource = classSources.get(topType);
      String source = null;
      if (classSource != null) {
        InputStream stream = classSource.openContents();
        source = Util.readStreamAsString(stream);
      }
      if (source == null) {
        // cache negative result so we don't try again
        cudCache.put(topType, null);
View Full Code Here

  @Override
  public InputSource resolveEntity(String publicId, String systemId) {
    String matchingPrefix = findMatchingPrefix(systemId);

    Resource resource = null;
    if (matchingPrefix != null) {
      resource =
          resourceOracle.getResource(RESOURCES + systemId.substring(matchingPrefix.length()));
    }

    if (resource == null) {
      resource = resourceOracle.getResource(pathBase + systemId);
    }

    if (resource != null) {
      String content;
      try {
        InputStream resourceStream = resource.openContents();
        content = Util.readStreamAsString(resourceStream);
      } catch (IOException ex) {
        logger.log(TreeLogger.ERROR, "Error reading resource: " + resource.getLocation());
        throw new RuntimeException(ex);
      }
      InputSource inputSource = new InputSource(new StringReader(content));
      inputSource.setPublicId(publicId);
      inputSource.setSystemId(resource.getPath());
      return inputSource;
    }
    /*
     * Let Sax find it on the interweb.
     */
 
View Full Code Here

    UiBinderWriter uiBinderWriter = new UiBinderWriter(interfaceType, implName, templatePath,
        oracle, logger, fieldManager, messages, designTime, uiBinderCtx,
        useSafeHtmlTemplates(logger, propertyOracle), useLazyWidgetBuilders, BINDER_URI,
        resourceOracle);

    Resource resource = getTemplateResource(logger, templatePath, resourceOracle);

    // Ensure that generated uibinder source is modified at least as often as synthesized .cssmap
    // resources, otherwise it would be possible to synthesize a modified .cssmap resource but fail
    // to retrigger the InlineClientBundleGenerator that processes it.
    binderPrintWriter.println("// .ui.xml template last modified: " + resource.getLastModified());
    Document doc = getW3cDoc(logger, designTime, resourceOracle, templatePath, resource);
    designTime.rememberPathForElements(doc);

    uiBinderWriter.parseDocument(doc, binderPrintWriter);
View Full Code Here

    return doc;
  }

  private Resource getTemplateResource(MortalLogger logger, String templatePath,
      ResourceOracle resourceOracle) throws UnableToCompleteException {
    Resource resource = resourceOracle.getResource(templatePath);
    if (null == resource) {
      logger.die("Unable to find resource: " + templatePath);
    }
    return resource;
  }
View Full Code Here

    String partialPath = localizedPath.replace('.', '/');
    for (int i = 0; i < loaders.size(); i++) {
      ResourceFactory element = loaders.get(i);
      String ext = "." + element.getExt();
      String path = partialPath + ext;
      Resource resource = resourceOracle.getResource(path);
      if (resource == null && partialPath.contains("$")) {
        // Also look for A_B for inner classes, as $ in path names
        // can cause issues for some build tools.
        path = partialPath.replace('$', '_') + ext;
        resource = resourceOracle.getResource(path);
      }
      if (resource != null) {
        InputStream resourceStream = null;
        try {
          resourceStream = resource.openContents();
        } catch (IOException ex) {
          logger.log(TreeLogger.ERROR, "Error opening resource: " + resource.getLocation());
          throw new RuntimeException(ex);
        }
        AbstractResource found = element.load(resourceStream, locale);
        found.setPath(path);
        resources.add(found);
View Full Code Here

  // TODO(stalcup): migrate internal Generators away from needing ClassLoader fallback.
  public static URL tryFindResourceUrl(TreeLogger logger, ResourceOracle resourceOracle,
      String resourceName) {
    // Also associates the requested resource with the currently being rebound type (via
    // RecordingResourceOracle).
    Resource resource = resourceOracle.getResource(resourceName);
    if (resource != null) {
      return resource.getURL();
    }

    // Fall back on loading resources via ClassLoader. This is needed for backwards compatibility
    // but should be avoided in favor of ResourceOracle loads since ResourceOracle loads so that
    // Resource modifications can be noticed and reacted to in per-file compilation recompiles.
View Full Code Here

TOP

Related Classes of com.google.gwt.dev.resource.Resource

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.