return theme;
}
+ /**
+ * Used to reload host page on theme changes.
+ */
+ private static native void reloadHostPage()
+ /*-{
+ $wnd.location.reload();
+ }-*/;
+
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
id = uidl.getId();
- // Some attributes to note
- theme = uidl.getStringAttribute("theme");
+ String newTheme = uidl.getStringAttribute("theme");
+ if (theme != null && !newTheme.equals(theme)) {
+ // Complete page refresh is needed due css can affect layout
+ // calculations etc
+ reloadHostPage();
+ } else {
+ theme = newTheme;
+ }
if (uidl.hasAttribute("style")) {
addStyleName(uidl.getStringAttribute("style"));
}
--- /dev/null
+package com.itmill.toolkit.tests.tickets;\r
+\r
+import com.itmill.toolkit.ui.Button;\r
+import com.itmill.toolkit.ui.Label;\r
+import com.itmill.toolkit.ui.Panel;\r
+import com.itmill.toolkit.ui.Window;\r
+import com.itmill.toolkit.ui.Button.ClickEvent;\r
+import com.itmill.toolkit.ui.Button.ClickListener;\r
+\r
+public class Ticket1924ThemeChanging extends com.itmill.toolkit.Application {\r
+\r
+ private Label l = new Label("Background should be red with test theme");\r
+\r
+ private Panel p;\r
+\r
+ public void init() {\r
+ final Window main = new Window(getClass().getName().substring(\r
+ getClass().getName().lastIndexOf(".") + 1));\r
+ setMainWindow(main);\r
+\r
+ l.setStyleName("red");\r
+ main.addComponent(l);\r
+\r
+ Button b = new Button("Toggle tests-tickets theme");\r
+ b.addListener(new ClickListener() {\r
+ boolean flag = false;\r
+\r
+ public void buttonClick(ClickEvent event) {\r
+ if (flag = !flag) {\r
+ main.setTheme("tests-tickets");\r
+ } else {\r
+ main.setTheme(null);\r
+ }\r
+ }\r
+ });\r
+\r
+ main.addComponent(b);\r
+\r
+ b = new Button("Modify caption (should not reload page)");\r
+ b.addListener(new ClickListener() {\r
+ public void buttonClick(ClickEvent event) {\r
+ main.setCaption(main.getCaption() + ".");\r
+ }\r
+ });\r
+\r
+ main.addComponent(b);\r
+\r
+ }\r
+}
\ No newline at end of file