Object value = parameters[1];
// TODO paintables inside lists/maps get rendered as
// components in the debug console
- String formattedValue = value instanceof Paintable ? c
- .getPid((Paintable) value) : String.valueOf(value);
+ String formattedValue = value instanceof VPaintable ? c
+ .getPaintableMap().getPid((VPaintable) value)
+ : String.valueOf(value);
formattedParams = parameters[0] + " : " + formattedValue;
}
if (null == formattedParams) {
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.json.client.JSONValue;
-import com.vaadin.terminal.gwt.client.Paintable;
+import com.vaadin.terminal.gwt.client.VPaintable;
+import com.vaadin.terminal.gwt.client.VPaintableMap;
/**
* Encoder for converting RPC parameters and other values to JSON for transfer
*
* @param value
* value to convert
- * @param paintableMapper
+ * @param paintableMap
* mapper from paintables to paintable IDs
* @return JSON representation of the value
*/
- public static JSONValue encode(Object value,
- PaintableIdMapper paintableMapper) {
- char type = getTransportType(value);
- Object encodedValue = null;
-
+ public static JSONValue encode(Object value, VPaintableMap paintableMap) {
if (null == value) {
// TODO as undefined type?
return combineTypeAndValue(VTYPE_UNDEFINED, JSONNull.getInstance());
JSONArray jsonArray = new JSONArray();
for (int i = 0; i < array.length; ++i) {
// TODO handle object graph loops?
- jsonArray.set(i, encode(array[i], paintableMapper));
+ jsonArray.set(i, encode(array[i], paintableMap));
}
return combineTypeAndValue(VTYPE_ARRAY, jsonArray);
} else if (value instanceof Map) {
for (String mapKey : map.keySet()) {
// TODO handle object graph loops?
Object mapValue = map.get(mapKey);
- jsonMap.put(mapKey, encode(mapValue, paintableMapper));
+ jsonMap.put(mapKey, encode(mapValue, paintableMap));
}
return combineTypeAndValue(VTYPE_MAP, jsonMap);
- } else if (value instanceof Paintable) {
- Paintable paintable = (Paintable) value;
+ } else if (value instanceof VPaintable) {
+ VPaintable paintable = (VPaintable) value;
return combineTypeAndValue(VTYPE_PAINTABLE, new JSONString(
- paintableMapper.getPid(paintable)));
+ paintableMap.getPid(paintable)));
} else {
return combineTypeAndValue(getTransportType(value), new JSONString(
String.valueOf(value)));
private static char getTransportType(Object value) {
if (value instanceof String) {
return VTYPE_STRING;
- } else if (value instanceof Paintable) {
+ } else if (value instanceof VPaintable) {
return VTYPE_PAINTABLE;
} else if (value instanceof Boolean) {
return VTYPE_BOOLEAN;