summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorHenri Sara <hesara@vaadin.com>2012-02-21 11:06:41 +0200
committerHenri Sara <hesara@vaadin.com>2012-02-21 11:06:41 +0200
commite31b26ca9840d653944bec1dc3123a35cef487e0 (patch)
tree1b41a753c6111a27060009642434b8cf208ef9bc /src/com
parente87a17b003cba3bd8cb11e60f1d2f57e1a653654 (diff)
downloadvaadin-framework-e31b26ca9840d653944bec1dc3123a35cef487e0.tar.gz
vaadin-framework-e31b26ca9840d653944bec1dc3123a35cef487e0.zip
Convert some literal strings of UIDL attributes to use constants.
Diffstat (limited to 'src/com')
-rw-r--r--src/com/vaadin/terminal/gwt/client/VCaption.java76
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VAbstractPaintableWidget.java28
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VAbstractSplitPanelPaintable.java9
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VButtonPaintable.java9
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VCheckBoxPaintable.java13
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VDateFieldPaintable.java8
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VFilterSelectPaintable.java9
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VFormLayout.java23
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VFormPaintable.java14
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VLinkPaintable.java14
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java10
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VMenuBarPaintable.java3
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VNativeButtonPaintable.java9
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VOptionGroup.java5
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VOptionGroupBasePaintable.java8
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VPanel.java6
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VPanelPaintable.java12
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VPopupViewPaintable.java6
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VProgressIndicatorPaintable.java4
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java2
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VScrollTablePaintable.java5
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VSliderPaintable.java12
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java16
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VTabsheetBasePaintable.java8
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VTextFieldPaintable.java4
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VTreePaintable.java9
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VUploadPaintable.java5
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VViewPaintable.java11
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VWindowPaintable.java5
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/richtextarea/VRichTextAreaPaintable.java6
-rw-r--r--src/com/vaadin/ui/AbstractComponent.java33
-rw-r--r--src/com/vaadin/ui/AbstractField.java7
-rw-r--r--src/com/vaadin/ui/MenuBar.java7
-rw-r--r--src/com/vaadin/ui/OptionGroup.java2
-rw-r--r--src/com/vaadin/ui/Select.java7
-rw-r--r--src/com/vaadin/ui/TabSheet.java8
36 files changed, 250 insertions, 163 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/VCaption.java b/src/com/vaadin/terminal/gwt/client/VCaption.java
index f6d8ffe58e..756fa71b6a 100644
--- a/src/com/vaadin/terminal/gwt/client/VCaption.java
+++ b/src/com/vaadin/terminal/gwt/client/VCaption.java
@@ -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;
}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VAbstractPaintableWidget.java b/src/com/vaadin/terminal/gwt/client/ui/VAbstractPaintableWidget.java
index 3d186d2759..2c948dfba8 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VAbstractPaintableWidget.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VAbstractPaintableWidget.java
@@ -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);
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VAbstractSplitPanelPaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VAbstractSplitPanelPaintable.java
index ccf3119d13..8d4a6954a1 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VAbstractSplitPanelPaintable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VAbstractSplitPanelPaintable.java
@@ -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];
}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VButtonPaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VButtonPaintable.java
index 9d60e21c82..ea227b1854 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VButtonPaintable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VButtonPaintable.java
@@ -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
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VCheckBoxPaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VCheckBoxPaintable.java
index acbb620361..daacbe03e5 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VCheckBoxPaintable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VCheckBoxPaintable.java
@@ -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
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VDateFieldPaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VDateFieldPaintable.java
index c11ef6f54f..0798cd1e60 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VDateFieldPaintable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VDateFieldPaintable.java
@@ -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");
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelectPaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelectPaintable.java
index eaf9eec16a..cd1c4e122d 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelectPaintable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelectPaintable.java
@@ -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");
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VFormLayout.java b/src/com/vaadin/terminal/gwt/client/ui/VFormLayout.java
index 6d3072f407..3e5600e4e6 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VFormLayout.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VFormLayout.java
@@ -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;");
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VFormPaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VFormPaintable.java
index a15a5b7837..eb0a91fb04 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VFormPaintable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VFormPaintable.java
@@ -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,
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VLinkPaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VLinkPaintable.java
index 6980baa61d..432365eaa7 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VLinkPaintable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VLinkPaintable.java
@@ -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));
}
}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java b/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java
index c39155d032..3bd90e17e6 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java
@@ -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();
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VMenuBarPaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VMenuBarPaintable.java
index 4b2fdff819..246986f174 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VMenuBarPaintable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VMenuBarPaintable.java
@@ -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;
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VNativeButtonPaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VNativeButtonPaintable.java
index b34a9d1335..4257597e2d 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VNativeButtonPaintable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VNativeButtonPaintable.java
@@ -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(
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VOptionGroup.java b/src/com/vaadin/terminal/gwt/client/ui/VOptionGroup.java
index bf89a01a03..413c5a40d0 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VOptionGroup.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VOptionGroup.java
@@ -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(),
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VOptionGroupBasePaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VOptionGroupBasePaintable.java
index b0fbda0875..2fc538d114 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VOptionGroupBasePaintable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VOptionGroupBasePaintable.java
@@ -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
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VPanel.java b/src/com/vaadin/terminal/gwt/client/ui/VPanel.java
index 82b362a385..b1b3ff27ff 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VPanel.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VPanel.java
@@ -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());
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VPanelPaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VPanelPaintable.java
index 9c34a68528..ce1c1f2482 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VPanelPaintable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VPanelPaintable.java
@@ -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";
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VPopupViewPaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VPopupViewPaintable.java
index 11896f7087..366e49cd75 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VPopupViewPaintable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VPopupViewPaintable.java
@@ -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();
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VProgressIndicatorPaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VProgressIndicatorPaintable.java
index 0d7c1624f4..d91705abe9 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VProgressIndicatorPaintable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VProgressIndicatorPaintable.java
@@ -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
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java
index a41fbe3ef9..17d02d5374 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java
@@ -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;
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTablePaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTablePaintable.java
index 23cf4925f8..a95ac5ef79 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTablePaintable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTablePaintable.java
@@ -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);
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VSliderPaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VSliderPaintable.java
index 5e32ac873a..2c25c6b16e 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VSliderPaintable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VSliderPaintable.java
@@ -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) {
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java b/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java
index 392c500f1d..ccd2b287a4 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java
@@ -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(" ");
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTabsheetBasePaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VTabsheetBasePaintable.java
index f08ffbe145..2a04f5fb23 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VTabsheetBasePaintable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VTabsheetBasePaintable.java
@@ -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);
}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTextFieldPaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VTextFieldPaintable.java
index f7735afc69..5736e77565 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VTextFieldPaintable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VTextFieldPaintable.java
@@ -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");
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTreePaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VTreePaintable.java
index 1a45c7418d..9704c38983 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VTreePaintable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VTreePaintable.java
@@ -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;
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VUploadPaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VUploadPaintable.java
index d633d8721c..cabf17be73 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VUploadPaintable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VUploadPaintable.java
@@ -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
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VViewPaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VViewPaintable.java
index 890fdd3e13..ea4a4dee7b 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VViewPaintable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VViewPaintable.java
@@ -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
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VWindowPaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VWindowPaintable.java
index afcd95a48b..7803931ecd 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VWindowPaintable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VWindowPaintable.java
@@ -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");
diff --git a/src/com/vaadin/terminal/gwt/client/ui/richtextarea/VRichTextAreaPaintable.java b/src/com/vaadin/terminal/gwt/client/ui/richtextarea/VRichTextAreaPaintable.java
index 9ade007d2e..9fa6aeeda0 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/richtextarea/VRichTextAreaPaintable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/richtextarea/VRichTextAreaPaintable.java
@@ -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) {
diff --git a/src/com/vaadin/ui/AbstractComponent.java b/src/com/vaadin/ui/AbstractComponent.java
index 5b877825c6..9654f12ea3 100644
--- a/src/com/vaadin/ui/AbstractComponent.java
+++ b/src/com/vaadin/ui/AbstractComponent.java
@@ -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());
// }
diff --git a/src/com/vaadin/ui/AbstractField.java b/src/com/vaadin/ui/AbstractField.java
index 4217f5f6fe..f949bc3da8 100644
--- a/src/com/vaadin/ui/AbstractField.java
+++ b/src/com/vaadin/ui/AbstractField.java
@@ -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);
}
}
diff --git a/src/com/vaadin/ui/MenuBar.java b/src/com/vaadin/ui/MenuBar.java
index 54a094a4e7..4a7b90c8ed 100644
--- a/src/com/vaadin/ui/MenuBar.java
+++ b/src/com/vaadin/ui/MenuBar.java
@@ -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),
diff --git a/src/com/vaadin/ui/OptionGroup.java b/src/com/vaadin/ui/OptionGroup.java
index ddacc31554..ae6636a33c 100644
--- a/src/com/vaadin/ui/OptionGroup.java
+++ b/src/com/vaadin/ui/OptionGroup.java
@@ -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);
}
}
diff --git a/src/com/vaadin/ui/Select.java b/src/com/vaadin/ui/Select.java
index c1da88acea..0ee1f899d6 100644
--- a/src/com/vaadin/ui/Select.java
+++ b/src/com/vaadin/ui/Select.java
@@ -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);
}
}
diff --git a/src/com/vaadin/ui/TabSheet.java b/src/com/vaadin/ui/TabSheet.java
index e256c51cfd..6208c0ba1f 100644
--- a/src/com/vaadin/ui/TabSheet.java
+++ b/src/com/vaadin/ui/TabSheet.java
@@ -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) {