Author: [EMAIL PROTECTED]
Date: Fri Nov 7 10:44:21 2008
New Revision: 3985
Modified:
changes/kprobst/soyc-vis/src/com/google/gwt/soyc/LiteralsCollection.java
Log:
Updated html outputter to use google api table. Much nicer.
Modified:
changes/kprobst/soyc-vis/src/com/google/gwt/soyc/LiteralsCollection.java
==============================================================================
---
changes/kprobst/soyc-vis/src/com/google/gwt/soyc/LiteralsCollection.java
(original)
+++
changes/kprobst/soyc-vis/src/com/google/gwt/soyc/LiteralsCollection.java
Fri Nov 7 10:44:21 2008
@@ -33,6 +33,59 @@
literalType = type;
}
+ public void createHtmlFileTable(String fileName) throws IOException{
+
+ final PrintWriter outFile = new PrintWriter(fileName);
+
+ outFile.println("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">");
+ outFile.println("<html>");
+ outFile.println("<head>");
+ outFile.println("<script type=\"text/javascript\"
src=\"http://www.google.com/jsapi\"></script>");
+ outFile.println("<script type=\"text/javascript\">");
+ outFile.println("google.load(\"visualization\", \"1\",
{packages:[\"table\"]});");
+ outFile.println("google.setOnLoadCallback(drawTable);");
+ outFile.println("function drawTable() {");
+ outFile.println("var data = new google.visualization.DataTable();");
+ outFile.println("data.addColumn('string', 'Literal');");
+ outFile.println("data.addColumn('string', 'Origin');");
+
+ int numRows = literalToLocations.keySet().size();
+ outFile.println("data.addRows(" + numRows + ");");
+
+ int rowCt = 0;
+ for (String literal : literalToLocations.keySet()){
+ HashSet<String> locations = literalToLocations.get(literal);
+
+ if (literal.trim().compareTo("") == 0){
+ literal = "[whitespace only string]";
+ }
+ literal = escapeXml(literal);
+
+ int ct = 0;
+ for (String location : locations){
+ if (ct == 0){
+ outFile.println("data.setCell(" + Integer.toString(rowCt) + ",
0, \"" + literal + "\");");
+ outFile.println("data.setCell(" + Integer.toString(rowCt) + ",
1, \"" + location + "\");");
+ rowCt++;
+ ct++;
+ }
+ }
+ }
+
+ outFile.println(" var table = new
google.visualization.Table(document.getElementById('table_div'));");
+ outFile.println(" table.draw(data, {showRowNumber: true});");
+ outFile.println("}");
+ outFile.println(" </script>");
+ outFile.println(" </head>");
+ outFile.println("<body>");
+ outFile.println(" <div id=\"table_div\"></div>");
+ outFile.println(" </body>");
+ outFile.println("</html>");
+
+ outFile.close();
+
+ }
+
public void createHtmlFile(String fileName) throws IOException{
final PrintWriter outFile = new PrintWriter(fileName);
@@ -88,7 +141,7 @@
escaped = escaped.replaceAll("\\<", "<");
escaped = escaped.replaceAll("\\>", ">");
escaped = escaped.replaceAll("\\\"", """);
- escaped = escaped.replaceAll("\\'", "'");
+ //escaped = escaped.replaceAll("\\'", "'");
return escaped;
}
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---