Example usage for com.google.gwt.dev About GWT_VERSION_NUM

List of usage examples for com.google.gwt.dev About GWT_VERSION_NUM

Introduction

In this page you can find the example usage for com.google.gwt.dev About GWT_VERSION_NUM.

Prototype

String GWT_VERSION_NUM

To view the source code for com.google.gwt.dev About GWT_VERSION_NUM.

Click Source Link

Usage

From source file:com.google.code.gwt.appcache.linker.IFrameAppCacheLinker.java

License:Apache License

/**
 * Emits the wrapper HTML resource which loads the permutation javascript in
 * an external JS resource./*from   ww  w .  j  a  va2s.c  om*/
 */
private void emitPermutationArtifacts(TreeLogger logger, LinkerContext context, CompilationResult cr,
        ArtifactSet toReturn) {
    // Define the strongName(s) and replace the compilation artifact:
    String htmlStrongName = null;
    String jsStrongName = null;
    String manifestStrongName = null;
    try {
        // Compute the strongName of the permutation artifact:
        EmittedArtifact htmlArtifact = doEmitCompilation(logger, context, cr);
        htmlStrongName = htmlArtifact.getPartialPath();
        // Now remove the '.cache.html' permutation artifact from the 'toReturn'
        // ArtifactSet, and replace it with a '.cache.js' artifact:
        toReturn.remove(htmlArtifact);
        // Compute the new 'strongName' for the cache.js artifact:
        jsStrongName = htmlStrongName.substring(0, htmlStrongName.length() - 4) + "js";
        SyntheticArtifact jsArtifact = emitInputStream(logger, htmlArtifact.getContents(logger), jsStrongName);
        toReturn.add(jsArtifact);
        // Emit the cache manifest:
        EmittedArtifact cacheManifestArtifact = emitPermutationCacheManifest(logger, context, jsStrongName);
        toReturn.add(cacheManifestArtifact);
        manifestStrongName = cacheManifestArtifact.getPartialPath();
    } catch (UnableToCompleteException e) {
        logger.log(TreeLogger.ERROR, "Failed to emit compilation!", e);
    }

    DefaultTextOutput out = new DefaultTextOutput(context.isOutputCompact());
    out.print("<html manifest=\"" + manifestStrongName + "\">");
    out.newlineOpt();

    // Setup the well-known variables.
    //
    out.print("<head><script>");
    out.newlineOpt();
    out.print("var $gwt_version = \"" + About.GWT_VERSION_NUM + "\";");
    out.newlineOpt();
    out.print("var $wnd = parent;");
    out.newlineOpt();
    out.print("var $doc = $wnd.document;");
    out.newlineOpt();
    out.print("var $moduleName, $moduleBase;");
    out.newlineOpt();
    out.print("var $stats = $wnd.__gwtStatsEvent ? function(a) {return $wnd.__gwtStatsEvent(a);} : null;");
    out.newlineOpt();
    out.print("$stats && $stats({moduleName:'" + context.getModuleName()
            + "',subSystem:'startup',evtGroup:'moduleStartup'"
            + ",millis:(new Date()).getTime(),type:'moduleEvalStart'});");
    out.newlineOpt();
    out.print("</script></head>");
    out.newlineOpt();
    out.print("<body>");
    out.newlineOpt();

    // Output the JS strongName to the HTML wrapper:
    out.print("<script type=\"text/javascript\" src=\"" + jsStrongName + "\"></script></body></html>");
    out.newlineOpt();

    try {
        toReturn.add(emitString(logger, out.toString(), htmlStrongName));
    } catch (UnableToCompleteException e) {
        logger.log(TreeLogger.ERROR, "Failed to emit wrapper HTML!", e);
    }
}