VAbstractPaintableWidget.updateFromUIDLtags/7.0.0.alpha2
import com.google.gwt.user.client.Event; | import com.google.gwt.user.client.Event; | ||||
import com.google.gwt.user.client.Timer; | import com.google.gwt.user.client.Timer; | ||||
import com.google.gwt.user.client.Window; | import com.google.gwt.user.client.Window; | ||||
import com.google.gwt.user.client.ui.FocusWidget; | |||||
import com.google.gwt.user.client.ui.Focusable; | |||||
import com.google.gwt.user.client.ui.HasWidgets; | import com.google.gwt.user.client.ui.HasWidgets; | ||||
import com.google.gwt.user.client.ui.Widget; | import com.google.gwt.user.client.ui.Widget; | ||||
import com.vaadin.terminal.gwt.client.ApplicationConfiguration.ErrorMessage; | import com.vaadin.terminal.gwt.client.ApplicationConfiguration.ErrorMessage; | ||||
import com.vaadin.terminal.gwt.client.RenderInformation.FloatSize; | import com.vaadin.terminal.gwt.client.RenderInformation.FloatSize; | ||||
import com.vaadin.terminal.gwt.client.RenderInformation.Size; | import com.vaadin.terminal.gwt.client.RenderInformation.Size; | ||||
import com.vaadin.terminal.gwt.client.ui.Field; | |||||
import com.vaadin.terminal.gwt.client.ui.VContextMenu; | import com.vaadin.terminal.gwt.client.ui.VContextMenu; | ||||
import com.vaadin.terminal.gwt.client.ui.VNotification; | import com.vaadin.terminal.gwt.client.ui.VNotification; | ||||
import com.vaadin.terminal.gwt.client.ui.VNotification.HideEvent; | import com.vaadin.terminal.gwt.client.ui.VNotification.HideEvent; | ||||
// This indicates the whole page is generated by us (not embedded) | // This indicates the whole page is generated by us (not embedded) | ||||
public static final String GENERATED_BODY_CLASSNAME = "v-generated-body"; | public static final String GENERATED_BODY_CLASSNAME = "v-generated-body"; | ||||
private static final String MODIFIED_CLASSNAME = "v-modified"; | |||||
public static final String MODIFIED_CLASSNAME = "v-modified"; | |||||
public static final String DISABLED_CLASSNAME = "v-disabled"; | public static final String DISABLED_CLASSNAME = "v-disabled"; | ||||
private static final String REQUIRED_CLASSNAME_EXT = "-required"; | |||||
public static final String REQUIRED_CLASSNAME_EXT = "-required"; | |||||
private static final String ERROR_CLASSNAME_EXT = "-error"; | |||||
public static final String ERROR_CLASSNAME_EXT = "-error"; | |||||
public static final char VAR_RECORD_SEPARATOR = '\u001e'; | public static final char VAR_RECORD_SEPARATOR = '\u001e'; | ||||
public static final String PARAM_UNLOADBURST = "onunloadburst"; | public static final String PARAM_UNLOADBURST = "onunloadburst"; | ||||
public static final String ATTRIBUTE_DESCRIPTION = "description"; | |||||
public static final String ATTRIBUTE_ERROR = "error"; | |||||
/** | /** | ||||
* A string that, if found in a non-JSON response to a UIDL request, will | * A string that, if found in a non-JSON response to a UIDL request, will | ||||
* cause the browser to refresh the page. If followed by a colon, optional | * cause the browser to refresh the page. If followed by a colon, optional | ||||
return result.toString(); | return result.toString(); | ||||
} | } | ||||
/** | |||||
* Update generic component features. | |||||
* | |||||
* <h2>Selecting correct implementation</h2> | |||||
* | |||||
* <p> | |||||
* The implementation of a component depends on many properties, including | |||||
* styles, component features, etc. Sometimes the user changes those | |||||
* properties after the component has been created. Calling this method in | |||||
* the beginning of your updateFromUIDL -method automatically replaces your | |||||
* component with more appropriate if the requested implementation changes. | |||||
* </p> | |||||
* | |||||
* <h2>Caption, icon, error messages and description</h2> | |||||
* | |||||
* <p> | |||||
* Component can delegate management of caption, icon, error messages and | |||||
* description to parent layout. This is optional an should be decided by | |||||
* component author | |||||
* </p> | |||||
* | |||||
* <h2>Component visibility and disabling</h2> | |||||
* | |||||
* This method will manage component visibility automatically and if | |||||
* component is an instanceof FocusWidget, also handle component disabling | |||||
* when needed. | |||||
* | |||||
* @param component | |||||
* Widget to be updated, expected to implement an instance of | |||||
* Paintable | |||||
* @param uidl | |||||
* UIDL to be painted | |||||
* @param manageCaption | |||||
* True if you want to delegate caption, icon, description and | |||||
* error message management to parent. | |||||
* | |||||
* @return Returns true iff no further painting is needed by caller | |||||
*/ | |||||
@Deprecated | |||||
public boolean updateComponent(VPaintableWidget paintable, UIDL uidl, | |||||
boolean manageCaption) { | |||||
Widget component = paintable.getWidgetForPaintable(); | |||||
String pid = paintableMap.getPid(paintable); | |||||
if (pid == null) { | |||||
VConsole.error("Trying to update an unregistered component: " | |||||
+ Util.getSimpleName(component)); | |||||
return true; | |||||
} | |||||
// If the server request that a cached instance should be used, do | |||||
// nothing | |||||
if (uidl.getBooleanAttribute("cached")) { | |||||
return true; | |||||
} | |||||
// register the listened events by the server-side to the event-handler | |||||
// of the component | |||||
paintableMap.registerEventListenersFromUIDL(pid, uidl); | |||||
// Visibility | |||||
boolean visible = !uidl.getBooleanAttribute("invisible"); | |||||
boolean wasVisible = component.isVisible(); | |||||
component.setVisible(visible); | |||||
if (wasVisible != visible) { | |||||
// Changed invisibile <-> visible | |||||
if (wasVisible && manageCaption) { | |||||
// Must hide caption when component is hidden | |||||
paintable.getParent().updateCaption(paintable, uidl); | |||||
} | |||||
} | |||||
if (configuration.useDebugIdInDOM() && uidl.getId().startsWith("PID_S")) { | |||||
DOM.setElementProperty(component.getElement(), "id", uidl.getId() | |||||
.substring(5)); | |||||
} | |||||
if (!visible) { | |||||
// component is invisible, delete old size to notify parent, if | |||||
// later make visible | |||||
paintableMap.setOffsetSize(paintable, null); | |||||
return true; | |||||
} | |||||
boolean enabled = !uidl.getBooleanAttribute("disabled"); | |||||
if (uidl.hasAttribute("tabindex") && component instanceof Focusable) { | |||||
((Focusable) component).setTabIndex(uidl | |||||
.getIntAttribute("tabindex")); | |||||
} | |||||
/* | |||||
* Disabled state may affect (override) tabindex so the order must be | |||||
* first setting tabindex, then enabled state. | |||||
*/ | |||||
if (component instanceof FocusWidget) { | |||||
FocusWidget fw = (FocusWidget) component; | |||||
fw.setEnabled(enabled); | |||||
} | |||||
// Style names | |||||
component.setStyleName(getStyleName(component.getStylePrimaryName(), | |||||
uidl, component instanceof Field)); | |||||
TooltipInfo tooltipInfo = paintableMap.getTooltipInfo(paintable, null); | |||||
// Update tooltip | |||||
if (uidl.hasAttribute(ATTRIBUTE_DESCRIPTION)) { | |||||
tooltipInfo | |||||
.setTitle(uidl.getStringAttribute(ATTRIBUTE_DESCRIPTION)); | |||||
} else { | |||||
tooltipInfo.setTitle(null); | |||||
} | |||||
// Set captions | |||||
if (manageCaption) { | |||||
paintable.getParent().updateCaption(paintable, uidl); | |||||
} | |||||
// add error classname to components w/ error | |||||
if (uidl.hasAttribute(ATTRIBUTE_ERROR)) { | |||||
tooltipInfo.setErrorUidl(uidl.getErrors()); | |||||
} else { | |||||
tooltipInfo.setErrorUidl(null); | |||||
} | |||||
/* | |||||
* updateComponentSize need to be after caption update so caption can be | |||||
* taken into account | |||||
*/ | |||||
updateComponentSize(paintable, uidl); | |||||
return false; | |||||
} | |||||
/** | |||||
* Generates the style name for the widget based on the given primary style | |||||
* name (typically returned by Widget.getPrimaryStyleName()) and the UIDL. | |||||
* An additional "modified" style name can be added if the field parameter | |||||
* is set to true. | |||||
* | |||||
* @param primaryStyleName | |||||
* @param uidl | |||||
* @param isField | |||||
* @return | |||||
*/ | |||||
public static String getStyleName(String primaryStyleName, UIDL uidl, | |||||
boolean field) { | |||||
boolean enabled = !uidl.getBooleanAttribute("disabled"); | |||||
StringBuffer styleBuf = new StringBuffer(); | |||||
styleBuf.append(primaryStyleName); | |||||
// first disabling and read-only status | |||||
if (!enabled) { | |||||
styleBuf.append(" "); | |||||
styleBuf.append(DISABLED_CLASSNAME); | |||||
} | |||||
if (uidl.getBooleanAttribute("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(" "); | |||||
for (int i = 0; i < styles.length; i++) { | |||||
styleBuf.append(" "); | |||||
styleBuf.append(primaryStyleName); | |||||
styleBuf.append("-"); | |||||
styleBuf.append(styles[i]); | |||||
styleBuf.append(" "); | |||||
styleBuf.append(styles[i]); | |||||
} | |||||
} | |||||
// add modified classname to Fields | |||||
if (field && uidl.hasAttribute("modified")) { | |||||
styleBuf.append(" "); | |||||
styleBuf.append(MODIFIED_CLASSNAME); | |||||
} | |||||
// add error classname to components w/ error | |||||
if (uidl.hasAttribute(ATTRIBUTE_ERROR)) { | |||||
styleBuf.append(" "); | |||||
styleBuf.append(primaryStyleName); | |||||
styleBuf.append(ERROR_CLASSNAME_EXT); | |||||
} | |||||
// add required style to required components | |||||
if (uidl.hasAttribute("required")) { | |||||
styleBuf.append(" "); | |||||
styleBuf.append(primaryStyleName); | |||||
styleBuf.append(REQUIRED_CLASSNAME_EXT); | |||||
} | |||||
return styleBuf.toString(); | |||||
} | |||||
private void updateComponentSize(VPaintableWidget paintable, UIDL uidl) { | |||||
public void updateComponentSize(VPaintableWidget paintable, UIDL uidl) { | |||||
String w = uidl.hasAttribute("width") ? uidl | String w = uidl.hasAttribute("width") ? uidl | ||||
.getStringAttribute("width") : ""; | .getStringAttribute("width") : ""; | ||||
} | } | ||||
@Deprecated | |||||
public static boolean isCached(UIDL uidl) { | public static boolean isCached(UIDL uidl) { | ||||
return uidl.getBooleanAttribute("cached"); | return uidl.getBooleanAttribute("cached"); | ||||
} | } |
} | } | ||||
}; | }; | ||||
@Override | |||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
getWidgetForPaintable().rendering = true; | getWidgetForPaintable().rendering = true; | ||||
getWidgetForPaintable().client = client; | getWidgetForPaintable().client = client; | ||||
// TODO margin handling | // TODO margin handling | ||||
if (client.updateComponent(this, uidl, true)) { | |||||
super.updateFromUIDL(uidl, client); | |||||
if (!isRealUpdate(uidl)) { | |||||
getWidgetForPaintable().rendering = false; | getWidgetForPaintable().rendering = false; | ||||
return; | return; | ||||
} | } |
*/ | */ | ||||
package com.vaadin.terminal.gwt.client.ui; | package com.vaadin.terminal.gwt.client.ui; | ||||
import com.google.gwt.user.client.DOM; | |||||
import com.google.gwt.user.client.ui.FocusWidget; | |||||
import com.google.gwt.user.client.ui.Focusable; | |||||
import com.google.gwt.user.client.ui.Widget; | import com.google.gwt.user.client.ui.Widget; | ||||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | import com.vaadin.terminal.gwt.client.ApplicationConnection; | ||||
import com.vaadin.terminal.gwt.client.TooltipInfo; | |||||
import com.vaadin.terminal.gwt.client.UIDL; | |||||
import com.vaadin.terminal.gwt.client.VPaintableMap; | import com.vaadin.terminal.gwt.client.VPaintableMap; | ||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | import com.vaadin.terminal.gwt.client.VPaintableWidget; | ||||
import com.vaadin.terminal.gwt.client.VPaintableWidgetContainer; | import com.vaadin.terminal.gwt.client.VPaintableWidgetContainer; | ||||
public abstract class VAbstractPaintableWidget implements VPaintableWidget { | public abstract class VAbstractPaintableWidget implements VPaintableWidget { | ||||
public static final String ATTRIBUTE_DESCRIPTION = "description"; | |||||
public static final String ATTRIBUTE_ERROR = "error"; | |||||
private Widget widget; | private Widget widget; | ||||
private ApplicationConnection connection; | private ApplicationConnection connection; | ||||
private String id; | private String id; | ||||
private VPaintableWidgetContainer parent; | private VPaintableWidgetContainer parent; | ||||
/* State variables */ | /* State variables */ | ||||
private boolean enabled = true; | private boolean enabled = true; | ||||
private boolean visible = true; | |||||
/** | /** | ||||
* Default constructor | * Default constructor | ||||
this.connection = connection; | this.connection = connection; | ||||
} | } | ||||
public boolean isEnabled() { | |||||
return enabled; | |||||
} | |||||
public String getId() { | public String getId() { | ||||
return id; | return id; | ||||
} | } | ||||
} | } | ||||
public VPaintableWidgetContainer getParent() { | public VPaintableWidgetContainer getParent() { | ||||
if (parent != null) | |||||
if (parent != null) { | |||||
return parent; | return parent; | ||||
} | |||||
// FIXME: Hierarchy should be set by framework instead of looked up here | // FIXME: Hierarchy should be set by framework instead of looked up here | ||||
VPaintableMap paintableMap = VPaintableMap.get(getConnection()); | VPaintableMap paintableMap = VPaintableMap.get(getConnection()); | ||||
while (w != null) { | while (w != null) { | ||||
w = w.getParent(); | w = w.getParent(); | ||||
if (paintableMap.isPaintable(w)) { | if (paintableMap.isPaintable(w)) { | ||||
parent = (VPaintableWidgetContainer) paintableMap.getPaintable(w); | |||||
parent = (VPaintableWidgetContainer) paintableMap | |||||
.getPaintable(w); | |||||
return parent; | return parent; | ||||
} | } | ||||
} | } | ||||
return null; | return null; | ||||
} | } | ||||
protected static boolean isRealUpdate(UIDL uidl) { | |||||
return !isCachedUpdate(uidl) && !uidl.getBooleanAttribute("invisible"); | |||||
} | |||||
protected static boolean isCachedUpdate(UIDL uidl) { | |||||
return uidl.getBooleanAttribute("cached"); | |||||
} | |||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | |||||
if (isCachedUpdate(uidl)) { | |||||
return; | |||||
} | |||||
VPaintableMap paintableMap = VPaintableMap.get(getConnection()); | |||||
// register the listened events by the server-side to the event-handler | |||||
// of the component | |||||
paintableMap.registerEventListenersFromUIDL(getId(), uidl); | |||||
// Visibility | |||||
setVisible(!uidl.getBooleanAttribute("invisible"), uidl); | |||||
if (uidl.getId().startsWith("PID_S")) { | |||||
DOM.setElementProperty(getWidgetForPaintable().getElement(), "id", | |||||
uidl.getId().substring(5)); | |||||
} | |||||
if (!isVisible()) { | |||||
// component is invisible, delete old size to notify parent, if | |||||
// later made visible | |||||
paintableMap.setOffsetSize(this, null); | |||||
return; | |||||
} | |||||
/* | |||||
* Disabled state may affect (override) tabindex so the order must be | |||||
* first setting tabindex, then enabled state. | |||||
*/ | |||||
if (uidl.hasAttribute("tabindex") | |||||
&& getWidgetForPaintable() instanceof Focusable) { | |||||
((Focusable) getWidgetForPaintable()).setTabIndex(uidl | |||||
.getIntAttribute("tabindex")); | |||||
} | |||||
setEnabled(!uidl.getBooleanAttribute("disabled")); | |||||
// Style names | |||||
String styleName = getStyleNameFromUIDL(getWidgetForPaintable() | |||||
.getStylePrimaryName(), uidl, | |||||
getWidgetForPaintable() instanceof Field); | |||||
getWidgetForPaintable().setStyleName(styleName); | |||||
// Update tooltip | |||||
TooltipInfo tooltipInfo = paintableMap.getTooltipInfo(this, null); | |||||
if (uidl.hasAttribute(ATTRIBUTE_DESCRIPTION)) { | |||||
tooltipInfo | |||||
.setTitle(uidl.getStringAttribute(ATTRIBUTE_DESCRIPTION)); | |||||
} else { | |||||
tooltipInfo.setTitle(null); | |||||
} | |||||
// add error info to tooltip if present | |||||
if (uidl.hasAttribute(ATTRIBUTE_ERROR)) { | |||||
tooltipInfo.setErrorUidl(uidl.getErrors()); | |||||
} else { | |||||
tooltipInfo.setErrorUidl(null); | |||||
} | |||||
// Set captions | |||||
if (delegateCaptionHandling()) { | |||||
getParent().updateCaption(this, uidl); | |||||
} | |||||
/* | |||||
* updateComponentSize need to be after caption update so caption can be | |||||
* taken into account | |||||
*/ | |||||
getConnection().updateComponentSize(this, uidl); | |||||
} | |||||
/** | |||||
* Sets the enabled state of this paintable | |||||
* | |||||
* @param enabled | |||||
* true if the paintable is enabled, false otherwise | |||||
*/ | |||||
protected void setEnabled(boolean enabled) { | |||||
this.enabled = enabled; | |||||
if (getWidgetForPaintable() instanceof FocusWidget) { | |||||
FocusWidget fw = (FocusWidget) getWidgetForPaintable(); | |||||
fw.setEnabled(enabled); | |||||
} | |||||
} | |||||
public boolean isEnabled() { | |||||
return enabled; | |||||
} | |||||
/** | |||||
* Return true if parent handles caption, false if the paintable handles the | |||||
* caption itself. | |||||
* | |||||
* | |||||
* @deprecated This should always return true and all components should let | |||||
* the parent handle the caption and use other attributes for | |||||
* internal texts in the component | |||||
* @return | |||||
*/ | |||||
@Deprecated | |||||
protected boolean delegateCaptionHandling() { | |||||
return true; | |||||
} | |||||
/** | |||||
* Sets the visible state for this paintable. | |||||
* | |||||
* @param visible | |||||
* true if the paintable should be made visible, false otherwise | |||||
* @param captionUidl | |||||
* The UIDL that is passed to the parent and onwards to VCaption | |||||
* if the caption needs to be updated as a result of the | |||||
* visibility change. | |||||
*/ | |||||
protected void setVisible(boolean visible, UIDL captionUidl) { | |||||
boolean wasVisible = this.visible; | |||||
this.visible = visible; | |||||
getWidgetForPaintable().setVisible(visible); | |||||
if (wasVisible != visible) { | |||||
// Changed invisibile <-> visible | |||||
if (wasVisible && delegateCaptionHandling()) { | |||||
// Must hide caption when component is hidden | |||||
getParent().updateCaption(this, captionUidl); | |||||
} | |||||
} | |||||
} | |||||
protected boolean isVisible() { | |||||
return visible; | |||||
} | |||||
/** | |||||
* Generates the style name for the widget based on the given primary style | |||||
* name (typically returned by Widget.getPrimaryStyleName()) and the UIDL. | |||||
* An additional "modified" style name can be added if the field parameter | |||||
* is set to true. | |||||
* | |||||
* @param primaryStyleName | |||||
* @param uidl | |||||
* @param isField | |||||
* @return | |||||
*/ | |||||
protected static String getStyleNameFromUIDL(String primaryStyleName, | |||||
UIDL uidl, boolean field) { | |||||
boolean enabled = !uidl.getBooleanAttribute("disabled"); | |||||
StringBuffer styleBuf = new StringBuffer(); | |||||
styleBuf.append(primaryStyleName); | |||||
// first disabling and read-only status | |||||
if (!enabled) { | |||||
styleBuf.append(" "); | |||||
styleBuf.append(ApplicationConnection.DISABLED_CLASSNAME); | |||||
} | |||||
if (uidl.getBooleanAttribute("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(" "); | |||||
for (int i = 0; i < styles.length; i++) { | |||||
styleBuf.append(" "); | |||||
styleBuf.append(primaryStyleName); | |||||
styleBuf.append("-"); | |||||
styleBuf.append(styles[i]); | |||||
styleBuf.append(" "); | |||||
styleBuf.append(styles[i]); | |||||
} | |||||
} | |||||
// add modified classname to Fields | |||||
if (field && uidl.hasAttribute("modified")) { | |||||
styleBuf.append(" "); | |||||
styleBuf.append(ApplicationConnection.MODIFIED_CLASSNAME); | |||||
} | |||||
// add error classname to components w/ error | |||||
if (uidl.hasAttribute(ATTRIBUTE_ERROR)) { | |||||
styleBuf.append(" "); | |||||
styleBuf.append(primaryStyleName); | |||||
styleBuf.append(ApplicationConnection.ERROR_CLASSNAME_EXT); | |||||
} | |||||
// add required style to required components | |||||
if (uidl.hasAttribute("required")) { | |||||
styleBuf.append(" "); | |||||
styleBuf.append(primaryStyleName); | |||||
styleBuf.append(ApplicationConnection.REQUIRED_CLASSNAME_EXT); | |||||
} | |||||
return styleBuf.toString(); | |||||
} | |||||
} | } |
}; | }; | ||||
@Override | |||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
getWidgetForPaintable().client = client; | getWidgetForPaintable().client = client; | ||||
getWidgetForPaintable().id = uidl.getId(); | getWidgetForPaintable().id = uidl.getId(); | ||||
getWidgetForPaintable().immediate = uidl.hasAttribute("immediate"); | getWidgetForPaintable().immediate = uidl.hasAttribute("immediate"); | ||||
if (client.updateComponent(this, uidl, true)) { | |||||
super.updateFromUIDL(uidl, client); | |||||
if (!isRealUpdate(uidl)) { | |||||
getWidgetForPaintable().rendering = false; | getWidgetForPaintable().rendering = false; | ||||
return; | return; | ||||
} | } |
getWidgetForPaintable().selectedUIDLItemIndex); | getWidgetForPaintable().selectedUIDLItemIndex); | ||||
selectedItem.setContent(selectedTabUIDL); | selectedItem.setContent(selectedTabUIDL); | ||||
} else if (!uidl.getBooleanAttribute("cached") | |||||
} else if (isRealUpdate(uidl) | |||||
&& getWidgetForPaintable().openTab != null) { | && getWidgetForPaintable().openTab != null) { | ||||
getWidgetForPaintable().close(getWidgetForPaintable().openTab); | getWidgetForPaintable().close(getWidgetForPaintable().openTab); | ||||
} | } |
@Override | @Override | ||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
if (client.updateComponent(this, uidl, true)) { | |||||
super.updateFromUIDL(uidl, client); | |||||
if (!isRealUpdate(uidl)) { | |||||
return; | return; | ||||
} | } | ||||
super.updateFromUIDL(uidl, client); | |||||
Style style = getWidgetForPaintable().getElement().getStyle(); | Style style = getWidgetForPaintable().getElement().getStyle(); | ||||
// Make sure that the controls are not clipped if visible. | // Make sure that the controls are not clipped if visible. |
public class VButtonPaintable extends VAbstractPaintableWidget { | public class VButtonPaintable extends VAbstractPaintableWidget { | ||||
@Override | |||||
protected boolean delegateCaptionHandling() { | |||||
return false; | |||||
} | |||||
@Override | |||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
// Ensure correct implementation, | // Ensure correct implementation, | ||||
// but don't let container manage caption etc. | // but don't let container manage caption etc. | ||||
if (client.updateComponent(this, uidl, false)) { | |||||
super.updateFromUIDL(uidl, client); | |||||
if (!isRealUpdate(uidl)) { | |||||
return; | return; | ||||
} | } | ||||
public class VCheckBoxPaintable extends VAbstractPaintableWidget { | public class VCheckBoxPaintable extends VAbstractPaintableWidget { | ||||
@Override | |||||
protected boolean delegateCaptionHandling() { | |||||
return false; | |||||
} | |||||
@Override | |||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
// Save details | // Save details | ||||
getWidgetForPaintable().client = client; | getWidgetForPaintable().client = client; | ||||
getWidgetForPaintable().id = uidl.getId(); | getWidgetForPaintable().id = uidl.getId(); | ||||
// Ensure correct implementation | // Ensure correct implementation | ||||
if (client.updateComponent(this, uidl, false)) { | |||||
super.updateFromUIDL(uidl, client); | |||||
if (!isRealUpdate(uidl)) { | |||||
return; | return; | ||||
} | } | ||||
} | } | ||||
}; | }; | ||||
@Override | |||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
getWidgetForPaintable().rendering = true; | getWidgetForPaintable().rendering = true; | ||||
if (client.updateComponent(this, uidl, true)) { | |||||
super.updateFromUIDL(uidl, client); | |||||
if (!isRealUpdate(uidl)) { | |||||
getWidgetForPaintable().rendering = false; | getWidgetForPaintable().rendering = false; | ||||
return; | return; | ||||
} | } |
public class VCustomComponentPaintable extends | public class VCustomComponentPaintable extends | ||||
VAbstractPaintableWidgetContainer { | VAbstractPaintableWidgetContainer { | ||||
@Override | |||||
public void updateFromUIDL(UIDL uidl, final ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, final ApplicationConnection client) { | ||||
getWidgetForPaintable().rendering = true; | getWidgetForPaintable().rendering = true; | ||||
if (client.updateComponent(this, uidl, true)) { | |||||
super.updateFromUIDL(uidl, client); | |||||
if (!isRealUpdate(uidl)) { | |||||
getWidgetForPaintable().rendering = false; | getWidgetForPaintable().rendering = false; | ||||
return; | return; | ||||
} | } |
public class VCustomLayoutPaintable extends VAbstractPaintableWidgetContainer { | public class VCustomLayoutPaintable extends VAbstractPaintableWidgetContainer { | ||||
/** Update the layout from UIDL */ | /** Update the layout from UIDL */ | ||||
@Override | |||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
getWidgetForPaintable().client = client; | getWidgetForPaintable().client = client; | ||||
// ApplicationConnection manages generic component features | // ApplicationConnection manages generic component features | ||||
if (client.updateComponent(this, uidl, true)) { | |||||
super.updateFromUIDL(uidl, client); | |||||
if (!isRealUpdate(uidl)) { | |||||
return; | return; | ||||
} | } | ||||
public class VDateFieldPaintable extends VAbstractPaintableWidget { | public class VDateFieldPaintable extends VAbstractPaintableWidget { | ||||
@Override | |||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
// Ensure correct implementation and let layout manage caption | // Ensure correct implementation and let layout manage caption | ||||
if (client.updateComponent(this, uidl, true)) { | |||||
super.updateFromUIDL(uidl, client); | |||||
if (!isRealUpdate(uidl)) { | |||||
return; | return; | ||||
} | } | ||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
getWidgetForPaintable().client = client; | getWidgetForPaintable().client = client; | ||||
super.updateFromUIDL(uidl, client); | super.updateFromUIDL(uidl, client); | ||||
if (!uidl.hasAttribute("cached") && !uidl.hasAttribute("hidden")) { | |||||
if (isRealUpdate(uidl) && !uidl.hasAttribute("hidden")) { | |||||
UIDL acceptCrit = uidl.getChildByTagName("-ac"); | UIDL acceptCrit = uidl.getChildByTagName("-ac"); | ||||
if (acceptCrit == null) { | if (acceptCrit == null) { | ||||
getWidgetForPaintable().dropHandler = null; | getWidgetForPaintable().dropHandler = null; |
public static final String CLICK_EVENT_IDENTIFIER = "click"; | public static final String CLICK_EVENT_IDENTIFIER = "click"; | ||||
@Override | |||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
if (client.updateComponent(this, uidl, true)) { | |||||
super.updateFromUIDL(uidl, client); | |||||
if (!isRealUpdate(uidl)) { | |||||
return; | return; | ||||
} | } | ||||
* com.vaadin.terminal.gwt.client.Paintable#updateFromUIDL(com.vaadin.terminal | * com.vaadin.terminal.gwt.client.Paintable#updateFromUIDL(com.vaadin.terminal | ||||
* .gwt.client.UIDL, com.vaadin.terminal.gwt.client.ApplicationConnection) | * .gwt.client.UIDL, com.vaadin.terminal.gwt.client.ApplicationConnection) | ||||
*/ | */ | ||||
@Override | |||||
@SuppressWarnings("deprecation") | @SuppressWarnings("deprecation") | ||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
// Save details | // Save details | ||||
getWidgetForPaintable().tb.setEnabled(getWidgetForPaintable().enabled); | getWidgetForPaintable().tb.setEnabled(getWidgetForPaintable().enabled); | ||||
getWidgetForPaintable().updateReadOnly(); | getWidgetForPaintable().updateReadOnly(); | ||||
if (client.updateComponent(this, uidl, true)) { | |||||
super.updateFromUIDL(uidl, client); | |||||
if (!isRealUpdate(uidl)) { | |||||
return; | return; | ||||
} | } | ||||
import com.vaadin.terminal.gwt.client.VPaintableWidget; | import com.vaadin.terminal.gwt.client.VPaintableWidget; | ||||
public class VFormLayoutPaintable extends VAbstractPaintableWidgetContainer { | public class VFormLayoutPaintable extends VAbstractPaintableWidgetContainer { | ||||
@Override | |||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
getWidgetForPaintable().rendering = true; | getWidgetForPaintable().rendering = true; | ||||
getWidgetForPaintable().client = client; | getWidgetForPaintable().client = client; | ||||
if (client.updateComponent(this, uidl, true)) { | |||||
super.updateFromUIDL(uidl, client); | |||||
if (!isRealUpdate(uidl)) { | |||||
getWidgetForPaintable().rendering = false; | getWidgetForPaintable().rendering = false; | ||||
return; | return; | ||||
} | } |
public class VFormPaintable extends VAbstractPaintableWidgetContainer { | public class VFormPaintable extends VAbstractPaintableWidgetContainer { | ||||
@Override | |||||
protected boolean delegateCaptionHandling() { | |||||
return false; | |||||
} | |||||
@Override | |||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
getWidgetForPaintable().rendering = true; | getWidgetForPaintable().rendering = true; | ||||
getWidgetForPaintable().client = client; | getWidgetForPaintable().client = client; | ||||
getWidgetForPaintable().id = uidl.getId(); | getWidgetForPaintable().id = uidl.getId(); | ||||
if (client.updateComponent(this, uidl, false)) { | |||||
super.updateFromUIDL(uidl, client); | |||||
if (!isRealUpdate(uidl)) { | |||||
getWidgetForPaintable().rendering = false; | getWidgetForPaintable().rendering = false; | ||||
return; | return; | ||||
} | } |
} | } | ||||
}; | }; | ||||
@Override | |||||
@SuppressWarnings("unchecked") | @SuppressWarnings("unchecked") | ||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
getWidgetForPaintable().rendering = true; | getWidgetForPaintable().rendering = true; | ||||
getWidgetForPaintable().client = client; | getWidgetForPaintable().client = client; | ||||
if (client.updateComponent(this, uidl, true)) { | |||||
super.updateFromUIDL(uidl, client); | |||||
if (!isRealUpdate(uidl)) { | |||||
getWidgetForPaintable().rendering = false; | getWidgetForPaintable().rendering = false; | ||||
return; | return; | ||||
} | } |
public class VLinkPaintable extends VAbstractPaintableWidget { | public class VLinkPaintable extends VAbstractPaintableWidget { | ||||
@Override | |||||
protected boolean delegateCaptionHandling() { | |||||
return false; | |||||
} | |||||
@Override | |||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
// Ensure correct implementation, | // Ensure correct implementation, | ||||
// but don't let container manage caption etc. | // but don't let container manage caption etc. | ||||
if (client.updateComponent(this, uidl, false)) { | |||||
super.updateFromUIDL(uidl, client); | |||||
if (!isRealUpdate(uidl)) { | |||||
return; | return; | ||||
} | } | ||||
public static final String ATTR_HTML = "html"; | public static final String ATTR_HTML = "html"; | ||||
public static final String ATTR_ALT_TEXT = "alt"; | public static final String ATTR_ALT_TEXT = "alt"; | ||||
@Override | |||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
if (client.updateComponent(this, uidl, true)) { | |||||
super.updateFromUIDL(uidl, client); | |||||
if (!isRealUpdate(uidl)) { | |||||
return; | return; | ||||
} | } | ||||
* This method is called when the page is loaded for the first time, and | * This method is called when the page is loaded for the first time, and | ||||
* every time UI changes in the component are received from the server. | * every time UI changes in the component are received from the server. | ||||
*/ | */ | ||||
@Override | |||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
// This call should be made first. Ensure correct implementation, | // This call should be made first. Ensure correct implementation, | ||||
// and let the containing layout manage caption, etc. | // and let the containing layout manage caption, etc. | ||||
if (client.updateComponent(this, uidl, true)) { | |||||
super.updateFromUIDL(uidl, client); | |||||
if (!isRealUpdate(uidl)) { | |||||
return; | return; | ||||
} | } | ||||
public class VNativeButtonPaintable extends VAbstractPaintableWidget { | public class VNativeButtonPaintable extends VAbstractPaintableWidget { | ||||
@Override | |||||
protected boolean delegateCaptionHandling() { | |||||
return false; | |||||
} | |||||
@Override | |||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
// Ensure correct implementation, | // Ensure correct implementation, | ||||
// but don't let container manage caption etc. | // but don't let container manage caption etc. | ||||
if (client.updateComponent(this, uidl, false)) { | |||||
super.updateFromUIDL(uidl, client); | |||||
if (!isRealUpdate(uidl)) { | |||||
return; | return; | ||||
} | } | ||||
public abstract class VOptionGroupBasePaintable extends | public abstract class VOptionGroupBasePaintable extends | ||||
VAbstractPaintableWidget { | VAbstractPaintableWidget { | ||||
@Override | |||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
// Save details | // Save details | ||||
getWidgetForPaintable().client = client; | getWidgetForPaintable().client = client; | ||||
getWidgetForPaintable().paintableId = uidl.getId(); | getWidgetForPaintable().paintableId = uidl.getId(); | ||||
if (client.updateComponent(this, uidl, true)) { | |||||
super.updateFromUIDL(uidl, client); | |||||
if (!isRealUpdate(uidl)) { | |||||
return; | return; | ||||
} | } | ||||
super.updateFromUIDL(uidl, client); | super.updateFromUIDL(uidl, client); | ||||
// Only non-cached, visible UIDL:s can introduce changes | // Only non-cached, visible UIDL:s can introduce changes | ||||
if (uidl.getBooleanAttribute("cached") | |||||
|| uidl.getBooleanAttribute("invisible")) { | |||||
if (!isRealUpdate(uidl) || uidl.getBooleanAttribute("invisible")) { | |||||
getWidgetForPaintable().isRendering = false; | getWidgetForPaintable().isRendering = false; | ||||
return; | return; | ||||
} | } | ||||
* the layout are rendered later when it is clear how much space | * the layout are rendered later when it is clear how much space | ||||
* they can use | * they can use | ||||
*/ | */ | ||||
if (!Util.isCached(childUIDL)) { | |||||
if (isRealUpdate(childUIDL)) { | |||||
FloatSize relativeSize = Util.parseRelativeSize(childUIDL); | FloatSize relativeSize = Util.parseRelativeSize(childUIDL); | ||||
childComponentContainer.setRelativeSize(relativeSize); | childComponentContainer.setRelativeSize(relativeSize); | ||||
} | } | ||||
.getWidth()); | .getWidth()); | ||||
} | } | ||||
if (getWidgetForPaintable().sizeHasChangedDuringRendering | if (getWidgetForPaintable().sizeHasChangedDuringRendering | ||||
&& Util.isCached(childUIDL)) { | |||||
&& !isRealUpdate(childUIDL)) { | |||||
// notify cached relative sized component about size | // notify cached relative sized component about size | ||||
// chance | // chance | ||||
client.handleComponentRelativeSize(childComponentContainer | client.handleComponentRelativeSize(childComponentContainer | ||||
getWidgetForPaintable().activeLayoutSize.getWidth()); | getWidgetForPaintable().activeLayoutSize.getWidth()); | ||||
} | } | ||||
if (Util.isCached(childUIDL)) { | |||||
if (!isRealUpdate(childUIDL)) { | |||||
/* | /* | ||||
* We must update the size of the relative sized component if | * We must update the size of the relative sized component if | ||||
* the expand ratio or something else in the layout changes | * the expand ratio or something else in the layout changes |
} | } | ||||
}; | }; | ||||
@Override | |||||
protected boolean delegateCaptionHandling() { | |||||
return false; | |||||
}; | |||||
@Override | |||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
getWidgetForPaintable().rendering = true; | getWidgetForPaintable().rendering = true; | ||||
if (!uidl.hasAttribute("cached")) { | |||||
if (isRealUpdate(uidl)) { | |||||
// Handle caption displaying and style names, prior generics. | // Handle caption displaying and style names, prior generics. | ||||
// Affects size | |||||
// calculations | |||||
// Affects size calculations | |||||
// Restore default stylenames | // Restore default stylenames | ||||
getWidgetForPaintable().contentNode.setClassName(VPanel.CLASSNAME | getWidgetForPaintable().contentNode.setClassName(VPanel.CLASSNAME | ||||
} | } | ||||
} | } | ||||
// Ensure correct implementation | // Ensure correct implementation | ||||
if (client.updateComponent(this, uidl, false)) { | |||||
super.updateFromUIDL(uidl, client); | |||||
if (!isRealUpdate(uidl)) { | |||||
getWidgetForPaintable().rendering = false; | getWidgetForPaintable().rendering = false; | ||||
return; | return; | ||||
} | } |
super.updateFromUIDL(uidl, client); | super.updateFromUIDL(uidl, client); | ||||
String popupStyleNames = ApplicationConnection.getStyleName( | |||||
String popupStyleNames = getStyleNameFromUIDL( | |||||
VPopupCalendar.POPUP_PRIMARY_STYLE_NAME, uidl, false); | VPopupCalendar.POPUP_PRIMARY_STYLE_NAME, uidl, false); | ||||
popupStyleNames += " " | popupStyleNames += " " | ||||
+ VDateField.CLASSNAME | + VDateField.CLASSNAME |
public class VPopupViewPaintable extends VAbstractPaintableWidgetContainer { | public class VPopupViewPaintable extends VAbstractPaintableWidgetContainer { | ||||
@Override | |||||
protected boolean delegateCaptionHandling() { | |||||
return false; | |||||
} | |||||
/** | /** | ||||
* | * | ||||
* | * | ||||
* @see com.vaadin.terminal.gwt.client.VPaintableWidget#updateFromUIDL(com.vaadin.terminal.gwt.client.UIDL, | * @see com.vaadin.terminal.gwt.client.VPaintableWidget#updateFromUIDL(com.vaadin.terminal.gwt.client.UIDL, | ||||
* com.vaadin.terminal.gwt.client.ApplicationConnection) | * com.vaadin.terminal.gwt.client.ApplicationConnection) | ||||
*/ | */ | ||||
@Override | |||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
// This call should be made first. Ensure correct implementation, | // This call should be made first. Ensure correct implementation, | ||||
// and don't let the containing layout manage caption. | // and don't let the containing layout manage caption. | ||||
if (client.updateComponent(this, uidl, false)) { | |||||
super.updateFromUIDL(uidl, client); | |||||
if (!isRealUpdate(uidl)) { | |||||
return; | return; | ||||
} | } | ||||
// These are for future server connections | // These are for future server connections |
public class VProgressIndicatorPaintable extends VAbstractPaintableWidget { | public class VProgressIndicatorPaintable extends VAbstractPaintableWidget { | ||||
@Override | |||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
// Ensure correct implementation, | // Ensure correct implementation, | ||||
// but don't let container manage caption etc. | // but don't let container manage caption etc. | ||||
if (client.updateComponent(this, uidl, false)) { | |||||
super.updateFromUIDL(uidl, client); | |||||
if (!isRealUpdate(uidl)) { | |||||
return; | return; | ||||
} | } | ||||
* com.vaadin.terminal.gwt.client.Paintable#updateFromUIDL(com.vaadin.terminal | * com.vaadin.terminal.gwt.client.Paintable#updateFromUIDL(com.vaadin.terminal | ||||
* .gwt.client.UIDL, com.vaadin.terminal.gwt.client.ApplicationConnection) | * .gwt.client.UIDL, com.vaadin.terminal.gwt.client.ApplicationConnection) | ||||
*/ | */ | ||||
@Override | |||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
getWidgetForPaintable().rendering = true; | getWidgetForPaintable().rendering = true; | ||||
getWidgetForPaintable().tFoot | getWidgetForPaintable().tFoot | ||||
.setVisible(getWidgetForPaintable().showColFooters); | .setVisible(getWidgetForPaintable().showColFooters); | ||||
if (client.updateComponent(this, uidl, true)) { | |||||
super.updateFromUIDL(uidl, client); | |||||
if (!isRealUpdate(uidl)) { | |||||
getWidgetForPaintable().rendering = false; | getWidgetForPaintable().rendering = false; | ||||
return; | return; | ||||
} | } |
public class VSliderPaintable extends VAbstractPaintableWidget { | public class VSliderPaintable extends VAbstractPaintableWidget { | ||||
@Override | |||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
getWidgetForPaintable().client = client; | getWidgetForPaintable().client = client; | ||||
getWidgetForPaintable().id = uidl.getId(); | getWidgetForPaintable().id = uidl.getId(); | ||||
// Ensure correct implementation | // Ensure correct implementation | ||||
if (client.updateComponent(this, uidl, true)) { | |||||
super.updateFromUIDL(uidl, client); | |||||
if (!isRealUpdate(uidl)) { | |||||
return; | return; | ||||
} | } | ||||
protected boolean disabled; | protected boolean disabled; | ||||
protected boolean readonly; | protected boolean readonly; | ||||
protected Set<String> disabledTabKeys = new HashSet<String>(); | protected Set<String> disabledTabKeys = new HashSet<String>(); | ||||
protected boolean cachedUpdate = false; | |||||
public VTabsheetBase(String classname) { | public VTabsheetBase(String classname) { | ||||
setElement(DOM.createDiv()); | setElement(DOM.createDiv()); |
public abstract class VTabsheetBasePaintable extends | public abstract class VTabsheetBasePaintable extends | ||||
VAbstractPaintableWidgetContainer { | VAbstractPaintableWidgetContainer { | ||||
@Override | |||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
getWidgetForPaintable().client = client; | getWidgetForPaintable().client = client; | ||||
// Ensure correct implementation | // Ensure correct implementation | ||||
getWidgetForPaintable().cachedUpdate = client.updateComponent(this, | |||||
uidl, true); | |||||
if (getWidgetForPaintable().cachedUpdate) { | |||||
super.updateFromUIDL(uidl, client); | |||||
if (!isRealUpdate(uidl)) { | |||||
return; | return; | ||||
} | } | ||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
getWidgetForPaintable().rendering = true; | getWidgetForPaintable().rendering = true; | ||||
if (!uidl.getBooleanAttribute("cached")) { | |||||
if (isRealUpdate(uidl)) { | |||||
// Handle stylename changes before generics (might affect size | // Handle stylename changes before generics (might affect size | ||||
// calculations) | // calculations) | ||||
getWidgetForPaintable().handleStyleNames(uidl); | getWidgetForPaintable().handleStyleNames(uidl); | ||||
} | } | ||||
super.updateFromUIDL(uidl, client); | super.updateFromUIDL(uidl, client); | ||||
if (getWidgetForPaintable().cachedUpdate) { | |||||
if (!isRealUpdate(uidl)) { | |||||
getWidgetForPaintable().rendering = false; | getWidgetForPaintable().rendering = false; | ||||
return; | return; | ||||
} | } |
public class VTextFieldPaintable extends VAbstractPaintableWidget implements | public class VTextFieldPaintable extends VAbstractPaintableWidget implements | ||||
BeforeShortcutActionListener { | BeforeShortcutActionListener { | ||||
@Override | |||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
// Save details | // Save details | ||||
getWidgetForPaintable().client = client; | getWidgetForPaintable().client = client; | ||||
getWidgetForPaintable().paintableId = uidl.getId(); | getWidgetForPaintable().paintableId = uidl.getId(); | ||||
if (client.updateComponent(this, uidl, true)) { | |||||
super.updateFromUIDL(uidl, client); | |||||
if (!isRealUpdate(uidl)) { | |||||
return; | return; | ||||
} | } | ||||
public class VTreePaintable extends VAbstractPaintableWidget { | public class VTreePaintable extends VAbstractPaintableWidget { | ||||
@Override | |||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
// Ensure correct implementation and let container manage caption | // Ensure correct implementation and let container manage caption | ||||
if (client.updateComponent(this, uidl, true)) { | |||||
super.updateFromUIDL(uidl, client); | |||||
if (!isRealUpdate(uidl)) { | |||||
return; | return; | ||||
} | } | ||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
// Captions are updated before super call to ensure the widths are set | // Captions are updated before super call to ensure the widths are set | ||||
// correctly | // correctly | ||||
if (!uidl.getBooleanAttribute("cached")) { | |||||
if (isRealUpdate(uidl)) { | |||||
getWidgetForPaintable().updateCaptions(uidl); | getWidgetForPaintable().updateCaptions(uidl); | ||||
} | } | ||||
public class VUnknownComponentPaintable extends VAbstractPaintableWidget { | public class VUnknownComponentPaintable extends VAbstractPaintableWidget { | ||||
@Override | |||||
protected boolean delegateCaptionHandling() { | |||||
return false; | |||||
} | |||||
@Override | |||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
if (client.updateComponent(this, uidl, false)) { | |||||
super.updateFromUIDL(uidl, client); | |||||
if (!isRealUpdate(uidl)) { | |||||
return; | return; | ||||
} | } | ||||
getWidgetForPaintable().setCaption( | getWidgetForPaintable().setCaption( |
public class VUploadPaintable extends VAbstractPaintableWidget { | public class VUploadPaintable extends VAbstractPaintableWidget { | ||||
@Override | |||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
if (client.updateComponent(this, uidl, true)) { | |||||
super.updateFromUIDL(uidl, client); | |||||
if (!isRealUpdate(uidl)) { | |||||
return; | return; | ||||
} | } | ||||
if (uidl.hasAttribute("notStarted")) { | if (uidl.hasAttribute("notStarted")) { |
@Override | @Override | ||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
if (client.updateComponent(this, uidl, true)) { | |||||
super.updateFromUIDL(uidl, client); | |||||
if (!isRealUpdate(uidl)) { | |||||
return; | return; | ||||
} | } | ||||
super.updateFromUIDL(uidl, client); | super.updateFromUIDL(uidl, client); |
private static final String CLICK_EVENT_IDENTIFIER = VPanelPaintable.CLICK_EVENT_IDENTIFIER; | private static final String CLICK_EVENT_IDENTIFIER = VPanelPaintable.CLICK_EVENT_IDENTIFIER; | ||||
@Override | |||||
public void updateFromUIDL(final UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(final UIDL uidl, ApplicationConnection client) { | ||||
getWidgetForPaintable().rendering = true; | getWidgetForPaintable().rendering = true; | ||||
// As VView is not created in the same way as all other paintables we | // As VView is not created in the same way as all other paintables we | ||||
} | } | ||||
getWidgetForPaintable().layout.updateFromUIDL(childUidl, client); | getWidgetForPaintable().layout.updateFromUIDL(childUidl, client); | ||||
if (!childUidl.getBooleanAttribute("cached")) { | |||||
if (isRealUpdate(childUidl)) { | |||||
getWidgetForPaintable().updateParentFrameSize(); | getWidgetForPaintable().updateParentFrameSize(); | ||||
} | } | ||||
} | } | ||||
}; | }; | ||||
@Override | |||||
protected boolean delegateCaptionHandling() { | |||||
return false; | |||||
}; | |||||
@Override | |||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
getWidgetForPaintable().id = uidl.getId(); | getWidgetForPaintable().id = uidl.getId(); | ||||
getWidgetForPaintable().client = client; | getWidgetForPaintable().client = client; | ||||
return; | return; | ||||
} | } | ||||
if (!uidl.hasAttribute("cached")) { | |||||
if (isRealUpdate(uidl)) { | |||||
if (uidl.getBooleanAttribute("modal") != getWidgetForPaintable().vaadinModality) { | if (uidl.getBooleanAttribute("modal") != getWidgetForPaintable().vaadinModality) { | ||||
getWidgetForPaintable().setVaadinModality( | getWidgetForPaintable().setVaadinModality( | ||||
!getWidgetForPaintable().vaadinModality); | !getWidgetForPaintable().vaadinModality); | ||||
} | } | ||||
getWidgetForPaintable().visibilityChangesDisabled = true; | getWidgetForPaintable().visibilityChangesDisabled = true; | ||||
if (client.updateComponent(this, uidl, false)) { | |||||
super.updateFromUIDL(uidl, client); | |||||
if (!isRealUpdate(uidl)) { | |||||
return; | return; | ||||
} | } | ||||
getWidgetForPaintable().visibilityChangesDisabled = false; | getWidgetForPaintable().visibilityChangesDisabled = false; |
public VLabelPaintable() { | public VLabelPaintable() { | ||||
} | } | ||||
@Override | |||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
if (client.updateComponent(this, uidl, true)) { | |||||
super.updateFromUIDL(uidl, client); | |||||
if (!isRealUpdate(uidl)) { | |||||
return; | return; | ||||
} | } | ||||
public abstract class CellBasedLayoutPaintable extends | public abstract class CellBasedLayoutPaintable extends | ||||
VAbstractPaintableWidgetContainer { | VAbstractPaintableWidgetContainer { | ||||
@Override | |||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
getWidgetForPaintable().client = client; | getWidgetForPaintable().client = client; | ||||
// Only non-cached UIDL:s can introduce changes | // Only non-cached UIDL:s can introduce changes | ||||
if (uidl.getBooleanAttribute("cached")) { | |||||
if (isCachedUpdate(uidl)) { | |||||
return; | return; | ||||
} | } | ||||
* This call should be made first. Ensure correct implementation, handle | * This call should be made first. Ensure correct implementation, handle | ||||
* size etc. | * size etc. | ||||
*/ | */ | ||||
if (client.updateComponent(this, uidl, true)) { | |||||
return; | |||||
} | |||||
super.updateFromUIDL(uidl, client); | |||||
handleDynamicDimensions(uidl); | handleDynamicDimensions(uidl); | ||||
} | } |
public class VRichTextAreaPaintable extends VAbstractPaintableWidget implements | public class VRichTextAreaPaintable extends VAbstractPaintableWidget implements | ||||
BeforeShortcutActionListener { | BeforeShortcutActionListener { | ||||
@Override | |||||
public void updateFromUIDL(final UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(final UIDL uidl, ApplicationConnection client) { | ||||
getWidgetForPaintable().client = client; | getWidgetForPaintable().client = client; | ||||
getWidgetForPaintable().id = uidl.getId(); | getWidgetForPaintable().id = uidl.getId(); | ||||
.setHTML(getWidgetForPaintable().currentValue); | .setHTML(getWidgetForPaintable().currentValue); | ||||
} | } | ||||
} | } | ||||
if (!uidl.hasAttribute("cached")) { | |||||
if (isRealUpdate(uidl)) { | |||||
getWidgetForPaintable().setEnabled( | getWidgetForPaintable().setEnabled( | ||||
!uidl.getBooleanAttribute("disabled")); | !uidl.getBooleanAttribute("disabled")); | ||||
} | } | ||||
if (client.updateComponent(this, uidl, true)) { | |||||
super.updateFromUIDL(uidl, client); | |||||
if (!isRealUpdate(uidl)) { | |||||
return; | return; | ||||
} | } | ||||
public class VMyDragSourcePaintable extends VAbstractPaintableWidget { | public class VMyDragSourcePaintable extends VAbstractPaintableWidget { | ||||
@Override | |||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
if (client.updateComponent(this, uidl, true)) { | |||||
super.updateFromUIDL(uidl, client); | |||||
if (!isRealUpdate(uidl)) { | |||||
return; | return; | ||||
} | } | ||||
} | } |
public class VMyDropTargetPaintable extends VAbstractPaintableWidget { | public class VMyDropTargetPaintable extends VAbstractPaintableWidget { | ||||
@Override | |||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | ||||
if (client.updateComponent(this, uidl, true)) { | |||||
super.updateFromUIDL(uidl, client); | |||||
if (!isRealUpdate(uidl)) { | |||||
return; | return; | ||||
} | } | ||||
getWidgetForPaintable().client = client; | getWidgetForPaintable().client = client; |