3 import com
.google
.gwt
.core
.client
.GWT
;
4 import com
.google
.gwt
.dom
.client
.Document
;
5 import com
.google
.gwt
.dom
.client
.ScriptElement
;
6 import com
.google
.gwt
.resources
.client
.ClientBundle
;
7 import com
.google
.gwt
.resources
.client
.TextResource
;
10 * Methods for installing Dygraphs source in a GWT document.
12 * @author flooey@google.com (Adam Vartanian)
14 public class Dygraphs
{
16 // Protected because the GWT compiler has to generate a subclass.
17 protected interface Resources
extends ClientBundle
{
18 @Source("org/danvk/dygraph-combined.js")
19 TextResource
dygraphs();
22 private static final Resources RESOURCES
= GWT
.create(Resources
.class);
23 private static boolean installed
= false
;
26 * Install the Dygraphs JavaScript source into the current document. This
27 * method is idempotent.
29 public static synchronized void install() {
31 ScriptElement e
= Document
.get().createScriptElement();
32 e
.setText(RESOURCES
.dygraphs().getText());
33 Document
.get().getBody().appendChild(e
);
38 // Prevent construction
39 private Dygraphs() { }