aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2014-07-30 07:53:28 +0000
committerHenri Sara <hesara@vaadin.com>2014-08-04 08:27:00 +0000
commit422c08c6145b8c8eaff4f453b5c0276beef27290 (patch)
tree4b21fae0fc435442c2d052ae76298b0fb33e3b43 /server
parent99118ccf946486e140cd1a85ff75f2a6c09f4266 (diff)
downloadvaadin-framework-422c08c6145b8c8eaff4f453b5c0276beef27290.tar.gz
vaadin-framework-422c08c6145b8c8eaff4f453b5c0276beef27290.zip
Allow changing theme on the fly (#2874, #14139, #14124)
* Updates UI and overlay container class names when the theme changes * Initially verifies that the theme has actually been loaded (for the embed case) and class names have been properly set * Forces a state change to all components to re-translate theme:// URLs * Runs a full layout after the new theme has been loaded and activated Change-Id: I5a7391abe1bb467130bbb4660e4829b43f3e4255
Diffstat (limited to 'server')
-rw-r--r--server/src/com/vaadin/ui/UI.java27
1 files changed, 22 insertions, 5 deletions
diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java
index a72cbe5c30..5abeea9480 100644
--- a/server/src/com/vaadin/ui/UI.java
+++ b/server/src/com/vaadin/ui/UI.java
@@ -549,8 +549,6 @@ public abstract class UI extends AbstractSingleComponentContainer implements
private boolean resizeLazy = false;
- private String theme;
-
private Navigator navigator;
private PushConnection pushConnection = null;
@@ -633,7 +631,7 @@ public abstract class UI extends AbstractSingleComponentContainer implements
this.embedId = embedId;
// Actual theme - used for finding CustomLayout templates
- theme = request.getParameter("theme");
+ getState().theme = request.getParameter("theme");
getPage().init(request);
@@ -1135,12 +1133,31 @@ public abstract class UI extends AbstractSingleComponentContainer implements
}
/**
- * Gets the theme that was used when the UI was initialized.
+ * Gets the theme currently in use by this UI
*
* @return the theme name
*/
public String getTheme() {
- return theme;
+ return getState(false).theme;
+ }
+
+ /**
+ * Sets the theme currently in use by this UI
+ * <p>
+ * Calling this method will remove the old theme (CSS file) from the
+ * application and add the new theme.
+ * <p>
+ * Note that this method is NOT SAFE to call in a portal environment or
+ * other environment where there are multiple UIs on the same page. The old
+ * CSS file will be removed even if there are other UIs on the page which
+ * are still using it.
+ *
+ * @since 7.3
+ * @param theme
+ * The new theme name
+ */
+ public void setTheme(String theme) {
+ getState().theme = theme;
}
/**