From 171a5a7840cdb3fc38bea5a36c7c17951c74c27d Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Wed, 23 Apr 2008 09:09:53 +0000 Subject: [PATCH] ApplicationConnection now loads theme css svn changeset:4206/svn branch:trunk --- WebContent/reservr.html | 21 ++++++++++------ .../gwt/client/ApplicationConnection.java | 25 +++++++++++++++++++ .../gwt/server/ApplicationServlet.java | 17 ------------- 3 files changed, 38 insertions(+), 25 deletions(-) diff --git a/WebContent/reservr.html b/WebContent/reservr.html index 764d81869f..a08b689b3f 100644 --- a/WebContent/reservr.html +++ b/WebContent/reservr.html @@ -2,11 +2,6 @@ IT Mill Toolkit 5 Demo: Reservr - - - @@ -29,7 +22,19 @@ Representational cars on-the-road - + +
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java b/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java index 1b8f0f0b31..8a9380ff5a 100755 --- a/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java @@ -97,6 +97,10 @@ public class ApplicationConnection { this.widgetSet = widgetSet; configuration = cnf; + if (cnf.getThemeUri() != null) { + injectCss(cnf.getThemeUri() + "/styles.css"); + } + if (isDebugMode()) { console = new DebugConsole(this); } else { @@ -126,6 +130,27 @@ public class ApplicationConnection { applicationRunning = true; } + /** + * Injects CSS to head element + * + * TODO since gwt 1.5 this can be made non-native + * + * @param css + */ + private native static void injectCss(String cssUri) + /*-{ + + if(!$wnd.itmill.themesLoaded[cssUri]) { + var stylesheet = $doc.createElement('link'); + stylesheet.setAttribute('rel', 'stylesheet'); + stylesheet.setAttribute('type', 'text/css'); + stylesheet.setAttribute('href', cssUri); + var h = $doc.getElementsByTagName("head")[0]; + h.appendChild(stylesheet); + $wnd.itmill.themesLoaded[cssUri] = true; + } + }-*/; + /** * Method to check if application is in testing mode. Can be used after * application init. diff --git a/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java b/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java index f1cfcd90ef..af972ca82c 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java @@ -798,23 +798,6 @@ public class ApplicationServlet extends HttpServlet { } page.write("};\n//]]>\n\n"); - if (themeName != null) { - // Custom theme's stylesheet, load only once, in different script - // tag to be dominate styles injected by widget - // set - page.write("\n"); - } - page.write("
\n"); if (!fragment) { -- 2.39.5