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 {
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";
/**
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) {
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
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("")) {
.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
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
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;
}
pos++;
}
- if (element.equals(ATTRIBUTE_REQUIRED)) {
+ if (element.equals(VAbstractPaintableWidget.ATTRIBUTE_REQUIRED)) {
return pos;
}
if (requiredFieldIndicator != null) {
}
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;
}
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;
((Focusable) getWidgetForPaintable()).setTabIndex(uidl
.getIntAttribute("tabindex"));
}
- setEnabled(!uidl.getBooleanAttribute("disabled"));
+ setEnabled(!uidl.getBooleanAttribute(ATTRIBUTE_DISABLED));
// Style names
String styleName = getStyleNameFromUIDL(getWidgetForPaintable()
*/
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);
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);
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);
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)) {
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];
}
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);
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
"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(),
.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(),
}
// 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
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");
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();
.getIntAttribute("filteringmode");
}
- getWidgetForPaintable().immediate = uidl.hasAttribute("immediate");
+ getWidgetForPaintable().immediate = uidl
+ .hasAttribute(ATTRIBUTE_IMMEDIATE);
getWidgetForPaintable().nullSelectionAllowed = uidl
.hasAttribute("nullselect");
*/
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);
}
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) {
}
- 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 {
// TODO should span also be removed
}
- if (uidl.hasAttribute("description")) {
+ if (uidl.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_DESCRIPTION)) {
if (captionText != null) {
addStyleDependentName("hasdescription");
} else {
}
}
- if (uidl.getBooleanAttribute("required")) {
+ if (uidl.getBooleanAttribute(VAbstractPaintableWidget.ATTRIBUTE_REQUIRED)) {
if (requiredFieldIndicator == null) {
requiredFieldIndicator = DOM.createSpan();
DOM.setInnerText(requiredFieldIndicator, "*");
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, " ");
}
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) {
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,
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");
// Set link caption
getWidgetForPaintable().captionElement.setInnerText(uidl
- .getStringAttribute("caption"));
+ .getStringAttribute(ATTRIBUTE_CAPTION));
// handle error
if (uidl.hasAttribute("error")) {
"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));
}
}
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";
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),
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();
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;
getWidgetForPaintable().paintableId = uidl.getId();
// Set text
- getWidgetForPaintable().setText(uidl.getStringAttribute("caption"));
+ getWidgetForPaintable().setText(
+ uidl.getStringAttribute(ATTRIBUTE_CAPTION));
// handle error
if (uidl.hasAttribute("error")) {
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(
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;
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(),
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
}
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());
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("");
// 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";
// 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();
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");
}
}
- if (!uidl.getBooleanAttribute("disabled")) {
+ if (!uidl.getBooleanAttribute(ATTRIBUTE_DISABLED)) {
getWidgetForPaintable().interval = uidl
.getIntAttribute("pollinginterval");
getWidgetForPaintable().poller
.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;
return;
}
- getWidgetForPaintable().enabled = !uidl.hasAttribute("disabled");
+ getWidgetForPaintable().enabled = !uidl
+ .hasAttribute(ATTRIBUTE_DISABLED);
if (BrowserInfo.get().isIE8() && !getWidgetForPaintable().enabled) {
/*
getWidgetForPaintable().client = client;
getWidgetForPaintable().paintableId = uidl.getStringAttribute("id");
getWidgetForPaintable().immediate = uidl
- .getBooleanAttribute("immediate");
+ .getBooleanAttribute(ATTRIBUTE_IMMEDIATE);
int previousTotalRows = getWidgetForPaintable().totalRows;
getWidgetForPaintable().updateTotalRows(uidl);
}
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) {
@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(),
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(" ");
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;
// 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);
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);
}
return;
}
- if (uidl.getBooleanAttribute("readonly")) {
+ if (uidl.getBooleanAttribute(ATTRIBUTE_READONLY)) {
getWidgetForPaintable().setReadOnly(true);
} else {
getWidgetForPaintable().setReadOnly(false);
.getIntAttribute("maxLength") : -1);
getWidgetForPaintable().immediate = uidl
- .getBooleanAttribute("immediate");
+ .getBooleanAttribute(ATTRIBUTE_IMMEDIATE);
getWidgetForPaintable().listenTextChangeEvents = client
.hasEventListeners(this, "ie");
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;
return;
}
getWidgetForPaintable().setImmediate(
- uidl.getBooleanAttribute("immediate"));
+ uidl.getBooleanAttribute(ATTRIBUTE_IMMEDIATE));
getWidgetForPaintable().client = client;
getWidgetForPaintable().paintableId = uidl.getId();
getWidgetForPaintable().nextUploadId = uidl.getIntAttribute("nextid");
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
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");
} 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
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");
}
if (isRealUpdate(uidl)) {
getWidgetForPaintable().setEnabled(
- !uidl.getBooleanAttribute("disabled"));
+ !uidl.getBooleanAttribute(ATTRIBUTE_DISABLED));
}
super.updateFromUIDL(uidl, client);
}
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) {
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;
// 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) {
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) {
// 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());
// }
import com.vaadin.terminal.ErrorMessage;
import com.vaadin.terminal.PaintException;
import com.vaadin.terminal.PaintTarget;
+import com.vaadin.terminal.gwt.client.ui.VAbstractPaintableWidget;
/**
* <p>
// 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);
}
}
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),
throws PaintException {
super.paintItem(target, itemId);
if (!isItemEnabled(itemId)) {
- target.addAttribute("disabled", true);
+ target.addAttribute(VOptionGroup.ATTRIBUTE_OPTION_DISABLED, true);
}
}
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;
/**
// Adds the required attribute
if (!isReadOnly() && isRequired()) {
- target.addAttribute("required", true);
+ target.addAttribute(VAbstractPaintableWidget.ATTRIBUTE_REQUIRED,
+ true);
}
if (isNewItemsAllowed()) {
// Hide the error indicator if needed
if (shouldHideErrors()) {
- target.addAttribute("hideErrors", true);
+ target.addAttribute(VAbstractPaintableWidget.ATTRIBUTE_HIDEERRORS,
+ true);
}
}
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;
target.startTag("tab");
if (!tab.isEnabled() && tab.isVisible()) {
- target.addAttribute("disabled", true);
+ target.addAttribute(
+ VTabsheetBasePaintable.ATTRIBUTE_TAB_DISABLED, true);
}
if (!tab.isVisible()) {
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) {