Package com.google.gwt.dev.resource

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


  protected InputStream getTemplateResource(GeneratorContext context, JClassType toGenerate, TreeLogger l,
      String markerPath) throws UnableToCompleteException {
    // look for a local file first
    // TODO remove this assumption
    String path = slashify(toGenerate.getPackage().getName()) + "/" + markerPath;
    Resource res = context.getResourcesOracle().getResourceMap().get(path);
    // if not a local path, try an absolute one
    if (res == null) {
      URL url = Thread.currentThread().getContextClassLoader().getResource(markerPath);
      if (url == null) {
        return null;
      }
      try {
        return url.openStream();
      } catch (IOException e) {
        logger.log(Type.ERROR, "IO Exception occured", e);
        throw new UnableToCompleteException();
      }
    }
    try {
      return res.openContents();
    } catch (Exception e) {
      logger.log(Type.ERROR, "Exception occured reading " + path, e);
      throw new UnableToCompleteException();
    }
  }
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 in the shell's public generated directory
    File shellDir = workDirs.getShellPublicGenDir(moduleDef);
    File requestedFile = new File(shellDir, partialPath);
View Full Code Here

    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

        }
        JRealClassType type = createType(compiledClass, unresolvedTypes);
        if (type != null) {
          if (unit instanceof SourceFileCompilationUnit) {
            SourceFileCompilationUnit sourceUnit = (SourceFileCompilationUnit) unit;
            Resource sourceFile = sourceUnit.getSourceFile();
            typeOracle.addSourceReference(type, sourceFile);
          }
          binaryMapper.put(internalName, type);
          classMapType.put(type, cv);
        }
View Full Code Here

  protected InputStream getTemplateResource(GeneratorContext context, JClassType toGenerate, TreeLogger l,
      String markerPath) throws UnableToCompleteException {
    // look for a local file first
    // TODO remove this assumption
    String path = slashify(toGenerate.getPackage().getName()) + "/" + markerPath;
    Resource res = context.getResourcesOracle().getResourceMap().get(path);
    // if not a local path, try an absolute one
    if (res == null) {
      URL url = Thread.currentThread().getContextClassLoader().getResource(markerPath);
      if (url == null) {
        return null;
      }
      try {
        return url.openStream();
      } catch (IOException e) {
        logger.log(Type.ERROR, "IO Exception occured", e);
        throw new UnableToCompleteException();
      }
    }
    try {
      return res.openContents();
    } catch (Exception e) {
      logger.log(Type.ERROR, "Exception occured reading " + path, e);
      throw new UnableToCompleteException();
    }
  }
View Full Code Here

  private Document getW3cDoc(MortalLogger logger, DesignTimeUtils designTime,
                             ResourceOracle resourceOracle, String templatePath)
          throws UnableToCompleteException {

    Resource resource = resourceOracle.getResourceMap().get(templatePath);
    if (null == resource) {
      logger.die("Unable to find resource: " + templatePath);
    }

    Document doc = null;
    try {
      String content = designTime.getTemplateContent(templatePath);
      if (content == null) {
        content = Util.readStreamAsString(resource.openContents());
      }
      doc = new W3cDomHelper(logger.getTreeLogger(), resourceOracle).documentFor(
              content, resource.getPath());
    } catch (IOException iex) {
      logger.die("Error opening resource:" + resource.getLocation(), iex);
  } catch (SAXParseException e) {
    logger.die(
       "Error parsing XML (line " + e.getLineNumber() + "): "
           + e.getMessage(), e);
  }
View Full Code Here

  private Document getW3cDoc(MortalLogger logger, DesignTimeUtils designTime,
                             ResourceOracle resourceOracle, String templatePath)
          throws UnableToCompleteException {

    Resource resource = resourceOracle.getResourceMap().get(templatePath);
    if (null == resource) {
      logger.die("Unable to find resource: " + templatePath);
    }

    Document doc = null;
    try {
      String content = designTime.getTemplateContent(templatePath);
      if (content == null) {
        content = Util.readStreamAsString(resource.openContents());
      }
      doc = new W3cDomHelper(logger.getTreeLogger(), resourceOracle).documentFor(
              content, resource.getPath());
    }
    catch (SAXParseException e) {
      logger.die(
              "Error parsing XML (line " + e.getLineNumber() + "): "
                      + e.getMessage(), e);
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

  private Document getW3cDoc(MortalLogger logger, DesignTimeUtils designTime,
      ResourceOracle resourceOracle, String templatePath)
      throws UnableToCompleteException {

    Resource resource = resourceOracle.getResourceMap().get(templatePath);
    if (null == resource) {
      logger.die("Unable to find resource: " + templatePath);
    }

    Document doc = null;
    try {
      String content = designTime.getTemplateContent(templatePath);
      if (content == null) {
        content = Util.readStreamAsString(resource.openContents());
      }
      doc = new W3cDomHelper(logger.getTreeLogger(), resourceOracle).documentFor(
          content, resource.getPath());
    } catch (SAXParseException e) {
      logger.die(
          "Error parsing XML (line " + e.getLineNumber() + "): "
              + e.getMessage(), e);
    }
View Full Code Here

    private Document getW3cDoc(MortalLogger logger, DesignTimeUtils designTime,
            ResourceOracle resourceOracle, String templatePath)
            throws UnableToCompleteException {

        Resource resource = resourceOracle.getResourceMap().get(templatePath);
        if (null == resource) {
            logger.die("Unable to find resource: " + templatePath);
        }

        Document doc = null;
        try {
            String content = designTime.getTemplateContent(templatePath);
            if (content == null) {
                content = Util.readStreamAsString(resource.openContents());
            }
            doc = new W3cDomHelper(logger.getTreeLogger(), resourceOracle).documentFor(
                    content, resource.getPath());
        } catch (IOException iex) {
            logger.die("Error opening resource:" + resource.getLocation(), iex);
        } catch (SAXParseException e) {
            logger.die(
                    "Error parsing XML (line " + e.getLineNumber() + "): "
                            + e.getMessage(), e);
        }
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.