@@ -16,6 +16,8 @@ import com.vaadin.terminal.gwt.client.communication.SharedState; | |||
public class ComponentState extends SharedState { | |||
private String height = ""; | |||
private String width = ""; | |||
private boolean readOnly = false; | |||
private boolean immediate = false; | |||
/** | |||
* Returns the component height as set by the server. | |||
@@ -93,7 +95,22 @@ public class ComponentState extends SharedState { | |||
return "".equals(getWidth()); | |||
} | |||
// TODO more fields to move here: style, readonly, immediate, disabled, | |||
// caption and description | |||
public boolean isReadOnly() { | |||
return readOnly; | |||
} | |||
public void setReadOnly(boolean readOnly) { | |||
this.readOnly = readOnly; | |||
} | |||
public boolean isImmediate() { | |||
return immediate; | |||
} | |||
public void setImmediate(boolean immediate) { | |||
this.immediate = immediate; | |||
} | |||
// TODO more fields to move here: style, disabled, caption and description | |||
} |
@@ -32,8 +32,6 @@ public abstract class VAbstractPaintableWidget implements VPaintableWidget { | |||
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"; | |||
@@ -211,7 +209,7 @@ public abstract class VAbstractPaintableWidget implements VPaintableWidget { | |||
// Style names | |||
String styleName = getStyleNameFromUIDL(getWidgetForPaintable() | |||
.getStylePrimaryName(), uidl, | |||
.getStylePrimaryName(), uidl, getState(), | |||
getWidgetForPaintable() instanceof Field); | |||
getWidgetForPaintable().setStyleName(styleName); | |||
@@ -308,17 +306,19 @@ public abstract class VAbstractPaintableWidget implements VPaintableWidget { | |||
/** | |||
* 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. | |||
* name (typically returned by Widget.getPrimaryStyleName()) and the UIDL | |||
* and shared state of the component. An additional "modified" style name | |||
* can be added if the field parameter is set to true. | |||
* | |||
* @param primaryStyleName | |||
* @param uidl | |||
* @param isField | |||
* @param state | |||
* component shared state | |||
* @param field | |||
* @return | |||
*/ | |||
protected static String getStyleNameFromUIDL(String primaryStyleName, | |||
UIDL uidl, boolean field) { | |||
UIDL uidl, ComponentState state, boolean field) { | |||
boolean enabled = !uidl.getBooleanAttribute(ATTRIBUTE_DISABLED); | |||
StringBuffer styleBuf = new StringBuffer(); | |||
@@ -329,7 +329,7 @@ public abstract class VAbstractPaintableWidget implements VPaintableWidget { | |||
styleBuf.append(" "); | |||
styleBuf.append(ApplicationConnection.DISABLED_CLASSNAME); | |||
} | |||
if (uidl.getBooleanAttribute(ATTRIBUTE_READONLY)) { | |||
if (state.isReadOnly()) { | |||
styleBuf.append(" "); | |||
styleBuf.append("v-readonly"); | |||
} |
@@ -70,8 +70,7 @@ public abstract class VAbstractSplitPanelPaintable extends | |||
getWidgetForPaintable().id = uidl.getId(); | |||
getWidgetForPaintable().rendering = true; | |||
getWidgetForPaintable().immediate = uidl | |||
.hasAttribute(ATTRIBUTE_IMMEDIATE); | |||
getWidgetForPaintable().immediate = getState().isImmediate(); | |||
super.updateFromUIDL(uidl, client); | |||
if (!isRealUpdate(uidl)) { |
@@ -62,7 +62,7 @@ public class VCheckBoxPaintable extends VAbstractPaintableWidget { | |||
"none"); | |||
} | |||
if (uidl.hasAttribute(ATTRIBUTE_READONLY)) { | |||
if (getState().isReadOnly()) { | |||
getWidgetForPaintable().setEnabled(false); | |||
} | |||
@@ -90,8 +90,7 @@ public class VCheckBoxPaintable extends VAbstractPaintableWidget { | |||
getWidgetForPaintable() | |||
.setValue( | |||
uidl.getBooleanVariable(getWidgetForPaintable().VARIABLE_STATE)); | |||
getWidgetForPaintable().immediate = uidl | |||
.getBooleanAttribute(VAbstractPaintableWidget.ATTRIBUTE_IMMEDIATE); | |||
getWidgetForPaintable().immediate = getState().isImmediate(); | |||
} | |||
@Override |
@@ -25,11 +25,9 @@ public class VDateFieldPaintable extends VAbstractPaintableWidget { | |||
// Save details | |||
getWidgetForPaintable().client = client; | |||
getWidgetForPaintable().paintableId = uidl.getId(); | |||
getWidgetForPaintable().immediate = uidl | |||
.getBooleanAttribute(ATTRIBUTE_IMMEDIATE); | |||
getWidgetForPaintable().immediate = getState().isImmediate(); | |||
getWidgetForPaintable().readonly = uidl | |||
.getBooleanAttribute(ATTRIBUTE_READONLY); | |||
getWidgetForPaintable().readonly = getState().isReadOnly(); | |||
getWidgetForPaintable().enabled = !uidl | |||
.getBooleanAttribute(ATTRIBUTE_DISABLED); | |||
@@ -28,8 +28,7 @@ public class VFilterSelectPaintable extends VAbstractPaintableWidget { | |||
getWidgetForPaintable().client = client; | |||
getWidgetForPaintable().paintableId = uidl.getId(); | |||
getWidgetForPaintable().readonly = uidl | |||
.hasAttribute(ATTRIBUTE_READONLY); | |||
getWidgetForPaintable().readonly = getState().isReadOnly(); | |||
getWidgetForPaintable().enabled = !uidl | |||
.hasAttribute(ATTRIBUTE_DISABLED); | |||
@@ -59,8 +58,7 @@ public class VFilterSelectPaintable extends VAbstractPaintableWidget { | |||
.getIntAttribute("filteringmode"); | |||
} | |||
getWidgetForPaintable().immediate = uidl | |||
.hasAttribute(ATTRIBUTE_IMMEDIATE); | |||
getWidgetForPaintable().immediate = getState().isImmediate(); | |||
getWidgetForPaintable().nullSelectionAllowed = uidl | |||
.hasAttribute("nullselect"); |
@@ -31,8 +31,7 @@ public class VLinkPaintable extends VAbstractPaintableWidget { | |||
getWidgetForPaintable().enabled = uidl.hasAttribute(ATTRIBUTE_DISABLED) ? false | |||
: true; | |||
getWidgetForPaintable().readonly = uidl | |||
.hasAttribute(ATTRIBUTE_READONLY) ? true : false; | |||
getWidgetForPaintable().readonly = getState().isReadOnly(); | |||
if (uidl.hasAttribute("name")) { | |||
getWidgetForPaintable().target = uidl.getStringAttribute("name"); |
@@ -25,14 +25,12 @@ public abstract class VOptionGroupBasePaintable extends | |||
getWidgetForPaintable().selectedKeys = uidl | |||
.getStringArrayVariableAsSet("selected"); | |||
getWidgetForPaintable().readonly = uidl | |||
.getBooleanAttribute(ATTRIBUTE_READONLY); | |||
getWidgetForPaintable().readonly = getState().isReadOnly(); | |||
getWidgetForPaintable().disabled = uidl | |||
.getBooleanAttribute(ATTRIBUTE_DISABLED); | |||
getWidgetForPaintable().multiselect = "multi".equals(uidl | |||
.getStringAttribute("selectmode")); | |||
getWidgetForPaintable().immediate = uidl | |||
.getBooleanAttribute(ATTRIBUTE_IMMEDIATE); | |||
getWidgetForPaintable().immediate = getState().isImmediate(); | |||
getWidgetForPaintable().nullSelectionAllowed = uidl | |||
.getBooleanAttribute("nullselect"); | |||
getWidgetForPaintable().nullSelectionItemAvailable = uidl |
@@ -35,7 +35,8 @@ public class VPopupCalendarPaintable extends VTextualDatePaintable { | |||
super.updateFromUIDL(uidl, client); | |||
String popupStyleNames = getStyleNameFromUIDL( | |||
VPopupCalendar.POPUP_PRIMARY_STYLE_NAME, uidl, false); | |||
VPopupCalendar.POPUP_PRIMARY_STYLE_NAME, uidl, getState(), | |||
false); | |||
popupStyleNames += " " | |||
+ VDateField.CLASSNAME | |||
+ "-" |
@@ -59,6 +59,7 @@ import com.google.gwt.user.client.ui.UIObject; | |||
import com.google.gwt.user.client.ui.Widget; | |||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | |||
import com.vaadin.terminal.gwt.client.BrowserInfo; | |||
import com.vaadin.terminal.gwt.client.ComponentState; | |||
import com.vaadin.terminal.gwt.client.Container; | |||
import com.vaadin.terminal.gwt.client.Focusable; | |||
import com.vaadin.terminal.gwt.client.MouseEventDetails; | |||
@@ -971,7 +972,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, | |||
} | |||
} | |||
void updateSelectionProperties(UIDL uidl) { | |||
void updateSelectionProperties(UIDL uidl, ComponentState state) { | |||
setMultiSelectMode(uidl.hasAttribute("multiselectmode") ? uidl | |||
.getIntAttribute("multiselectmode") : MULTISELECT_MODE_DEFAULT); | |||
@@ -979,7 +980,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, | |||
.getBooleanAttribute("nsa") : true; | |||
if (uidl.hasAttribute("selectmode")) { | |||
if (uidl.getBooleanAttribute(VAbstractPaintableWidget.ATTRIBUTE_READONLY)) { | |||
if (state.isReadOnly()) { | |||
selectMode = SelectMode.NONE; | |||
} else if (uidl.getStringAttribute("selectmode").equals("multi")) { | |||
selectMode = SelectMode.MULTI; |
@@ -72,8 +72,7 @@ public class VScrollTablePaintable extends VAbstractPaintableWidgetContainer { | |||
getWidgetForPaintable().client = client; | |||
getWidgetForPaintable().paintableId = uidl.getStringAttribute("id"); | |||
getWidgetForPaintable().immediate = uidl | |||
.getBooleanAttribute(ATTRIBUTE_IMMEDIATE); | |||
getWidgetForPaintable().immediate = getState().isImmediate(); | |||
int previousTotalRows = getWidgetForPaintable().totalRows; | |||
getWidgetForPaintable().updateTotalRows(uidl); | |||
@@ -81,7 +80,7 @@ public class VScrollTablePaintable extends VAbstractPaintableWidgetContainer { | |||
getWidgetForPaintable().updateDragMode(uidl); | |||
getWidgetForPaintable().updateSelectionProperties(uidl); | |||
getWidgetForPaintable().updateSelectionProperties(uidl, getState()); | |||
if (uidl.hasAttribute("alb")) { | |||
getWidgetForPaintable().bodyActionKeys = uidl |
@@ -24,15 +24,14 @@ public class VSliderPaintable extends VAbstractPaintableWidget { | |||
return; | |||
} | |||
getWidgetForPaintable().immediate = uidl | |||
.getBooleanAttribute(ATTRIBUTE_IMMEDIATE); | |||
getWidgetForPaintable().immediate = getState().isImmediate(); | |||
getWidgetForPaintable().disabled = uidl | |||
.getBooleanAttribute(ATTRIBUTE_DISABLED); | |||
getWidgetForPaintable().readonly = uidl | |||
.getBooleanAttribute(ATTRIBUTE_READONLY); | |||
getWidgetForPaintable().readonly = getState().isReadOnly(); | |||
getWidgetForPaintable().vertical = uidl.hasAttribute("vertical"); | |||
// TODO should these style names be used? | |||
String style = ""; | |||
if (uidl.hasAttribute(ATTRIBUTE_STYLE)) { | |||
style = uidl.getStringAttribute(ATTRIBUTE_STYLE); |
@@ -27,11 +27,7 @@ public class VTextFieldPaintable extends VAbstractPaintableWidget implements | |||
return; | |||
} | |||
if (uidl.getBooleanAttribute(ATTRIBUTE_READONLY)) { | |||
getWidgetForPaintable().setReadOnly(true); | |||
} else { | |||
getWidgetForPaintable().setReadOnly(false); | |||
} | |||
getWidgetForPaintable().setReadOnly(getState().isReadOnly()); | |||
getWidgetForPaintable().inputPrompt = uidl | |||
.getStringAttribute(VTextField.ATTR_INPUTPROMPT); | |||
@@ -40,8 +36,7 @@ public class VTextFieldPaintable extends VAbstractPaintableWidget implements | |||
uidl.hasAttribute("maxLength") ? uidl | |||
.getIntAttribute("maxLength") : -1); | |||
getWidgetForPaintable().immediate = uidl | |||
.getBooleanAttribute(ATTRIBUTE_IMMEDIATE); | |||
getWidgetForPaintable().immediate = getState().isImmediate(); | |||
getWidgetForPaintable().listenTextChangeEvents = client | |||
.hasEventListeners(this, "ie"); |
@@ -41,13 +41,11 @@ public class VTreePaintable extends VAbstractPaintableWidget { | |||
getWidgetForPaintable().paintableId = uidl.getId(); | |||
getWidgetForPaintable().immediate = uidl | |||
.hasAttribute(ATTRIBUTE_IMMEDIATE); | |||
getWidgetForPaintable().immediate = getState().isImmediate(); | |||
getWidgetForPaintable().disabled = uidl | |||
.getBooleanAttribute(ATTRIBUTE_DISABLED); | |||
getWidgetForPaintable().readonly = uidl | |||
.getBooleanAttribute(ATTRIBUTE_READONLY); | |||
getWidgetForPaintable().readonly = getState().isReadOnly(); | |||
getWidgetForPaintable().dragMode = uidl.hasAttribute("dragMode") ? uidl | |||
.getIntAttribute("dragMode") : 0; |
@@ -25,8 +25,7 @@ public class VUploadPaintable extends VAbstractPaintableWidget { | |||
getWidgetForPaintable().submit(); | |||
return; | |||
} | |||
getWidgetForPaintable().setImmediate( | |||
uidl.getBooleanAttribute(ATTRIBUTE_IMMEDIATE)); | |||
getWidgetForPaintable().setImmediate(getState().isImmediate()); | |||
getWidgetForPaintable().client = client; | |||
getWidgetForPaintable().paintableId = uidl.getId(); | |||
getWidgetForPaintable().nextUploadId = uidl.getIntAttribute("nextid"); | |||
@@ -43,8 +42,7 @@ public class VUploadPaintable extends VAbstractPaintableWidget { | |||
getWidgetForPaintable().fu.setName(getWidgetForPaintable().paintableId | |||
+ "_file"); | |||
if (uidl.hasAttribute(ATTRIBUTE_DISABLED) | |||
|| uidl.hasAttribute(ATTRIBUTE_READONLY)) { | |||
if (uidl.hasAttribute(ATTRIBUTE_DISABLED) || getState().isReadOnly()) { | |||
getWidgetForPaintable().disableUpload(); | |||
} else if (!uidl.getBooleanAttribute("state")) { | |||
// Enable the button only if an upload is not in progress |
@@ -41,8 +41,7 @@ public class VViewPaintable extends VAbstractPaintableWidgetContainer { | |||
boolean firstPaint = getWidgetForPaintable().connection == null; | |||
getWidgetForPaintable().connection = client; | |||
getWidgetForPaintable().immediate = uidl | |||
.hasAttribute(ATTRIBUTE_IMMEDIATE); | |||
getWidgetForPaintable().immediate = getState().isImmediate(); | |||
getWidgetForPaintable().resizeLazy = uidl | |||
.hasAttribute(VView.RESIZE_LAZY); | |||
String newTheme = uidl.getStringAttribute("theme"); |
@@ -90,11 +90,9 @@ public class VWindowPaintable extends VAbstractPaintableWidgetContainer | |||
clickEventHandler.handleEventHandlerRegistration(client); | |||
getWidgetForPaintable().immediate = uidl | |||
.hasAttribute(ATTRIBUTE_IMMEDIATE); | |||
getWidgetForPaintable().immediate = getState().isImmediate(); | |||
getWidgetForPaintable().setClosable( | |||
!uidl.getBooleanAttribute(ATTRIBUTE_READONLY)); | |||
getWidgetForPaintable().setClosable(!getState().isReadOnly()); | |||
// Initialize the position form UIDL | |||
int positionx = uidl.getIntVariable("positionx"); |
@@ -40,10 +40,8 @@ public class VRichTextAreaPaintable extends VAbstractPaintableWidget implements | |||
return; | |||
} | |||
getWidgetForPaintable().setReadOnly( | |||
uidl.getBooleanAttribute(ATTRIBUTE_READONLY)); | |||
getWidgetForPaintable().immediate = uidl | |||
.getBooleanAttribute(ATTRIBUTE_IMMEDIATE); | |||
getWidgetForPaintable().setReadOnly(getState().isReadOnly()); | |||
getWidgetForPaintable().immediate = getState().isImmediate(); | |||
int newMaxLength = uidl.hasAttribute("maxLength") ? uidl | |||
.getIntAttribute("maxLength") : -1; | |||
if (newMaxLength >= 0) { |
@@ -776,15 +776,6 @@ public abstract class AbstractComponent implements Component, MethodEventSource | |||
VAbstractPaintableWidget.ATTRIBUTE_STYLE, | |||
getStyle()); | |||
} | |||
if (isReadOnly()) { | |||
target.addAttribute( | |||
VAbstractPaintableWidget.ATTRIBUTE_READONLY, true); | |||
} | |||
if (isImmediate()) { | |||
target.addAttribute( | |||
VAbstractPaintableWidget.ATTRIBUTE_IMMEDIATE, true); | |||
} | |||
if (!isEnabled()) { | |||
target.addAttribute( | |||
VAbstractPaintableWidget.ATTRIBUTE_DISABLED, true); | |||
@@ -903,6 +894,9 @@ public abstract class AbstractComponent implements Component, MethodEventSource | |||
sharedState.setWidth("" + getCSSWidth()); | |||
} | |||
sharedState.setImmediate(isImmediate()); | |||
sharedState.setReadOnly(isReadOnly()); | |||
// if (getCaption() != null) { | |||
// state.put(ComponentState.STATE_CAPTION, getCaption()); | |||
// } | |||
@@ -912,13 +906,6 @@ public abstract class AbstractComponent implements Component, MethodEventSource | |||
// if (styles != null && styles.size() > 0) { | |||
// state.put(ComponentState.STATE_STYLE, getStyle()); | |||
// } | |||
// if (isReadOnly()) { | |||
// state.put(ComponentState.STATE_READONLY, true); | |||
// } | |||
// | |||
// if (isImmediate()) { | |||
// state.put(ComponentState.STATE_IMMEDIATE, true); | |||
// } | |||
// if (!isEnabled()) { | |||
// state.put(ComponentState.STATE_DISABLED, true); | |||
// } |