]> source.dussan.org Git - vaadin-framework.git/commitdiff
concatenating css classnames instead of mangling dom many times
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Fri, 16 May 2008 16:55:47 +0000 (16:55 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Fri, 16 May 2008 16:55:47 +0000 (16:55 +0000)
svn changeset:4534/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java

index 330f8595c13058e07e38c124aa847d2f73ab7325..1e79ad8f86d477977c70cd35799c3811ee5ec8d8 100755 (executable)
@@ -753,21 +753,19 @@ public class ApplicationConnection {
 
         updateComponentSize(component, uidl);
 
-        // Styles + disabled & readonly
-        component.setStyleName(component.getStylePrimaryName());
-
-        // first disabling and read-only status
-        boolean enabled = true;
-        if (uidl.hasAttribute("disabled")) {
-            enabled = !uidl.getBooleanAttribute("disabled");
-        }
+        boolean enabled = !uidl.getBooleanAttribute("disabled");
         if (component instanceof FocusWidget) {
             ((FocusWidget) component).setEnabled(enabled);
         }
+
+        StringBuffer styleBuf = new StringBuffer();
+        String primaryName = component.getStylePrimaryName();
+        styleBuf.append(primaryName);
+
+        // first disabling and read-only status
         if (!enabled) {
-            component.addStyleName("i-disabled");
-        } else {
-            component.removeStyleName("i-disabled");
+            styleBuf.append(" ");
+            styleBuf.append("i-disabled");
         }
 
         // add additional styles as css classes, prefixed with component default
@@ -775,26 +773,31 @@ public class ApplicationConnection {
         if (uidl.hasAttribute("style")) {
             final String[] styles = uidl.getStringAttribute("style").split(" ");
             for (int i = 0; i < styles.length; i++) {
-                component.addStyleDependentName(styles[i]);
+                styleBuf.append(" ");
+                styleBuf.append(primaryName);
+                styleBuf.append("-");
+                styleBuf.append(styles[i]);
             }
         }
 
         // add modified classname to Fields
         if (component instanceof Field && uidl.hasAttribute("modified")) {
-            component.addStyleName(MODIFIED_CLASSNAME);
+            styleBuf.append(" ");
+            styleBuf.append(MODIFIED_CLASSNAME);
         }
         // add error classname to components w/ error
         if (uidl.hasAttribute("error")) {
-            component.addStyleName(ERROR_CLASSNAME);
+            styleBuf.append(" ");
+            styleBuf.append(ERROR_CLASSNAME);
         }
 
+        // Styles + disabled & readonly
+        component.setStyleName(styleBuf.toString());
+
         if (usePaintableIdsInDOM) {
             DOM.setElementProperty(component.getElement(), "id", uidl.getId());
         }
 
-        // TODO this should really build one string with all the classnames
-        // and setStyleName() once
-
         return false;
     }