]> source.dussan.org Git - vaadin-framework.git/commitdiff
Convert some literal strings of UIDL attributes to use constants.
authorHenri Sara <hesara@vaadin.com>
Tue, 21 Feb 2012 09:06:41 +0000 (11:06 +0200)
committerHenri Sara <hesara@vaadin.com>
Tue, 21 Feb 2012 09:06:41 +0000 (11:06 +0200)
36 files changed:
src/com/vaadin/terminal/gwt/client/VCaption.java
src/com/vaadin/terminal/gwt/client/ui/VAbstractPaintableWidget.java
src/com/vaadin/terminal/gwt/client/ui/VAbstractSplitPanelPaintable.java
src/com/vaadin/terminal/gwt/client/ui/VButtonPaintable.java
src/com/vaadin/terminal/gwt/client/ui/VCheckBoxPaintable.java
src/com/vaadin/terminal/gwt/client/ui/VDateFieldPaintable.java
src/com/vaadin/terminal/gwt/client/ui/VFilterSelectPaintable.java
src/com/vaadin/terminal/gwt/client/ui/VFormLayout.java
src/com/vaadin/terminal/gwt/client/ui/VFormPaintable.java
src/com/vaadin/terminal/gwt/client/ui/VLinkPaintable.java
src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java
src/com/vaadin/terminal/gwt/client/ui/VMenuBarPaintable.java
src/com/vaadin/terminal/gwt/client/ui/VNativeButtonPaintable.java
src/com/vaadin/terminal/gwt/client/ui/VOptionGroup.java
src/com/vaadin/terminal/gwt/client/ui/VOptionGroupBasePaintable.java
src/com/vaadin/terminal/gwt/client/ui/VPanel.java
src/com/vaadin/terminal/gwt/client/ui/VPanelPaintable.java
src/com/vaadin/terminal/gwt/client/ui/VPopupViewPaintable.java
src/com/vaadin/terminal/gwt/client/ui/VProgressIndicatorPaintable.java
src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java
src/com/vaadin/terminal/gwt/client/ui/VScrollTablePaintable.java
src/com/vaadin/terminal/gwt/client/ui/VSliderPaintable.java
src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java
src/com/vaadin/terminal/gwt/client/ui/VTabsheetBasePaintable.java
src/com/vaadin/terminal/gwt/client/ui/VTextFieldPaintable.java
src/com/vaadin/terminal/gwt/client/ui/VTreePaintable.java
src/com/vaadin/terminal/gwt/client/ui/VUploadPaintable.java
src/com/vaadin/terminal/gwt/client/ui/VViewPaintable.java
src/com/vaadin/terminal/gwt/client/ui/VWindowPaintable.java
src/com/vaadin/terminal/gwt/client/ui/richtextarea/VRichTextAreaPaintable.java
src/com/vaadin/ui/AbstractComponent.java
src/com/vaadin/ui/AbstractField.java
src/com/vaadin/ui/MenuBar.java
src/com/vaadin/ui/OptionGroup.java
src/com/vaadin/ui/Select.java
src/com/vaadin/ui/TabSheet.java

index f6d8ffe58e103704b9c9eb1044a71c6ea6e1cf6c..756fa71b6a4c71f904b24b48f8647991c709d15d 100644 (file)
@@ -9,6 +9,7 @@ import com.google.gwt.user.client.Element;
 import com.google.gwt.user.client.Event;
 import com.google.gwt.user.client.ui.HTML;
 import com.vaadin.terminal.gwt.client.ui.Icon;
