]> source.dussan.org Git - vaadin-framework.git/commitdiff
Test case and fix for #1924
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Thu, 10 Jul 2008 07:41:06 +0000 (07:41 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Thu, 10 Jul 2008 07:41:06 +0000 (07:41 +0000)
svn changeset:5076/svn branch:trunk

WebContent/ITMILL/themes/tests-tickets/styles.css
src/com/itmill/toolkit/terminal/gwt/client/ui/IView.java
src/com/itmill/toolkit/tests/tickets/Ticket1924ThemeChanging.java [new file with mode: 0644]
src/com/itmill/toolkit/ui/Window.java

index 4c8ea4a202240ba17434825e7c40712f7bb44633..dfc4dabf6e87f6b2c25f2d4df2a727eeea4d6ee0 100644 (file)
 .i-orderedlayout-red-background {
        background: red;
        }
+
+/*****************************************************************************/
+/* Ticket 1924                                                               */
+/*****************************************************************************/
+
+.i-label-red {
+       background: red;
+}
+       
\ No newline at end of file
index 530b2fa74998a5ae6f99a9295308a77bec446b52..13a41fc82edad42a33ed0d5729ac29c98ec476bf 100644 (file)
@@ -101,12 +101,26 @@ public class IView extends SimplePanel implements Paintable,
         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"));
         }
diff --git a/src/com/itmill/toolkit/tests/tickets/Ticket1924ThemeChanging.java b/src/com/itmill/toolkit/tests/tickets/Ticket1924ThemeChanging.java
new file mode 100644 (file)
index 0000000..33d0094
--- /dev/null
@@ -0,0 +1,49 @@
+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
index e486423b940a90db52ca6dd4d780199e8b085ed7..a69ac113cad1d3fcf4e804f9b59289220eabbeba 100644 (file)
@@ -432,6 +432,8 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
      * 
      * Setting theme for subwindows is not supported.
      * 
+     * In Toolkit 5 terminal will reload its host page on theme changes.
+     * 
      * @param theme
      *                the New theme for this window. Null implies the default
      *                theme.