+import com.vaadin.terminal.gwt.client.ui.VAbstractPaintableWidget;
 
 public class VCaption extends HTML {
 
@@ -32,13 +33,6 @@ public class VCaption extends HTML {
 
     private int maxWidth = -1;
 
-    protected static final String ATTRIBUTE_ICON = "icon";
-    protected static final String ATTRIBUTE_CAPTION = "caption";
-    protected static final String ATTRIBUTE_DESCRIPTION = "description";
-    protected static final String ATTRIBUTE_REQUIRED = "required";
-    protected static final String ATTRIBUTE_ERROR = "error";
-    protected static final String ATTRIBUTE_HIDEERRORS = "hideErrors";
-
     private static final String CLASSNAME_CLEAR = CLASSNAME + "-clearelem";
 
     /**
@@ -79,25 +73,31 @@ public class VCaption extends HTML {
         placedAfterComponent = true;
 
         String style = CLASSNAME;
-        if (uidl.hasAttribute("style")) {
-            final String[] styles = uidl.getStringAttribute("style").split(" ");
+        if (uidl.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_STYLE)) {
+            final String[] styles = uidl.getStringAttribute(
+                    VAbstractPaintableWidget.ATTRIBUTE_STYLE).split(" ");
             for (int i = 0; i < styles.length; i++) {
                 style += " " + CLASSNAME + "-" + styles[i];
             }
         }
 
-        if (uidl.hasAttribute("disabled")) {
+        if (uidl.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_DISABLED)) {
             style += " " + ApplicationConnection.DISABLED_CLASSNAME;
         }
 
         setStyleName(style);
 
-        boolean hasIcon = uidl.hasAttribute(ATTRIBUTE_ICON);
-        boolean hasText = uidl.hasAttribute(ATTRIBUTE_CAPTION);
-        boolean hasDescription = uidl.hasAttribute(ATTRIBUTE_DESCRIPTION);
-        boolean showRequired = uidl.getBooleanAttribute(ATTRIBUTE_REQUIRED);
-        boolean showError = uidl.hasAttribute(ATTRIBUTE_ERROR)
-                && !uidl.getBooleanAttribute(ATTRIBUTE_HIDEERRORS);
+        boolean hasIcon = uidl
+                .hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_ICON);
+        boolean hasText = uidl
+                .hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_CAPTION);
+        boolean hasDescription = uidl
+                .hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_DESCRIPTION);
+        boolean showRequired = uidl
+                .getBooleanAttribute(VAbstractPaintableWidget.ATTRIBUTE_REQUIRED);
+        boolean showError = uidl
+                .hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_ERROR)
+                && !uidl.getBooleanAttribute(VAbstractPaintableWidget.ATTRIBUTE_HIDEERRORS);
 
         if (hasIcon) {
             if (icon == null) {
@@ -105,13 +105,16 @@ public class VCaption extends HTML {
                 icon.setWidth("0");
                 icon.setHeight("0");
 
-                DOM.insertChild(getElement(), icon.getElement(),
-                        getInsertPosition(ATTRIBUTE_ICON));
+                DOM.insertChild(
+                        getElement(),
+                        icon.getElement(),
+                        getInsertPosition(VAbstractPaintableWidget.ATTRIBUTE_ICON));
             }
             // Icon forces the caption to be above the component
             placedAfterComponent = false;
 
-            icon.setUri(uidl.getStringAttribute(ATTRIBUTE_ICON));
+            icon.setUri(uidl
+                    .getStringAttribute(VAbstractPaintableWidget.ATTRIBUTE_ICON));
 
         } else if (icon != null) {
             // Remove existing
@@ -128,12 +131,15 @@ public class VCaption extends HTML {
                 captionText = DOM.createDiv();
                 captionText.setClassName("v-captiontext");
 
-                DOM.insertChild(getElement(), captionText,
-                        getInsertPosition(ATTRIBUTE_CAPTION));
+                DOM.insertChild(
+                        getElement(),
+                        captionText,
+                        getInsertPosition(VAbstractPaintableWidget.ATTRIBUTE_CAPTION));
             }
 
             // Update caption text
-            String c = uidl.getStringAttribute(ATTRIBUTE_CAPTION);
+            String c = uidl
+                    .getStringAttribute(VAbstractPaintableWidget.ATTRIBUTE_CAPTION);
             // A text forces the caption to be above the component.
             placedAfterComponent = false;
             if (c == null || c.trim().equals("")) {
@@ -171,8 +177,10 @@ public class VCaption extends HTML {
                         .setClassName("v-required-field-indicator");
                 DOM.setInnerText(requiredFieldIndicator, "*");
 
-                DOM.insertChild(getElement(), requiredFieldIndicator,
-                        getInsertPosition(ATTRIBUTE_REQUIRED));
+                DOM.insertChild(
+                        getElement(),
+                        requiredFieldIndicator,
+                        getInsertPosition(VAbstractPaintableWidget.ATTRIBUTE_REQUIRED));
             }
         } else if (requiredFieldIndicator != null) {
             // Remove existing
@@ -187,8 +195,10 @@ public class VCaption extends HTML {
                 DOM.setElementProperty(errorIndicatorElement, "className",
                         "v-errorindicator");
 
-                DOM.insertChild(getElement(), errorIndicatorElement,
-                        getInsertPosition(ATTRIBUTE_ERROR));
+                DOM.insertChild(
+                        getElement(),
+                        errorIndicatorElement,
+                        getInsertPosition(VAbstractPaintableWidget.ATTRIBUTE_ERROR));
             }
         } else if (errorIndicatorElement != null) {
             // Remove existing
@@ -207,14 +217,14 @@ public class VCaption extends HTML {
 
     private int getInsertPosition(String element) {
         int pos = 0;
-        if (element.equals(ATTRIBUTE_ICON)) {
+        if (element.equals(VAbstractPaintableWidget.ATTRIBUTE_ICON)) {
             return pos;
         }
         if (icon != null) {
             pos++;
         }
 
-        if (element.equals(ATTRIBUTE_CAPTION)) {
+        if (element.equals(VAbstractPaintableWidget.ATTRIBUTE_CAPTION)) {
             return pos;
         }
 
@@ -222,7 +232,7 @@ public class VCaption extends HTML {
             pos++;
         }
 
-        if (element.equals(ATTRIBUTE_REQUIRED)) {
+        if (element.equals(VAbstractPaintableWidget.ATTRIBUTE_REQUIRED)) {
             return pos;
         }
         if (requiredFieldIndicator != null) {
@@ -273,16 +283,16 @@ public class VCaption extends HTML {
     }
 
     public static boolean isNeeded(UIDL uidl) {
-        if (uidl.getStringAttribute(ATTRIBUTE_CAPTION) != null) {
+        if (uidl.getStringAttribute(VAbstractPaintableWidget.ATTRIBUTE_CAPTION) != null) {
             return true;
         }
-        if (uidl.hasAttribute(ATTRIBUTE_ERROR)) {
+        if (uidl.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_ERROR)) {
             return true;
         }
-        if (uidl.hasAttribute(ATTRIBUTE_ICON)) {
+        if (uidl.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_ICON)) {
             return true;
         }
-        if (uidl.hasAttribute(ATTRIBUTE_REQUIRED)) {
+        if (uidl.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_REQUIRED)) {
             return true;
         }
 
index 3d186d2759f9b6419b5527f32169c2f668188a87..2c948dfba8022c6bd25f710f47070a6d2fb5f111 100644 (file)
@@ -17,8 +17,23 @@ import com.vaadin.terminal.gwt.client.communication.SharedState;
 
 public abstract class VAbstractPaintableWidget implements VPaintableWidget {
 
+    // Generic UIDL parameter names, to be moved to shared state.
+    // Attributes are here mainly if they apply to all paintable widgets or
+    // affect captions - otherwise, they are in the relevant subclasses.
+    // For e.g. item or context specific attributes, subclasses may use separate
+    // constants, which may refer to these.
+    // Not all references to the string literals have been converted to use
+    // these!
+    public static final String ATTRIBUTE_ICON = "icon";
+    public static final String ATTRIBUTE_CAPTION = "caption";
     public static final String ATTRIBUTE_DESCRIPTION = "description";
+    public static final String ATTRIBUTE_REQUIRED = "required";
     public static final String ATTRIBUTE_ERROR = "error";
+    public static final String ATTRIBUTE_HIDEERRORS = "hideErrors";
+    public static final String ATTRIBUTE_READONLY = "readonly";
+    public static final String ATTRIBUTE_IMMEDIATE = "immediate";
+    public static final String ATTRIBUTE_DISABLED = "disabled";
+    public static final String ATTRIBUTE_STYLE = "style";
 
     private Widget widget;
     private ApplicationConnection connection;
@@ -164,7 +179,7 @@ public abstract class VAbstractPaintableWidget implements VPaintableWidget {
             ((Focusable) getWidgetForPaintable()).setTabIndex(uidl
                     .getIntAttribute("tabindex"));
         }
-        setEnabled(!uidl.getBooleanAttribute("disabled"));
+        setEnabled(!uidl.getBooleanAttribute(ATTRIBUTE_DISABLED));
 
         // Style names
         String styleName = getStyleNameFromUIDL(getWidgetForPaintable()
@@ -276,7 +291,7 @@ public abstract class VAbstractPaintableWidget implements VPaintableWidget {
      */
     protected static String getStyleNameFromUIDL(String primaryStyleName,
             UIDL uidl, boolean field) {
-        boolean enabled = !uidl.getBooleanAttribute("disabled");
+        boolean enabled = !uidl.getBooleanAttribute(ATTRIBUTE_DISABLED);
 
         StringBuffer styleBuf = new StringBuffer();
         styleBuf.append(primaryStyleName);
@@ -286,15 +301,16 @@ public abstract class VAbstractPaintableWidget implements VPaintableWidget {
             styleBuf.append(" ");
             styleBuf.append(ApplicationConnection.DISABLED_CLASSNAME);
         }
-        if (uidl.getBooleanAttribute("readonly")) {
+        if (uidl.getBooleanAttribute(ATTRIBUTE_READONLY)) {
             styleBuf.append(" ");
             styleBuf.append("v-readonly");
         }
 
         // add additional styles as css classes, prefixed with component default
         // stylename
-        if (uidl.hasAttribute("style")) {
-            final String[] styles = uidl.getStringAttribute("style").split(" ");
+        if (uidl.hasAttribute(ATTRIBUTE_STYLE)) {
+            final String[] styles = uidl.getStringAttribute(ATTRIBUTE_STYLE)
+                    .split(" ");
             for (int i = 0; i < styles.length; i++) {
                 styleBuf.append(" ");
                 styleBuf.append(primaryStyleName);
@@ -318,7 +334,7 @@ public abstract class VAbstractPaintableWidget implements VPaintableWidget {
             styleBuf.append(ApplicationConnection.ERROR_CLASSNAME_EXT);
         }
         // add required style to required components
-        if (uidl.hasAttribute("required")) {
+        if (uidl.hasAttribute(ATTRIBUTE_REQUIRED)) {
             styleBuf.append(" ");
             styleBuf.append(primaryStyleName);
             styleBuf.append(ApplicationConnection.REQUIRED_CLASSNAME_EXT);
index ccf3119d132cc3fe2e6b9468184530498fc996ce..8d4a6954a16f6fc55fa7ed803cd71ad12478988a 100644 (file)
@@ -70,7 +70,8 @@ public abstract class VAbstractSplitPanelPaintable extends
         getWidgetForPaintable().id = uidl.getId();
         getWidgetForPaintable().rendering = true;
 
-        getWidgetForPaintable().immediate = uidl.hasAttribute("immediate");
+        getWidgetForPaintable().immediate = uidl
+                .hasAttribute(ATTRIBUTE_IMMEDIATE);
 
         super.updateFromUIDL(uidl, client);
         if (!isRealUpdate(uidl)) {
@@ -78,12 +79,12 @@ public abstract class VAbstractSplitPanelPaintable extends
             return;
         }
         getWidgetForPaintable().setEnabled(
-                !uidl.getBooleanAttribute("disabled"));
+                !uidl.getBooleanAttribute(ATTRIBUTE_DISABLED));
 
         clickEventHandler.handleEventHandlerRegistration(client);
-        if (uidl.hasAttribute("style")) {
+        if (uidl.hasAttribute(ATTRIBUTE_STYLE)) {
             getWidgetForPaintable().componentStyleNames = uidl
-                    .getStringAttribute("style").split(" ");
+                    .getStringAttribute(ATTRIBUTE_STYLE).split(" ");
         } else {
             getWidgetForPaintable().componentStyleNames = new String[0];
         }
index 9d60e21c827dfb0fb7586dc711f73f77feffebab..ea227b1854eca23318afff6c04832fcfb3438afb 100644 (file)
@@ -40,7 +40,8 @@ public class VButtonPaintable extends VAbstractPaintableWidget {
         getWidgetForPaintable().paintableId = uidl.getId();
 
         // Set text
-        getWidgetForPaintable().setText(uidl.getStringAttribute("caption"));
+        getWidgetForPaintable().setText(
+                uidl.getStringAttribute(ATTRIBUTE_CAPTION));
 
         getWidgetForPaintable().disableOnClick = uidl
                 .hasAttribute(VButton.ATTR_DISABLE_ON_CLICK);
@@ -63,15 +64,15 @@ public class VButtonPaintable extends VAbstractPaintableWidget {
             getWidgetForPaintable().errorIndicatorElement = null;
         }
 
-        if (uidl.hasAttribute("icon")) {
+        if (uidl.hasAttribute(ATTRIBUTE_ICON)) {
             if (getWidgetForPaintable().icon == null) {
                 getWidgetForPaintable().icon = new Icon(client);
                 getWidgetForPaintable().wrapper.insertBefore(
                         getWidgetForPaintable().icon.getElement(),
                         getWidgetForPaintable().captionElement);
             }
-            getWidgetForPaintable().icon
-                    .setUri(uidl.getStringAttribute("icon"));
+            getWidgetForPaintable().icon.setUri(uidl
+                    .getStringAttribute(ATTRIBUTE_ICON));
         } else {
             if (getWidgetForPaintable().icon != null) {
                 getWidgetForPaintable().wrapper
index acbb620361f3502314c7b179afeda736780ddf2f..daacbe03e5de1f36bd80890bddbd6c84550c6da1 100644 (file)
@@ -62,11 +62,11 @@ public class VCheckBoxPaintable extends VAbstractPaintableWidget {
                     "none");
         }
 
-        if (uidl.hasAttribute("readonly")) {
+        if (uidl.hasAttribute(ATTRIBUTE_READONLY)) {
             getWidgetForPaintable().setEnabled(false);
         }
 
-        if (uidl.hasAttribute("icon")) {
+        if (uidl.hasAttribute(ATTRIBUTE_ICON)) {
             if (getWidgetForPaintable().icon == null) {
                 getWidgetForPaintable().icon = new Icon(client);
                 DOM.insertChild(getWidgetForPaintable().getElement(),
@@ -75,8 +75,8 @@ public class VCheckBoxPaintable extends VAbstractPaintableWidget {
                         .sinkEvents(VTooltip.TOOLTIP_EVENTS);
                 getWidgetForPaintable().icon.sinkEvents(Event.ONCLICK);
             }
-            getWidgetForPaintable().icon
-                    .setUri(uidl.getStringAttribute("icon"));
+            getWidgetForPaintable().icon.setUri(uidl
+                    .getStringAttribute(ATTRIBUTE_ICON));
         } else if (getWidgetForPaintable().icon != null) {
             // detach icon
             DOM.removeChild(getWidgetForPaintable().getElement(),
@@ -85,12 +85,13 @@ public class VCheckBoxPaintable extends VAbstractPaintableWidget {
         }
 
         // Set text
-        getWidgetForPaintable().setText(uidl.getStringAttribute("caption"));
+        getWidgetForPaintable().setText(
+                uidl.getStringAttribute(ATTRIBUTE_CAPTION));
         getWidgetForPaintable()
                 .setValue(
                         uidl.getBooleanVariable(getWidgetForPaintable().VARIABLE_STATE));
         getWidgetForPaintable().immediate = uidl
-                .getBooleanAttribute("immediate");
+                .getBooleanAttribute(VAbstractPaintableWidget.ATTRIBUTE_IMMEDIATE);
     }
 
     @Override
index c11ef6f54f5dff853318a174e1a2293700cd60cd..0798cd1e60150aec8b6ea512b42eb9e0c355c980 100644 (file)
@@ -26,10 +26,12 @@ public class VDateFieldPaintable extends VAbstractPaintableWidget {
         getWidgetForPaintable().client = client;
         getWidgetForPaintable().paintableId = uidl.getId();
         getWidgetForPaintable().immediate = uidl
-                .getBooleanAttribute("immediate");
+                .getBooleanAttribute(ATTRIBUTE_IMMEDIATE);
 
-        getWidgetForPaintable().readonly = uidl.getBooleanAttribute("readonly");
-        getWidgetForPaintable().enabled = !uidl.getBooleanAttribute("disabled");
+        getWidgetForPaintable().readonly = uidl
+                .getBooleanAttribute(ATTRIBUTE_READONLY);
+        getWidgetForPaintable().enabled = !uidl
+                .getBooleanAttribute(ATTRIBUTE_DISABLED);
 
         if (uidl.hasAttribute("locale")) {
             final String locale = uidl.getStringAttribute("locale");
index eaf9eec16a2c12644cc665bd2a4fffa1579088e7..cd1c4e122dbf5b199757ce1cd9a0f1217903f19c 100644 (file)
@@ -28,8 +28,10 @@ public class VFilterSelectPaintable extends VAbstractPaintableWidget {
         getWidgetForPaintable().client = client;
         getWidgetForPaintable().paintableId = uidl.getId();
 
-        getWidgetForPaintable().readonly = uidl.hasAttribute("readonly");
-        getWidgetForPaintable().enabled = !uidl.hasAttribute("disabled");
+        getWidgetForPaintable().readonly = uidl
+                .hasAttribute(ATTRIBUTE_READONLY);
+        getWidgetForPaintable().enabled = !uidl
+                .hasAttribute(ATTRIBUTE_DISABLED);
 
         getWidgetForPaintable().tb.setEnabled(getWidgetForPaintable().enabled);
         getWidgetForPaintable().updateReadOnly();
@@ -57,7 +59,8 @@ public class VFilterSelectPaintable extends VAbstractPaintableWidget {
                     .getIntAttribute("filteringmode");
         }
 
-        getWidgetForPaintable().immediate = uidl.hasAttribute("immediate");
+        getWidgetForPaintable().immediate = uidl
+                .hasAttribute(ATTRIBUTE_IMMEDIATE);
 
         getWidgetForPaintable().nullSelectionAllowed = uidl
                 .hasAttribute("nullselect");
index 6d3072f40778e800a133014bc780d02701b2bb64..3e5600e4e6836a691eb8f986e9faf22a821b83fe 100644 (file)
@@ -62,14 +62,15 @@ public class VFormLayout extends SimplePanel implements Container {
      */
     private String[] getStylesFromUIDL(UIDL uidl) {
         List<String> styles = new ArrayList<String>();
-        if (uidl.hasAttribute("style")) {
-            String[] stylesnames = uidl.getStringAttribute("style").split(" ");
+        if (uidl.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_STYLE)) {
+            String[] stylesnames = uidl.getStringAttribute(
+                    VAbstractPaintableWidget.ATTRIBUTE_STYLE).split(" ");
             for (String name : stylesnames) {
                 styles.add(name);
             }
         }
 
-        if (uidl.hasAttribute("disabled")) {
+        if (uidl.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_DISABLED)) {
             styles.add(ApplicationConnection.DISABLED_CLASSNAME);
         }
 
@@ -346,13 +347,14 @@ public class VFormLayout extends SimplePanel implements Container {
 
             boolean isEmpty = true;
 
-            if (uidl.hasAttribute("icon")) {
+            if (uidl.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_ICON)) {
                 if (icon == null) {
                     icon = new Icon(client);
 
                     DOM.insertChild(getElement(), icon.getElement(), 0);
                 }
-                icon.setUri(uidl.getStringAttribute("icon"));
+                icon.setUri(uidl
+                        .getStringAttribute(VAbstractPaintableWidget.ATTRIBUTE_ICON));
                 isEmpty = false;
             } else {
                 if (icon != null) {
@@ -362,13 +364,14 @@ public class VFormLayout extends SimplePanel implements Container {
 
             }
 
-            if (uidl.hasAttribute("caption")) {
+            if (uidl.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_CAPTION)) {
                 if (captionText == null) {
                     captionText = DOM.createSpan();
                     DOM.insertChild(getElement(), captionText, icon == null ? 0
                             : 1);
                 }
-                String c = uidl.getStringAttribute("caption");
+                String c = uidl
+                        .getStringAttribute(VAbstractPaintableWidget.ATTRIBUTE_CAPTION);
                 if (c == null) {
                     c = "";
                 } else {
@@ -379,7 +382,7 @@ public class VFormLayout extends SimplePanel implements Container {
                 // TODO should span also be removed
             }
 
-            if (uidl.hasAttribute("description")) {
+            if (uidl.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_DESCRIPTION)) {
                 if (captionText != null) {
                     addStyleDependentName("hasdescription");
                 } else {
@@ -387,7 +390,7 @@ public class VFormLayout extends SimplePanel implements Container {
                 }
             }
 
-            if (uidl.getBooleanAttribute("required")) {
+            if (uidl.getBooleanAttribute(VAbstractPaintableWidget.ATTRIBUTE_REQUIRED)) {
                 if (requiredFieldIndicator == null) {
                     requiredFieldIndicator = DOM.createSpan();
                     DOM.setInnerText(requiredFieldIndicator, "*");
@@ -451,7 +454,7 @@ public class VFormLayout extends SimplePanel implements Container {
         public void updateFromUIDL(UIDL uidl, VPaintableWidget component) {
             owner = component;
             if (uidl.hasAttribute("error")
-                    && !uidl.getBooleanAttribute("hideErrors")) {
+                    && !uidl.getBooleanAttribute(VAbstractPaintableWidget.ATTRIBUTE_HIDEERRORS)) {
                 if (errorIndicatorElement == null) {
                     errorIndicatorElement = DOM.createDiv();
                     DOM.setInnerHTML(errorIndicatorElement, "&nbsp;");
index a15a5b78374003e5226edd6263e6725a23d8afbd..eb0a91fb04928e12605ec05911428560c1e6b4f8 100644 (file)
@@ -31,21 +31,21 @@ public class VFormPaintable extends VAbstractPaintableWidgetContainer {
         }
 
         boolean legendEmpty = true;
-        if (uidl.hasAttribute("caption")) {
+        if (uidl.hasAttribute(ATTRIBUTE_CAPTION)) {
             getWidgetForPaintable().caption.setInnerText(uidl
-                    .getStringAttribute("caption"));
+                    .getStringAttribute(ATTRIBUTE_CAPTION));
             legendEmpty = false;
         } else {
             getWidgetForPaintable().caption.setInnerText("");
         }
-        if (uidl.hasAttribute("icon")) {
+        if (uidl.hasAttribute(ATTRIBUTE_ICON)) {
             if (getWidgetForPaintable().icon == null) {
                 getWidgetForPaintable().icon = new Icon(client);
                 getWidgetForPaintable().legend
                         .insertFirst(getWidgetForPaintable().icon.getElement());
             }
-            getWidgetForPaintable().icon
-                    .setUri(uidl.getStringAttribute("icon"));
+            getWidgetForPaintable().icon.setUri(uidl
+                    .getStringAttribute(ATTRIBUTE_ICON));
             legendEmpty = false;
         } else {
             if (getWidgetForPaintable().icon != null) {
@@ -67,9 +67,9 @@ public class VFormPaintable extends VAbstractPaintableWidgetContainer {
             getWidgetForPaintable().errorMessage.setVisible(false);
         }
 
-        if (uidl.hasAttribute("description")) {
+        if (uidl.hasAttribute(ATTRIBUTE_DESCRIPTION)) {
             getWidgetForPaintable().desc.setInnerHTML(uidl
-                    .getStringAttribute("description"));
+                    .getStringAttribute(ATTRIBUTE_DESCRIPTION));
             if (getWidgetForPaintable().desc.getParentElement() == null) {
                 getWidgetForPaintable().fieldSet.insertAfter(
                         getWidgetForPaintable().desc,
index 6980baa61d5ca66b2a0c433a231de362c35608cf..432365eaa7e7ca122bbbe81b9534bbb1a750eb68 100644 (file)
@@ -29,10 +29,10 @@ public class VLinkPaintable extends VAbstractPaintableWidget {
 
         getWidgetForPaintable().client = client;
 
-        getWidgetForPaintable().enabled = uidl.hasAttribute("disabled") ? false
+        getWidgetForPaintable().enabled = uidl.hasAttribute(ATTRIBUTE_DISABLED) ? false
                 : true;
-        getWidgetForPaintable().readonly = uidl.hasAttribute("readonly") ? true
-                : false;
+        getWidgetForPaintable().readonly = uidl
+                .hasAttribute(ATTRIBUTE_READONLY) ? true : false;
 
         if (uidl.hasAttribute("name")) {
             getWidgetForPaintable().target = uidl.getStringAttribute("name");
@@ -64,7 +64,7 @@ public class VLinkPaintable extends VAbstractPaintableWidget {
 
         // Set link caption
         getWidgetForPaintable().captionElement.setInnerText(uidl
-                .getStringAttribute("caption"));
+                .getStringAttribute(ATTRIBUTE_CAPTION));
 
         // handle error
         if (uidl.hasAttribute("error")) {
@@ -82,15 +82,15 @@ public class VLinkPaintable extends VAbstractPaintableWidget {
                     "none");
         }
 
-        if (uidl.hasAttribute("icon")) {
+        if (uidl.hasAttribute(ATTRIBUTE_ICON)) {
             if (getWidgetForPaintable().icon == null) {
                 getWidgetForPaintable().icon = new Icon(client);
                 getWidgetForPaintable().anchor.insertBefore(
                         getWidgetForPaintable().icon.getElement(),
                         getWidgetForPaintable().captionElement);
             }
-            getWidgetForPaintable().icon
-                    .setUri(uidl.getStringAttribute("icon"));
+            getWidgetForPaintable().icon.setUri(uidl
+                    .getStringAttribute(ATTRIBUTE_ICON));
         }
 
     }
index c39155d032f8f5a76cc5a91d5d28bc57a3e79053..3bd90e17e697da4b425632a8aa607d8721d6d9a7 100644 (file)
@@ -65,6 +65,9 @@ public class VMenuBar extends SimpleFocusablePanel implements
     public static final String OPEN_ROOT_MENU_ON_HOWER = "ormoh";
 
     public static final String ATTRIBUTE_CHECKED = "checked";
+    public static final String ATTRIBUTE_ITEM_DESCRIPTION = VAbstractPaintableWidget.ATTRIBUTE_DESCRIPTION;
+    public static final String ATTRIBUTE_ITEM_ICON = VAbstractPaintableWidget.ATTRIBUTE_ICON;
+    public static final String ATTRIBUTE_ITEM_DISABLED = VAbstractPaintableWidget.ATTRIBUTE_DISABLED;
 
     public static final String HTML_CONTENT_ALLOWED = "usehtml";
 
@@ -899,7 +902,7 @@ public class VMenuBar extends SimpleFocusablePanel implements
         public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
             this.client = client;
             setSeparator(uidl.hasAttribute("separator"));
-            setEnabled(!uidl.hasAttribute("disabled"));
+            setEnabled(!uidl.hasAttribute(ATTRIBUTE_ITEM_DISABLED));
 
             if (!isSeparator() && uidl.hasAttribute(ATTRIBUTE_CHECKED)) {
                 // if the selected attribute is present (either true or false),
@@ -915,8 +918,9 @@ public class VMenuBar extends SimpleFocusablePanel implements
                 addStyleDependentName(itemStyle);
             }
 
-            if (uidl.hasAttribute("description")) {
-                String description = uidl.getStringAttribute("description");
+            if (uidl.hasAttribute(ATTRIBUTE_ITEM_DESCRIPTION)) {
+                String description = uidl
+                        .getStringAttribute(ATTRIBUTE_ITEM_DESCRIPTION);
                 TooltipInfo info = new TooltipInfo(description);
 
                 VMenuBar root = findRootMenu();
index 4b2fdff819690ca4f867cd5cab8e9a22d740261c..246986f174db876268f2d9d6551dea0cb0f333d5 100644 (file)
@@ -38,7 +38,8 @@ public class VMenuBarPaintable extends VAbstractPaintableWidget {
         getWidgetForPaintable().openRootOnHover = uidl
                 .getBooleanAttribute(VMenuBar.OPEN_ROOT_MENU_ON_HOWER);
 
-        getWidgetForPaintable().enabled = !uidl.getBooleanAttribute("disabled");
+        getWidgetForPaintable().enabled = !uidl
+                .getBooleanAttribute(ATTRIBUTE_DISABLED);
 
         // For future connections
         getWidgetForPaintable().client = client;
index b34a9d1335863425eaa602f1f4ba6d94507b5a7f..4257597e2dbbea8e3177dd3b0a95be3b9eb4c27b 100644 (file)
@@ -42,7 +42,8 @@ public class VNativeButtonPaintable extends VAbstractPaintableWidget {
         getWidgetForPaintable().paintableId = uidl.getId();
 
         // Set text
-        getWidgetForPaintable().setText(uidl.getStringAttribute("caption"));
+        getWidgetForPaintable().setText(
+                uidl.getStringAttribute(ATTRIBUTE_CAPTION));
 
         // handle error
         if (uidl.hasAttribute("error")) {
@@ -62,15 +63,15 @@ public class VNativeButtonPaintable extends VAbstractPaintableWidget {
             getWidgetForPaintable().errorIndicatorElement = null;
         }
 
-        if (uidl.hasAttribute("icon")) {
+        if (uidl.hasAttribute(ATTRIBUTE_ICON)) {
             if (getWidgetForPaintable().icon == null) {
                 getWidgetForPaintable().icon = new Icon(client);
                 getWidgetForPaintable().getElement().insertBefore(
                         getWidgetForPaintable().icon.getElement(),
                         getWidgetForPaintable().captionElement);
             }
-            getWidgetForPaintable().icon
-                    .setUri(uidl.getStringAttribute("icon"));
+            getWidgetForPaintable().icon.setUri(uidl
+                    .getStringAttribute(ATTRIBUTE_ICON));
         } else {
             if (getWidgetForPaintable().icon != null) {
                 getWidgetForPaintable().getElement().removeChild(
index bf89a01a03a537447b7a3a74ebce23ca9dd0fde3..413c5a40d097f74a7be95d455b4e65a5b93b1755 100644 (file)
@@ -37,6 +37,8 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler,
 
     public static final String CLASSNAME = "v-select-optiongroup";
 
+    public static final String ATTRIBUTE_OPTION_DISABLED = VAbstractPaintableWidget.ATTRIBUTE_DISABLED;
+
     protected final Panel panel;
 
     private final Map<CheckBox, String> optionsToKeys;
@@ -106,7 +108,8 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler,
 
             op.addStyleName(CLASSNAME_OPTION);
             op.setValue(opUidl.getBooleanAttribute("selected"));
-            boolean enabled = !opUidl.getBooleanAttribute("disabled")
+            boolean enabled = !opUidl
+                    .getBooleanAttribute(ATTRIBUTE_OPTION_DISABLED)
                     && !isReadonly() && !isDisabled();
             op.setEnabled(enabled);
             setStyleName(op.getElement(),
index b0fbda08753fc82ad52a2e1ca856e59774a1440f..2fc538d114c995c2c7ec2266d3772f0f8722d4fe 100644 (file)
@@ -25,12 +25,14 @@ public abstract class VOptionGroupBasePaintable extends
         getWidgetForPaintable().selectedKeys = uidl
                 .getStringArrayVariableAsSet("selected");
 
-        getWidgetForPaintable().readonly = uidl.getBooleanAttribute("readonly");
-        getWidgetForPaintable().disabled = uidl.getBooleanAttribute("disabled");
+        getWidgetForPaintable().readonly = uidl
+                .getBooleanAttribute(ATTRIBUTE_READONLY);
+        getWidgetForPaintable().disabled = uidl
+                .getBooleanAttribute(ATTRIBUTE_DISABLED);
         getWidgetForPaintable().multiselect = "multi".equals(uidl
                 .getStringAttribute("selectmode"));
         getWidgetForPaintable().immediate = uidl
-                .getBooleanAttribute("immediate");
+                .getBooleanAttribute(ATTRIBUTE_IMMEDIATE);
         getWidgetForPaintable().nullSelectionAllowed = uidl
                 .getBooleanAttribute("nullselect");
         getWidgetForPaintable().nullSelectionItemAvailable = uidl
index 82b362a385dbdcef29c563d3d9100034b3de2a29..b1b3ff27ff51ac97c3dc183bf768320530275178 100644 (file)
@@ -174,8 +174,10 @@ public class VPanel extends SimplePanel implements Container,
     }
 
     void setIconUri(UIDL uidl, ApplicationConnection client) {
-        final String iconUri = uidl.hasAttribute("icon") ? uidl
-                .getStringAttribute("icon") : null;
+        final String iconUri = uidl
+                .hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_ICON) ? uidl
+                .getStringAttribute(VAbstractPaintableWidget.ATTRIBUTE_ICON)
+                : null;
         if (iconUri == null) {
             if (icon != null) {
                 DOM.removeChild(captionNode, icon.getElement());
index 9c34a68528e05dd5d6e70656c08ab3492e3df377..ce1c1f24820d99160755f0cce3c2aac3b70ead52 100644 (file)
@@ -47,10 +47,10 @@ public class VPanelPaintable extends VAbstractPaintableWidgetContainer {
             getWidgetForPaintable().captionNode.setClassName(VPanel.CLASSNAME
                     + "-caption");
             boolean hasCaption = false;
-            if (uidl.hasAttribute("caption")
-                    && !uidl.getStringAttribute("caption").equals("")) {
+            if (uidl.hasAttribute(ATTRIBUTE_CAPTION)
+                    && !uidl.getStringAttribute(ATTRIBUTE_CAPTION).equals("")) {
                 getWidgetForPaintable().setCaption(
-                        uidl.getStringAttribute("caption"));
+                        uidl.getStringAttribute(ATTRIBUTE_CAPTION));
                 hasCaption = true;
             } else {
                 getWidgetForPaintable().setCaption("");
@@ -60,9 +60,9 @@ public class VPanelPaintable extends VAbstractPaintableWidgetContainer {
 
             // Add proper stylenames for all elements. This way we can prevent
             // unwanted CSS selector inheritance.
-            if (uidl.hasAttribute("style")) {
-                final String[] styles = uidl.getStringAttribute("style").split(
-                        " ");
+            if (uidl.hasAttribute(ATTRIBUTE_STYLE)) {
+                final String[] styles = uidl
+                        .getStringAttribute(ATTRIBUTE_STYLE).split(" ");
                 final String captionBaseClass = VPanel.CLASSNAME
                         + (hasCaption ? "-caption" : "-nocaption");
                 final String contentBaseClass = VPanel.CLASSNAME + "-content";
index 11896f7087137fb3b3d76e26dbab83dbd6136088..366e49cd75d230d6402ad3a49e29e580bf343ca8 100644 (file)
@@ -53,9 +53,9 @@ public class VPopupViewPaintable extends VAbstractPaintableWidgetContainer {
             // showPopupOnTop(popup, hostReference);
             getWidgetForPaintable().preparePopup(getWidgetForPaintable().popup);
             getWidgetForPaintable().popup.updateFromUIDL(popupUIDL, client);
-            if (uidl.hasAttribute("style")) {
-                final String[] styles = uidl.getStringAttribute("style").split(
-                        " ");
+            if (uidl.hasAttribute(ATTRIBUTE_STYLE)) {
+                final String[] styles = uidl
+                        .getStringAttribute(ATTRIBUTE_STYLE).split(" ");
                 final StringBuffer styleBuf = new StringBuffer();
                 final String primaryName = getWidgetForPaintable().popup
                         .getStylePrimaryName();
index 0d7c1624f488ecefdd7f50a832f14a3c01191640..d91705abe971df81a1db96a1be09954fcb9d0751 100644 (file)
@@ -31,7 +31,7 @@ public class VProgressIndicatorPaintable extends VAbstractPaintableWidget {
         if (getWidgetForPaintable().indeterminate) {
             String basename = VProgressIndicator.CLASSNAME + "-indeterminate";
             getWidgetForPaintable().addStyleName(basename);
-            if (uidl.getBooleanAttribute("disabled")) {
+            if (uidl.getBooleanAttribute(ATTRIBUTE_DISABLED)) {
                 getWidgetForPaintable().addStyleName(basename + "-disabled");
             } else {
                 getWidgetForPaintable().removeStyleName(basename + "-disabled");
@@ -47,7 +47,7 @@ public class VProgressIndicatorPaintable extends VAbstractPaintableWidget {
             }
         }
 
-        if (!uidl.getBooleanAttribute("disabled")) {
+        if (!uidl.getBooleanAttribute(ATTRIBUTE_DISABLED)) {
             getWidgetForPaintable().interval = uidl
                     .getIntAttribute("pollinginterval");
             getWidgetForPaintable().poller
index a41fbe3ef9092373ff09cae5efaac6701dc86487..17d02d5374454c049fd51b119e3ad7041a23aa43 100644 (file)
@@ -979,7 +979,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
                 .getBooleanAttribute("nsa") : true;
 
         if (uidl.hasAttribute("selectmode")) {
-            if (uidl.getBooleanAttribute("readonly")) {
+            if (uidl.getBooleanAttribute(VAbstractPaintableWidget.ATTRIBUTE_READONLY)) {
                 selectMode = SelectMode.NONE;
             } else if (uidl.getStringAttribute("selectmode").equals("multi")) {
                 selectMode = SelectMode.MULTI;
index 23cf4925f8cd350369f494d22253ac9f97a57f11..a95ac5ef79f4b1b92dc847e949ba80d0769e6dec 100644 (file)
@@ -55,7 +55,8 @@ public class VScrollTablePaintable extends VAbstractPaintableWidgetContainer {
             return;
         }
 
-        getWidgetForPaintable().enabled = !uidl.hasAttribute("disabled");
+        getWidgetForPaintable().enabled = !uidl
+                .hasAttribute(ATTRIBUTE_DISABLED);
 
         if (BrowserInfo.get().isIE8() && !getWidgetForPaintable().enabled) {
             /*
@@ -72,7 +73,7 @@ public class VScrollTablePaintable extends VAbstractPaintableWidgetContainer {
         getWidgetForPaintable().client = client;
         getWidgetForPaintable().paintableId = uidl.getStringAttribute("id");
         getWidgetForPaintable().immediate = uidl
-                .getBooleanAttribute("immediate");
+                .getBooleanAttribute(ATTRIBUTE_IMMEDIATE);
 
         int previousTotalRows = getWidgetForPaintable().totalRows;
         getWidgetForPaintable().updateTotalRows(uidl);
index 5e32ac873a031a6deae6c181dcc224dd0bc56dee..2c25c6b16e22f7a30043188283ccffaed666d3a0 100644 (file)
@@ -25,15 +25,17 @@ public class VSliderPaintable extends VAbstractPaintableWidget {
         }
 
         getWidgetForPaintable().immediate = uidl
-                .getBooleanAttribute("immediate");
-        getWidgetForPaintable().disabled = uidl.getBooleanAttribute("disabled");
-        getWidgetForPaintable().readonly = uidl.getBooleanAttribute("readonly");
+                .getBooleanAttribute(ATTRIBUTE_IMMEDIATE);
+        getWidgetForPaintable().disabled = uidl
+                .getBooleanAttribute(ATTRIBUTE_DISABLED);
+        getWidgetForPaintable().readonly = uidl
+                .getBooleanAttribute(ATTRIBUTE_READONLY);
 
         getWidgetForPaintable().vertical = uidl.hasAttribute("vertical");
 
         String style = "";
-        if (uidl.hasAttribute("style")) {
-            style = uidl.getStringAttribute("style");
+        if (uidl.hasAttribute(ATTRIBUTE_STYLE)) {
+            style = uidl.getStringAttribute(ATTRIBUTE_STYLE);
         }
 
         if (getWidgetForPaintable().vertical) {
index 392c500f1df3956a9aef15b40c61da25837b6e81..ccd2b287a48eb12aba81bf5aa913d48916467e32 100644 (file)
@@ -198,12 +198,13 @@ public class VTabsheet extends VTabsheetBase {
 
         @Override
         public boolean updateCaption(UIDL uidl) {
-            if (uidl.hasAttribute(ATTRIBUTE_DESCRIPTION)
-                    || uidl.hasAttribute(ATTRIBUTE_ERROR)) {
+            if (uidl.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_DESCRIPTION)
+                    || uidl.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_ERROR)) {
                 TooltipInfo tooltipInfo = new TooltipInfo();
-                tooltipInfo.setTitle(uidl
-                        .getStringAttribute(ATTRIBUTE_DESCRIPTION));
-                if (uidl.hasAttribute(ATTRIBUTE_ERROR)) {
+                tooltipInfo
+                        .setTitle(uidl
+                                .getStringAttribute(VAbstractPaintableWidget.ATTRIBUTE_DESCRIPTION));
+                if (uidl.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_ERROR)) {
                     tooltipInfo.setErrorUidl(uidl.getErrors());
                 }
                 client.registerWidgetTooltip(getTabsheet(), getElement(),
@@ -637,8 +638,9 @@ public class VTabsheet extends VTabsheetBase {
     void handleStyleNames(UIDL uidl) {
         // Add proper stylenames for all elements (easier to prevent unwanted
         // style inheritance)
-        if (uidl.hasAttribute("style")) {
-            final String style = uidl.getStringAttribute("style");
+        if (uidl.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_STYLE)) {
+            final String style = uidl
+                    .getStringAttribute(VAbstractPaintableWidget.ATTRIBUTE_STYLE);
             if (currentStyle != style) {
                 currentStyle = style;
                 final String[] styles = style.split(" ");
index f08ffbe1452c5ce6b614887c7dd9ec62b8e18494..2a04f5fb231e77cb57910dfb1e0a24051ee5ea8c 100644 (file)
@@ -15,6 +15,9 @@ import com.vaadin.terminal.gwt.client.VPaintableWidget;
 public abstract class VTabsheetBasePaintable extends
         VAbstractPaintableWidgetContainer {
 
+    // this needs to match ATTRIBUTE_DISABLED as it is used in building captions
+    public static final String ATTRIBUTE_TAB_DISABLED = VAbstractPaintableWidget.ATTRIBUTE_DISABLED;
+
     @Override
     public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
         getWidgetForPaintable().client = client;
@@ -27,7 +30,8 @@ public abstract class VTabsheetBasePaintable extends
 
         // Update member references
         getWidgetForPaintable().id = uidl.getId();
-        getWidgetForPaintable().disabled = uidl.hasAttribute("disabled");
+        getWidgetForPaintable().disabled = uidl
+                .hasAttribute(ATTRIBUTE_DISABLED);
 
         // Render content
         final UIDL tabs = uidl.getChildUIDL(0);
@@ -50,7 +54,7 @@ public abstract class VTabsheetBasePaintable extends
             final boolean selected = tab.getBooleanAttribute("selected");
             final boolean hidden = tab.getBooleanAttribute("hidden");
 
-            if (tab.getBooleanAttribute("disabled")) {
+            if (tab.getBooleanAttribute(ATTRIBUTE_TAB_DISABLED)) {
                 getWidgetForPaintable().disabledTabKeys.add(key);
             }
 
index f7735afc6922c9c854457e33b5e74246a7c99290..5736e775650167300e18df81b41c15a73adc0341 100644 (file)
@@ -27,7 +27,7 @@ public class VTextFieldPaintable extends VAbstractPaintableWidget implements
             return;
         }
 
-        if (uidl.getBooleanAttribute("readonly")) {
+        if (uidl.getBooleanAttribute(ATTRIBUTE_READONLY)) {
             getWidgetForPaintable().setReadOnly(true);
         } else {
             getWidgetForPaintable().setReadOnly(false);
@@ -41,7 +41,7 @@ public class VTextFieldPaintable extends VAbstractPaintableWidget implements
                         .getIntAttribute("maxLength") : -1);
 
         getWidgetForPaintable().immediate = uidl
-                .getBooleanAttribute("immediate");
+                .getBooleanAttribute(ATTRIBUTE_IMMEDIATE);
 
         getWidgetForPaintable().listenTextChangeEvents = client
                 .hasEventListeners(this, "ie");
index 1a45c7418d025300bfa735642a048d269a55c87a..9704c3898346b91e201a24ed680301d2dfca2df6 100644 (file)
@@ -34,10 +34,13 @@ public class VTreePaintable extends VAbstractPaintableWidget {
 
         getWidgetForPaintable().paintableId = uidl.getId();
 
-        getWidgetForPaintable().immediate = uidl.hasAttribute("immediate");
+        getWidgetForPaintable().immediate = uidl
+                .hasAttribute(ATTRIBUTE_IMMEDIATE);
 
-        getWidgetForPaintable().disabled = uidl.getBooleanAttribute("disabled");
-        getWidgetForPaintable().readonly = uidl.getBooleanAttribute("readonly");
+        getWidgetForPaintable().disabled = uidl
+                .getBooleanAttribute(ATTRIBUTE_DISABLED);
+        getWidgetForPaintable().readonly = uidl
+                .getBooleanAttribute(ATTRIBUTE_READONLY);
 
         getWidgetForPaintable().dragMode = uidl.hasAttribute("dragMode") ? uidl
                 .getIntAttribute("dragMode") : 0;
index d633d8721c1089696a16fe599fab485ae725c03d..cabf17be73b4f2dafcb2aa4160ef095f19b96eb3 100644 (file)
@@ -26,7 +26,7 @@ public class VUploadPaintable extends VAbstractPaintableWidget {
             return;
         }
         getWidgetForPaintable().setImmediate(
-                uidl.getBooleanAttribute("immediate"));
+                uidl.getBooleanAttribute(ATTRIBUTE_IMMEDIATE));
         getWidgetForPaintable().client = client;
         getWidgetForPaintable().paintableId = uidl.getId();
         getWidgetForPaintable().nextUploadId = uidl.getIntAttribute("nextid");
@@ -43,7 +43,8 @@ public class VUploadPaintable extends VAbstractPaintableWidget {
         getWidgetForPaintable().fu.setName(getWidgetForPaintable().paintableId
                 + "_file");
 
-        if (uidl.hasAttribute("disabled") || uidl.hasAttribute("readonly")) {
+        if (uidl.hasAttribute(ATTRIBUTE_DISABLED)
+                || uidl.hasAttribute(ATTRIBUTE_READONLY)) {
             getWidgetForPaintable().disableUpload();
         } else if (!uidl.getBooleanAttribute("state")) {
             // Enable the button only if an upload is not in progress
index 890fdd3e13d46edca3b75a2b2b1623dc610c4b16..ea4a4dee7bc8c606a3e118fee9cee767adb756bf 100644 (file)
@@ -41,7 +41,8 @@ public class VViewPaintable extends VAbstractPaintableWidgetContainer {
         boolean firstPaint = getWidgetForPaintable().connection == null;
         getWidgetForPaintable().connection = client;
 
-        getWidgetForPaintable().immediate = uidl.hasAttribute("immediate");
+        getWidgetForPaintable().immediate = uidl
+                .hasAttribute(ATTRIBUTE_IMMEDIATE);
         getWidgetForPaintable().resizeLazy = uidl
                 .hasAttribute(VView.RESIZE_LAZY);
         String newTheme = uidl.getStringAttribute("theme");
@@ -53,19 +54,19 @@ public class VViewPaintable extends VAbstractPaintableWidgetContainer {
         } else {
             getWidgetForPaintable().theme = newTheme;
         }
-        if (uidl.hasAttribute("style")) {
+        if (uidl.hasAttribute(ATTRIBUTE_STYLE)) {
             getWidgetForPaintable().setStyleName(
                     getWidgetForPaintable().getStylePrimaryName() + " "
-                            + uidl.getStringAttribute("style"));
+                            + uidl.getStringAttribute(ATTRIBUTE_STYLE));
         }
 
         clickEventHandler.handleEventHandlerRegistration(client);
 
         if (!getWidgetForPaintable().isEmbedded()
-                && uidl.hasAttribute("caption")) {
+                && uidl.hasAttribute(ATTRIBUTE_CAPTION)) {
             // only change window title if we're in charge of the whole page
             com.google.gwt.user.client.Window.setTitle(uidl
-                    .getStringAttribute("caption"));
+                    .getStringAttribute(ATTRIBUTE_CAPTION));
         }
 
         // Process children
index afcd95a48bbaa8cf0dd6cb6d63122caf59110020..7803931ecd04971e559b1975a9b1fe8c2de9c668 100644 (file)
@@ -92,10 +92,11 @@ public class VWindowPaintable extends VAbstractPaintableWidgetContainer
 
         clickEventHandler.handleEventHandlerRegistration(client);
 
-        getWidgetForPaintable().immediate = uidl.hasAttribute("immediate");
+        getWidgetForPaintable().immediate = uidl
+                .hasAttribute(ATTRIBUTE_IMMEDIATE);
 
         getWidgetForPaintable().setClosable(
-                !uidl.getBooleanAttribute("readonly"));
+                !uidl.getBooleanAttribute(ATTRIBUTE_READONLY));
 
         // Initialize the position form UIDL
         int positionx = uidl.getIntVariable("positionx");
index 9ade007d2e9c50223ce218a9519a6326aa45d6d8..9fa6aeeda0468a1c64daa39bde3125dcf2f43ea0 100644 (file)
@@ -32,7 +32,7 @@ public class VRichTextAreaPaintable extends VAbstractPaintableWidget implements
         }
         if (isRealUpdate(uidl)) {
             getWidgetForPaintable().setEnabled(
-                    !uidl.getBooleanAttribute("disabled"));
+                    !uidl.getBooleanAttribute(ATTRIBUTE_DISABLED));
         }
 
         super.updateFromUIDL(uidl, client);
@@ -41,9 +41,9 @@ public class VRichTextAreaPaintable extends VAbstractPaintableWidget implements
         }
 
         getWidgetForPaintable().setReadOnly(
-                uidl.getBooleanAttribute("readonly"));
+                uidl.getBooleanAttribute(ATTRIBUTE_READONLY));
         getWidgetForPaintable().immediate = uidl
-                .getBooleanAttribute("immediate");
+                .getBooleanAttribute(ATTRIBUTE_IMMEDIATE);
         int newMaxLength = uidl.hasAttribute("maxLength") ? uidl
                 .getIntAttribute("maxLength") : -1;
         if (newMaxLength >= 0) {
index 5b877825c64ae8d6894e9a7de06a7d9b99935c53..9654f12ea3dfe09397760982cbf8b4fd5484a88c 100644 (file)
@@ -31,6 +31,7 @@ import com.vaadin.terminal.PaintTarget.PaintStatus;
 import com.vaadin.terminal.Resource;
 import com.vaadin.terminal.Terminal;
 import com.vaadin.terminal.gwt.client.ComponentState;
+import com.vaadin.terminal.gwt.client.ui.VAbstractPaintableWidget;
 import com.vaadin.terminal.gwt.server.ComponentSizeValidator;
 import com.vaadin.terminal.gwt.server.RpcManager;
 import com.vaadin.terminal.gwt.server.RpcTarget;
@@ -771,27 +772,37 @@ public abstract class AbstractComponent implements Component, MethodEventSource
                 // width and height are only in shared state
 
                 if (styles != null && styles.size() > 0) {
-                    target.addAttribute("style", getStyle());
+                    target.addAttribute(
+                            VAbstractPaintableWidget.ATTRIBUTE_STYLE,
+                            getStyle());
                 }
                 if (isReadOnly()) {
-                    target.addAttribute("readonly", true);
+                    target.addAttribute(
+                            VAbstractPaintableWidget.ATTRIBUTE_READONLY, true);
                 }
 
                 if (isImmediate()) {
-                    target.addAttribute("immediate", true);
+                    target.addAttribute(
+                            VAbstractPaintableWidget.ATTRIBUTE_IMMEDIATE, true);
                 }
                 if (!isEnabled()) {
-                    target.addAttribute("disabled", true);
+                    target.addAttribute(
+                            VAbstractPaintableWidget.ATTRIBUTE_DISABLED, true);
                 }
                 if (getCaption() != null) {
-                    target.addAttribute("caption", getCaption());
+                    target.addAttribute(
+                            VAbstractPaintableWidget.ATTRIBUTE_CAPTION,
+                            getCaption());
                 }
                 if (getIcon() != null) {
-                    target.addAttribute("icon", getIcon());
+                    target.addAttribute(
+                            VAbstractPaintableWidget.ATTRIBUTE_ICON, getIcon());
                 }
 
                 if (getDescription() != null && getDescription().length() > 0) {
-                    target.addAttribute("description", getDescription());
+                    target.addAttribute(
+                            VAbstractPaintableWidget.ATTRIBUTE_DESCRIPTION,
+                            getDescription());
                 }
 
                 if (eventIdentifiers != null) {
@@ -893,6 +904,10 @@ public abstract class AbstractComponent implements Component, MethodEventSource
             state.put(ComponentState.STATE_WIDTH, "" + getCSSWidth());
         }
 
+        // if (getCaption() != null) {
+        // state.put(ComponentState.STATE_CAPTION, getCaption());
+        // }
+
         // TODO use the rest on the client side
 
         // if (styles != null && styles.size() > 0) {
@@ -908,11 +923,7 @@ public abstract class AbstractComponent implements Component, MethodEventSource
         // if (!isEnabled()) {
         // state.put(ComponentState.STATE_DISABLED, true);
         // }
-        // if (getCaption() != null) {
-        // state.put(ComponentState.STATE_CAPTION, getCaption());
-        // }
         // // TODO add icon (Resource)
-        //
         // if (getDescription() != null && getDescription().length() > 0) {
         // state.put(ComponentState.STATE_DESCRIPTION, getDescription());
         // }
index 4217f5f6fe0637d07e9c97b89882375d89f5baf5..f949bc3da86805948ba8293d288a310001f2ef52 100644 (file)
@@ -30,6 +30,7 @@ import com.vaadin.terminal.CompositeErrorMessage;
 import com.vaadin.terminal.ErrorMessage;
 import com.vaadin.terminal.PaintException;
 import com.vaadin.terminal.PaintTarget;
+import com.vaadin.terminal.gwt.client.ui.VAbstractPaintableWidget;
 
 /**
  * <p>
@@ -172,12 +173,14 @@ public abstract class AbstractField<T> extends AbstractComponent implements
 
         // Adds the required attribute
         if (!isReadOnly() && isRequired()) {
-            target.addAttribute("required", true);
+            target.addAttribute(VAbstractPaintableWidget.ATTRIBUTE_REQUIRED,
+                    true);
         }
 
         // Hide the error indicator if needed
         if (shouldHideErrors()) {
-            target.addAttribute("hideErrors", true);
+            target.addAttribute(VAbstractPaintableWidget.ATTRIBUTE_HIDEERRORS,
+                    true);
         }
     }
 
index 54a094a4e75f1b99989f60156d7490d1171a34d2..4a7b90c8edb7a3d690ca3314fd9cfec66891c06c 100644 (file)
@@ -101,16 +101,17 @@ public class MenuBar extends AbstractComponent {
 
             Resource icon = item.getIcon();
             if (icon != null) {
-                target.addAttribute("icon", icon);
+                target.addAttribute(VMenuBar.ATTRIBUTE_ITEM_ICON, icon);
             }
 
             if (!item.isEnabled()) {
-                target.addAttribute("disabled", true);
+                target.addAttribute(VMenuBar.ATTRIBUTE_ITEM_DISABLED, true);
             }
 
             String description = item.getDescription();
             if (description != null && description.length() > 0) {
-                target.addAttribute("description", description);
+                target.addAttribute(VMenuBar.ATTRIBUTE_ITEM_DESCRIPTION,
+                        description);
             }
             if (item.isCheckable()) {
                 // if the "checked" attribute is present (either true or false),
index ddacc315543c18f7834df2044dafe041c1a2efa6..ae6636a33c4c71163ea45b50b2576657ed61d9f6 100644 (file)
@@ -61,7 +61,7 @@ public class OptionGroup extends AbstractSelect implements
             throws PaintException {
         super.paintItem(target, itemId);
         if (!isItemEnabled(itemId)) {
-            target.addAttribute("disabled", true);
+            target.addAttribute(VOptionGroup.ATTRIBUTE_OPTION_DISABLED, true);
         }
     }
 
index c1da88aceaaa8ad301528143c91e835691907eee..0ee1f899d66b8ac5955dda6214a16d65f0fafb4c 100644 (file)
@@ -23,6 +23,7 @@ import com.vaadin.event.FieldEvents.FocusListener;
 import com.vaadin.terminal.PaintException;
 import com.vaadin.terminal.PaintTarget;
 import com.vaadin.terminal.Resource;
+import com.vaadin.terminal.gwt.client.ui.VAbstractPaintableWidget;
 import com.vaadin.terminal.gwt.client.ui.VFilterSelectPaintable;
 
 /**
@@ -149,7 +150,8 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering,
 
         // Adds the required attribute
         if (!isReadOnly() && isRequired()) {
-            target.addAttribute("required", true);
+            target.addAttribute(VAbstractPaintableWidget.ATTRIBUTE_REQUIRED,
+                    true);
         }
 
         if (isNewItemsAllowed()) {
@@ -274,7 +276,8 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering,
 
         // Hide the error indicator if needed
         if (shouldHideErrors()) {
-            target.addAttribute("hideErrors", true);
+            target.addAttribute(VAbstractPaintableWidget.ATTRIBUTE_HIDEERRORS,
+                    true);
         }
     }
 
index e256c51cfd0011f9529e95e6a7b09787480c65fe..6208c0ba1fc3063ff68a0e8d1a2f481608c0567e 100644 (file)
@@ -19,7 +19,9 @@ import com.vaadin.terminal.KeyMapper;
 import com.vaadin.terminal.PaintException;
 import com.vaadin.terminal.PaintTarget;
 import com.vaadin.terminal.Resource;
+import com.vaadin.terminal.gwt.client.ui.VAbstractPaintableWidget;
 import com.vaadin.terminal.gwt.client.ui.VTabsheet;
+import com.vaadin.terminal.gwt.client.ui.VTabsheetBasePaintable;
 import com.vaadin.terminal.gwt.client.ui.VTabsheetPaintable;
 import com.vaadin.terminal.gwt.server.CommunicationManager;
 import com.vaadin.ui.themes.Reindeer;
@@ -376,7 +378,8 @@ public class TabSheet extends AbstractComponentContainer {
 
             target.startTag("tab");
             if (!tab.isEnabled() && tab.isVisible()) {
-                target.addAttribute("disabled", true);
+                target.addAttribute(
+                        VTabsheetBasePaintable.ATTRIBUTE_TAB_DISABLED, true);
             }
 
             if (!tab.isVisible()) {
@@ -389,7 +392,8 @@ public class TabSheet extends AbstractComponentContainer {
 
             final Resource icon = tab.getIcon();
             if (icon != null) {
-                target.addAttribute("icon", icon);
+                target.addAttribute(VAbstractPaintableWidget.ATTRIBUTE_ICON,
+                        icon);
             }
             final String caption = tab.getCaption();
             if (caption != null && caption.length() > 0) {