shared state and RPC callstags/7.0.0.alpha2
states.getJavaScriptObject(connectorId)); | states.getJavaScriptObject(connectorId)); | ||||
Object state = JsonDecoder.convertValue( | Object state = JsonDecoder.convertValue( | ||||
stateDataAndType, connectorMap); | |||||
stateDataAndType, connectorMap, | |||||
ApplicationConnection.this); | |||||
paintable.setState((SharedState) state); | paintable.setState((SharedState) state); | ||||
} | } | ||||
Object[] parameters = new Object[parametersJson.size()]; | Object[] parameters = new Object[parametersJson.size()]; | ||||
for (int j = 0; j < parametersJson.size(); ++j) { | for (int j = 0; j < parametersJson.size(); ++j) { | ||||
parameters[j] = JsonDecoder.convertValue( | parameters[j] = JsonDecoder.convertValue( | ||||
(JSONArray) parametersJson.get(j), getConnectorMap()); | |||||
(JSONArray) parametersJson.get(j), getConnectorMap(), this); | |||||
} | } | ||||
return new MethodInvocation(connectorId, interfaceName, methodName, | return new MethodInvocation(connectorId, interfaceName, methodName, | ||||
parameters); | parameters); | ||||
for (int i = 0; i < invocation.getParameters().length; ++i) { | for (int i = 0; i < invocation.getParameters().length; ++i) { | ||||
// TODO non-static encoder? type registration? | // TODO non-static encoder? type registration? | ||||
paramJson.set(i, JsonEncoder.encode( | paramJson.set(i, JsonEncoder.encode( | ||||
invocation.getParameters()[i], getConnectorMap())); | |||||
invocation.getParameters()[i], getConnectorMap(), | |||||
this)); | |||||
} | } | ||||
invocationJson.set(3, paramJson); | invocationJson.set(3, paramJson); | ||||
reqJson.set(reqJson.size(), invocationJson); | reqJson.set(reqJson.size(), invocationJson); |
package com.vaadin.terminal.gwt.client; | package com.vaadin.terminal.gwt.client; | ||||
import com.vaadin.terminal.gwt.client.communication.SharedState; | import com.vaadin.terminal.gwt.client.communication.SharedState; | ||||
import com.vaadin.terminal.gwt.client.communication.URLReference; | |||||
import com.vaadin.ui.Component; | import com.vaadin.ui.Component; | ||||
/** | /** | ||||
// string! | // string! | ||||
private String caption = null; | private String caption = null; | ||||
private boolean visible = true; | private boolean visible = true; | ||||
private URLReference icon = null; | |||||
/** | /** | ||||
* Returns the component height as set by the server. | * Returns the component height as set by the server. | ||||
this.visible = visible; | this.visible = visible; | ||||
} | } | ||||
public URLReference getIcon() { | |||||
return icon; | |||||
} | |||||
public void setIcon(URLReference icon) { | |||||
this.icon = icon; | |||||
} | |||||
} | } |
} | } | ||||
setStyleName(style); | setStyleName(style); | ||||
boolean hasIcon = uidl | |||||
.hasAttribute(AbstractComponentConnector.ATTRIBUTE_ICON); | |||||
boolean hasIcon = owner.getState().getIcon() != null; | |||||
boolean showRequired = uidl | boolean showRequired = uidl | ||||
.getBooleanAttribute(AbstractComponentConnector.ATTRIBUTE_REQUIRED); | .getBooleanAttribute(AbstractComponentConnector.ATTRIBUTE_REQUIRED); | ||||
boolean showError = uidl | boolean showError = uidl | ||||
// Icon forces the caption to be above the component | // Icon forces the caption to be above the component | ||||
placedAfterComponent = false; | placedAfterComponent = false; | ||||
icon.setUri(uidl | |||||
.getStringAttribute(AbstractComponentConnector.ATTRIBUTE_ICON)); | |||||
icon.setUri(owner.getState().getIcon().getURL()); | |||||
} else if (icon != null) { | } else if (icon != null) { | ||||
// Remove existing | // Remove existing | ||||
@Deprecated | @Deprecated | ||||
public boolean updateCaptionWithoutOwner(UIDL uidl, String caption, | public boolean updateCaptionWithoutOwner(UIDL uidl, String caption, | ||||
boolean disabled, boolean hasDescription) { | |||||
boolean disabled, boolean hasDescription, String iconURL) { | |||||
// TODO temporary method, needed because some tabsheet and accordion | // TODO temporary method, needed because some tabsheet and accordion | ||||
// internal captions do not have an owner or shared state. Simplified to | // internal captions do not have an owner or shared state. Simplified to | ||||
// only support those cases | // only support those cases | ||||
removeStyleDependentName("hasdescription"); | removeStyleDependentName("hasdescription"); | ||||
} | } | ||||
} | } | ||||
boolean hasIcon = uidl | |||||
.hasAttribute(AbstractComponentConnector.ATTRIBUTE_ICON); | |||||
boolean hasIcon = iconURL != null; | |||||
boolean showError = uidl | boolean showError = uidl | ||||
.hasAttribute(AbstractComponentConnector.ATTRIBUTE_ERROR) | .hasAttribute(AbstractComponentConnector.ATTRIBUTE_ERROR) | ||||
&& !uidl.getBooleanAttribute(AbstractComponentConnector.ATTRIBUTE_HIDEERRORS); | && !uidl.getBooleanAttribute(AbstractComponentConnector.ATTRIBUTE_HIDEERRORS); | ||||
// Icon forces the caption to be above the component | // Icon forces the caption to be above the component | ||||
placedAfterComponent = false; | placedAfterComponent = false; | ||||
icon.setUri(uidl | |||||
.getStringAttribute(AbstractComponentConnector.ATTRIBUTE_ICON)); | |||||
icon.setUri(iconURL); | |||||
} else if (icon != null) { | } else if (icon != null) { | ||||
// Remove existing | // Remove existing | ||||
if (uidl.hasAttribute(AbstractComponentConnector.ATTRIBUTE_ERROR)) { | if (uidl.hasAttribute(AbstractComponentConnector.ATTRIBUTE_ERROR)) { | ||||
return true; | return true; | ||||
} | } | ||||
if (uidl.hasAttribute(AbstractComponentConnector.ATTRIBUTE_ICON)) { | |||||
if (state.getIcon() != null) { | |||||
return true; | return true; | ||||
} | } | ||||
if (uidl.hasAttribute(AbstractComponentConnector.ATTRIBUTE_REQUIRED)) { | if (uidl.hasAttribute(AbstractComponentConnector.ATTRIBUTE_REQUIRED)) { |
package com.vaadin.terminal.gwt.client.communication; | package com.vaadin.terminal.gwt.client.communication; | ||||
import com.google.gwt.json.client.JSONObject; | import com.google.gwt.json.client.JSONObject; | ||||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | |||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | import com.vaadin.terminal.gwt.client.ConnectorMap; | ||||
import com.vaadin.terminal.gwt.server.JsonCodec; | import com.vaadin.terminal.gwt.server.JsonCodec; | ||||
* | * | ||||
* @since 7.0 | * @since 7.0 | ||||
*/ | */ | ||||
public interface JSONSerializer { | |||||
public interface JSONSerializer<T> { | |||||
/** | /** | ||||
* Creates and deserializes an object received from the server. Must be | * Creates and deserializes an object received from the server. Must be | ||||
* references to paintables | * references to paintables | ||||
* @return A deserialized object | * @return A deserialized object | ||||
*/ | */ | ||||
Object deserialize(JSONObject jsonValue, ConnectorMap idMapper); | |||||
T deserialize(JSONObject jsonValue, ConnectorMap idMapper, | |||||
ApplicationConnection connection); | |||||
/** | /** | ||||
* Serialize the given object into JSON. Must be compatible with | * Serialize the given object into JSON. Must be compatible with | ||||
* references to paintables | * references to paintables | ||||
* @return A JSON serialized version of the object | * @return A JSON serialized version of the object | ||||
*/ | */ | ||||
JSONObject serialize(Object value, ConnectorMap idMapper); | |||||
JSONObject serialize(T value, ConnectorMap idMapper, | |||||
ApplicationConnection connection); | |||||
} | } |
import com.google.gwt.json.client.JSONArray; | import com.google.gwt.json.client.JSONArray; | ||||
import com.google.gwt.json.client.JSONObject; | import com.google.gwt.json.client.JSONObject; | ||||
import com.google.gwt.json.client.JSONString; | import com.google.gwt.json.client.JSONString; | ||||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | |||||
import com.vaadin.terminal.gwt.client.Connector; | import com.vaadin.terminal.gwt.client.Connector; | ||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | import com.vaadin.terminal.gwt.client.ConnectorMap; | ||||
* JSON array with two elements | * JSON array with two elements | ||||
* @param idMapper | * @param idMapper | ||||
* mapper between connector ID and {@link Connector} objects | * mapper between connector ID and {@link Connector} objects | ||||
* @param connection | |||||
* reference to the current ApplicationConnection | |||||
* @return converted value (does not contain JSON types) | * @return converted value (does not contain JSON types) | ||||
*/ | */ | ||||
public static Object convertValue(JSONArray jsonArray, ConnectorMap idMapper) { | |||||
public static Object convertValue(JSONArray jsonArray, | |||||
ConnectorMap idMapper, ApplicationConnection connection) { | |||||
String type = ((JSONString) jsonArray.get(0)).stringValue(); | String type = ((JSONString) jsonArray.get(0)).stringValue(); | ||||
return convertValue(type, jsonArray.get(1), idMapper); | |||||
return convertValue(type, jsonArray.get(1), idMapper, connection); | |||||
} | } | ||||
private static Object convertValue(String variableType, Object value, | private static Object convertValue(String variableType, Object value, | ||||
ConnectorMap idMapper) { | |||||
ConnectorMap idMapper, ApplicationConnection connection) { | |||||
Object val = null; | Object val = null; | ||||
// TODO type checks etc. | // TODO type checks etc. | ||||
if (JsonEncoder.VTYPE_UNDEFINED.equals(variableType)) { | if (JsonEncoder.VTYPE_UNDEFINED.equals(variableType)) { | ||||
val = null; | val = null; | ||||
} else if (JsonEncoder.VTYPE_ARRAY.equals(variableType)) { | } else if (JsonEncoder.VTYPE_ARRAY.equals(variableType)) { | ||||
val = convertArray((JSONArray) value, idMapper); | |||||
val = convertArray((JSONArray) value, idMapper, connection); | |||||
} else if (JsonEncoder.VTYPE_MAP.equals(variableType)) { | } else if (JsonEncoder.VTYPE_MAP.equals(variableType)) { | ||||
val = convertMap((JSONObject) value, idMapper); | |||||
val = convertMap((JSONObject) value, idMapper, connection); | |||||
} else if (JsonEncoder.VTYPE_STRINGARRAY.equals(variableType)) { | } else if (JsonEncoder.VTYPE_STRINGARRAY.equals(variableType)) { | ||||
val = convertStringArray((JSONArray) value); | val = convertStringArray((JSONArray) value); | ||||
} else if (JsonEncoder.VTYPE_STRING.equals(variableType)) { | } else if (JsonEncoder.VTYPE_STRING.equals(variableType)) { | ||||
JSONSerializer serializer = serializerMap | JSONSerializer serializer = serializerMap | ||||
.getSerializer(variableType); | .getSerializer(variableType); | ||||
// TODO handle case with no serializer found | // TODO handle case with no serializer found | ||||
Object object = serializer | |||||
.deserialize((JSONObject) value, idMapper); | |||||
Object object = serializer.deserialize((JSONObject) value, | |||||
idMapper, connection); | |||||
return object; | return object; | ||||
} | } | ||||
} | } | ||||
private static Map<String, Object> convertMap(JSONObject jsonMap, | private static Map<String, Object> convertMap(JSONObject jsonMap, | ||||
ConnectorMap idMapper) { | |||||
ConnectorMap idMapper, ApplicationConnection connection) { | |||||
HashMap<String, Object> map = new HashMap<String, Object>(); | HashMap<String, Object> map = new HashMap<String, Object>(); | ||||
Iterator<String> it = jsonMap.keySet().iterator(); | Iterator<String> it = jsonMap.keySet().iterator(); | ||||
while (it.hasNext()) { | while (it.hasNext()) { | ||||
String key = it.next(); | String key = it.next(); | ||||
map.put(key, convertValue((JSONArray) jsonMap.get(key), idMapper)); | |||||
map.put(key, | |||||
convertValue((JSONArray) jsonMap.get(key), idMapper, | |||||
connection)); | |||||
} | } | ||||
return map; | return map; | ||||
} | } | ||||
} | } | ||||
private static Object[] convertArray(JSONArray jsonArray, | private static Object[] convertArray(JSONArray jsonArray, | ||||
ConnectorMap idMapper) { | |||||
ConnectorMap idMapper, ApplicationConnection connection) { | |||||
List<Object> tokens = new ArrayList<Object>(); | List<Object> tokens = new ArrayList<Object>(); | ||||
for (int i = 0; i < jsonArray.size(); ++i) { | for (int i = 0; i < jsonArray.size(); ++i) { | ||||
// each entry always has two elements: type and value | // each entry always has two elements: type and value | ||||
JSONArray entryArray = (JSONArray) jsonArray.get(i); | JSONArray entryArray = (JSONArray) jsonArray.get(i); | ||||
tokens.add(convertValue(entryArray, idMapper)); | |||||
tokens.add(convertValue(entryArray, idMapper, connection)); | |||||
} | } | ||||
return tokens.toArray(new Object[tokens.size()]); | return tokens.toArray(new Object[tokens.size()]); | ||||
} | } |
import com.google.gwt.json.client.JSONObject; | import com.google.gwt.json.client.JSONObject; | ||||
import com.google.gwt.json.client.JSONString; | import com.google.gwt.json.client.JSONString; | ||||
import com.google.gwt.json.client.JSONValue; | import com.google.gwt.json.client.JSONValue; | ||||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | |||||
import com.vaadin.terminal.gwt.client.Connector; | import com.vaadin.terminal.gwt.client.Connector; | ||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | import com.vaadin.terminal.gwt.client.ConnectorMap; | ||||
* value to convert | * value to convert | ||||
* @param connectorMap | * @param connectorMap | ||||
* mapper from connectors to connector IDs | * mapper from connectors to connector IDs | ||||
* @param connection | |||||
* @return JSON representation of the value | * @return JSON representation of the value | ||||
*/ | */ | ||||
public static JSONValue encode(Object value, ConnectorMap connectorMap) { | |||||
public static JSONValue encode(Object value, ConnectorMap connectorMap, | |||||
ApplicationConnection connection) { | |||||
if (null == value) { | if (null == value) { | ||||
// TODO as undefined type? | // TODO as undefined type? | ||||
return combineTypeAndValue(VTYPE_UNDEFINED, JSONNull.getInstance()); | return combineTypeAndValue(VTYPE_UNDEFINED, JSONNull.getInstance()); | ||||
JSONArray jsonArray = new JSONArray(); | JSONArray jsonArray = new JSONArray(); | ||||
for (int i = 0; i < array.length; ++i) { | for (int i = 0; i < array.length; ++i) { | ||||
// TODO handle object graph loops? | // TODO handle object graph loops? | ||||
jsonArray.set(i, encode(array[i], connectorMap)); | |||||
jsonArray.set(i, encode(array[i], connectorMap, connection)); | |||||
} | } | ||||
return combineTypeAndValue(VTYPE_ARRAY, jsonArray); | return combineTypeAndValue(VTYPE_ARRAY, jsonArray); | ||||
} else if (value instanceof Map) { | } else if (value instanceof Map) { | ||||
for (String mapKey : map.keySet()) { | for (String mapKey : map.keySet()) { | ||||
// TODO handle object graph loops? | // TODO handle object graph loops? | ||||
Object mapValue = map.get(mapKey); | Object mapValue = map.get(mapKey); | ||||
jsonMap.put(mapKey, encode(mapValue, connectorMap)); | |||||
jsonMap.put(mapKey, encode(mapValue, connectorMap, connection)); | |||||
} | } | ||||
return combineTypeAndValue(VTYPE_MAP, jsonMap); | return combineTypeAndValue(VTYPE_MAP, jsonMap); | ||||
} else if (value instanceof Connector) { | } else if (value instanceof Connector) { | ||||
// TODO handle case with no serializer found | // TODO handle case with no serializer found | ||||
return combineTypeAndValue(type, | return combineTypeAndValue(type, | ||||
serializer.serialize(value, connectorMap)); | |||||
serializer.serialize(value, connectorMap, connection)); | |||||
} | } | ||||
} | } | ||||
} | } |
package com.vaadin.terminal.gwt.client.communication; | |||||
import com.vaadin.Application; | |||||
import com.vaadin.terminal.ApplicationResource; | |||||
import com.vaadin.terminal.ExternalResource; | |||||
import com.vaadin.terminal.Resource; | |||||
import com.vaadin.terminal.ThemeResource; | |||||
public class ResourceReference extends URLReference { | |||||
private Resource resource; | |||||
public ResourceReference(Resource resource) { | |||||
this.resource = resource; | |||||
} | |||||
public Resource getResource() { | |||||
return resource; | |||||
} | |||||
@Override | |||||
public String getURL() { | |||||
if (resource instanceof ExternalResource) { | |||||
return ((ExternalResource) resource).getURL(); | |||||
} else if (resource instanceof ApplicationResource) { | |||||
final ApplicationResource r = (ApplicationResource) resource; | |||||
final Application a = r.getApplication(); | |||||
if (a == null) { | |||||
throw new RuntimeException( | |||||
"An ApplicationResource (" | |||||
+ r.getClass().getName() | |||||
+ " must be attached to an application when it is sent to the client."); | |||||
} | |||||
final String uri = a.getRelativeLocation(r); | |||||
return uri; | |||||
} else if (resource instanceof ThemeResource) { | |||||
final String uri = "theme://" | |||||
+ ((ThemeResource) resource).getResourceId(); | |||||
return uri; | |||||
} else { | |||||
throw new RuntimeException(getClass().getSimpleName() | |||||
+ " does not support resources of type: " | |||||
+ resource.getClass().getName()); | |||||
} | |||||
} | |||||
} |
package com.vaadin.terminal.gwt.client.communication; | |||||
public class URLReference { | |||||
private String URL; | |||||
/** | |||||
* Returns the URL that this object refers to. | |||||
* <p> | |||||
* Note that the URL can use special protocols like theme:// | |||||
* | |||||
* @return The URL for this reference or null if unknown. | |||||
*/ | |||||
public String getURL() { | |||||
return URL; | |||||
} | |||||
/** | |||||
* Sets the URL that this object refers to | |||||
* | |||||
* @param URL | |||||
*/ | |||||
public void setURL(String URL) { | |||||
this.URL = URL; | |||||
} | |||||
} |
package com.vaadin.terminal.gwt.client.communication; | |||||
import com.google.gwt.core.client.GWT; | |||||
import com.google.gwt.json.client.JSONArray; | |||||
import com.google.gwt.json.client.JSONObject; | |||||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | |||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | |||||
public class URLReference_Serializer implements JSONSerializer<URLReference> { | |||||
public URLReference deserialize(JSONObject jsonValue, | |||||
ConnectorMap idMapper, ApplicationConnection connection) { | |||||
URLReference reference = GWT.create(URLReference.class); | |||||
JSONArray jsonURL = (JSONArray) jsonValue.get("URL"); | |||||
String URL = (String) JsonDecoder.convertValue(jsonURL, idMapper, | |||||
connection); | |||||
reference.setURL(connection.translateVaadinUri(URL)); | |||||
return reference; | |||||
} | |||||
public JSONObject serialize(URLReference value, ConnectorMap idMapper, | |||||
ApplicationConnection connection) { | |||||
JSONObject json = new JSONObject(); | |||||
json.put("URL", | |||||
JsonEncoder.encode(value.getURL(), idMapper, connection)); | |||||
return json; | |||||
} | |||||
} |
// constants, which may refer to these. | // constants, which may refer to these. | ||||
// Not all references to the string literals have been converted to use | // Not all references to the string literals have been converted to use | ||||
// these! | // these! | ||||
public static final String ATTRIBUTE_ICON = "icon"; | |||||
public static final String ATTRIBUTE_REQUIRED = "required"; | public static final String ATTRIBUTE_REQUIRED = "required"; | ||||
public static final String ATTRIBUTE_ERROR = "error"; | public static final String ATTRIBUTE_ERROR = "error"; | ||||
public static final String ATTRIBUTE_HIDEERRORS = "hideErrors"; | public static final String ATTRIBUTE_HIDEERRORS = "hideErrors"; |
getWidget().errorIndicatorElement = null; | getWidget().errorIndicatorElement = null; | ||||
} | } | ||||
if (uidl.hasAttribute(ATTRIBUTE_ICON)) { | |||||
if (getState().getIcon() != null) { | |||||
if (getWidget().icon == null) { | if (getWidget().icon == null) { | ||||
getWidget().icon = new Icon(client); | getWidget().icon = new Icon(client); | ||||
getWidget().wrapper.insertBefore(getWidget().icon.getElement(), | getWidget().wrapper.insertBefore(getWidget().icon.getElement(), | ||||
getWidget().captionElement); | getWidget().captionElement); | ||||
} | } | ||||
getWidget().icon.setUri(uidl.getStringAttribute(ATTRIBUTE_ICON)); | |||||
getWidget().icon.setUri(getState().getIcon().getURL()); | |||||
} else { | } else { | ||||
if (getWidget().icon != null) { | if (getWidget().icon != null) { | ||||
getWidget().wrapper.removeChild(getWidget().icon.getElement()); | getWidget().wrapper.removeChild(getWidget().icon.getElement()); |
getWidget().setEnabled(false); | getWidget().setEnabled(false); | ||||
} | } | ||||
if (uidl.hasAttribute(ATTRIBUTE_ICON)) { | |||||
if (getState().getIcon() != null) { | |||||
if (getWidget().icon == null) { | if (getWidget().icon == null) { | ||||
getWidget().icon = new Icon(client); | getWidget().icon = new Icon(client); | ||||
DOM.insertChild(getWidget().getElement(), | DOM.insertChild(getWidget().getElement(), | ||||
getWidget().icon.sinkEvents(VTooltip.TOOLTIP_EVENTS); | getWidget().icon.sinkEvents(VTooltip.TOOLTIP_EVENTS); | ||||
getWidget().icon.sinkEvents(Event.ONCLICK); | getWidget().icon.sinkEvents(Event.ONCLICK); | ||||
} | } | ||||
getWidget().icon.setUri(uidl.getStringAttribute(ATTRIBUTE_ICON)); | |||||
getWidget().icon.setUri(getState().getIcon().getURL()); | |||||
} else if (getWidget().icon != null) { | } else if (getWidget().icon != null) { | ||||
// detach icon | // detach icon | ||||
DOM.removeChild(getWidget().getElement(), | DOM.removeChild(getWidget().getElement(), |
} else { | } else { | ||||
getWidget().caption.setInnerText(""); | getWidget().caption.setInnerText(""); | ||||
} | } | ||||
if (uidl.hasAttribute(ATTRIBUTE_ICON)) { | |||||
if (getState().getIcon() != null) { | |||||
if (getWidget().icon == null) { | if (getWidget().icon == null) { | ||||
getWidget().icon = new Icon(client); | getWidget().icon = new Icon(client); | ||||
getWidget().legend.insertFirst(getWidget().icon.getElement()); | getWidget().legend.insertFirst(getWidget().icon.getElement()); | ||||
} | } | ||||
getWidget().icon.setUri(uidl.getStringAttribute(ATTRIBUTE_ICON)); | |||||
getWidget().icon.setUri(getState().getIcon().getURL()); | |||||
legendEmpty = false; | legendEmpty = false; | ||||
} else { | } else { | ||||
if (getWidget().icon != null) { | if (getWidget().icon != null) { |
"none"); | "none"); | ||||
} | } | ||||
if (uidl.hasAttribute(ATTRIBUTE_ICON)) { | |||||
if (getState().getIcon() != null) { | |||||
if (getWidget().icon == null) { | if (getWidget().icon == null) { | ||||
getWidget().icon = new Icon(client); | getWidget().icon = new Icon(client); | ||||
getWidget().anchor.insertBefore(getWidget().icon.getElement(), | getWidget().anchor.insertBefore(getWidget().icon.getElement(), | ||||
getWidget().captionElement); | getWidget().captionElement); | ||||
} | } | ||||
getWidget().icon.setUri(uidl.getStringAttribute(ATTRIBUTE_ICON)); | |||||
getWidget().icon.setUri(getState().getIcon().getURL()); | |||||
} | } | ||||
} | } |
public void init() { | public void init() { | ||||
super.init(); | super.init(); | ||||
ButtonServerRpc rpcProxy = GWT | |||||
.create(ButtonServerRpc.class); | |||||
ButtonServerRpc rpcProxy = GWT.create(ButtonServerRpc.class); | |||||
getWidget().buttonRpcProxy = initRPC(rpcProxy); | getWidget().buttonRpcProxy = initRPC(rpcProxy); | ||||
} | } | ||||
getWidget().errorIndicatorElement = null; | getWidget().errorIndicatorElement = null; | ||||
} | } | ||||
if (uidl.hasAttribute(ATTRIBUTE_ICON)) { | |||||
if (getState().getIcon() != null) { | |||||
if (getWidget().icon == null) { | if (getWidget().icon == null) { | ||||
getWidget().icon = new Icon(client); | getWidget().icon = new Icon(client); | ||||
getWidget().getElement().insertBefore( | getWidget().getElement().insertBefore( | ||||
getWidget().icon.getElement(), | getWidget().icon.getElement(), | ||||
getWidget().captionElement); | getWidget().captionElement); | ||||
} | } | ||||
getWidget().icon.setUri(uidl.getStringAttribute(ATTRIBUTE_ICON)); | |||||
getWidget().icon.setUri(getState().getIcon().getURL()); | |||||
} else { | } else { | ||||
if (getWidget().icon != null) { | if (getWidget().icon != null) { | ||||
getWidget().getElement().removeChild( | getWidget().getElement().removeChild( |
getWidget().client = client; | getWidget().client = client; | ||||
getWidget().id = uidl.getId(); | getWidget().id = uidl.getId(); | ||||
getWidget().setIconUri(uidl, client); | |||||
if (getState().getIcon() != null) { | |||||
getWidget().setIconUri(getState().getIcon().getURL(), client); | |||||
} else { | |||||
getWidget().setIconUri(null, client); | |||||
} | |||||
getWidget().handleError(uidl); | getWidget().handleError(uidl); | ||||
public static final String ATTRIBUTE_TAB_DISABLED = "disabled"; | public static final String ATTRIBUTE_TAB_DISABLED = "disabled"; | ||||
public static final String ATTRIBUTE_TAB_DESCRIPTION = "description"; | public static final String ATTRIBUTE_TAB_DESCRIPTION = "description"; | ||||
public static final String ATTRIBUTE_TAB_CAPTION = "caption"; | public static final String ATTRIBUTE_TAB_CAPTION = "caption"; | ||||
public static final String ATTRIBUTE_TAB_ICON = "icon"; | |||||
@Override | @Override | ||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { |
public static final String ATTRIBUTE_NODE_STYLE = "style"; | public static final String ATTRIBUTE_NODE_STYLE = "style"; | ||||
public static final String ATTRIBUTE_NODE_CAPTION = "caption"; | public static final String ATTRIBUTE_NODE_CAPTION = "caption"; | ||||
public static final String ATTRIBUTE_NODE_ICON = AbstractComponentConnector.ATTRIBUTE_ICON; | |||||
public static final String ATTRIBUTE_NODE_ICON = "icon"; | |||||
public static final String ATTRIBUTE_ACTION_CAPTION = "caption"; | public static final String ATTRIBUTE_ACTION_CAPTION = "caption"; | ||||
public static final String ATTRIBUTE_ACTION_ICON = AbstractComponentConnector.ATTRIBUTE_ICON; | |||||
public static final String ATTRIBUTE_ACTION_ICON = ATTRIBUTE_NODE_ICON; | |||||
@Override | @Override | ||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { | public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { |
uidl, | uidl, | ||||
uidl.getStringAttribute(TabsheetBaseConnector.ATTRIBUTE_TAB_CAPTION), | uidl.getStringAttribute(TabsheetBaseConnector.ATTRIBUTE_TAB_CAPTION), | ||||
uidl.hasAttribute(TabsheetBaseConnector.ATTRIBUTE_TAB_DISABLED), | uidl.hasAttribute(TabsheetBaseConnector.ATTRIBUTE_TAB_DISABLED), | ||||
uidl.hasAttribute(TabsheetBaseConnector.ATTRIBUTE_TAB_DESCRIPTION)); | |||||
uidl.hasAttribute(TabsheetBaseConnector.ATTRIBUTE_TAB_DESCRIPTION), | |||||
uidl.getStringAttribute(TabsheetBaseConnector.ATTRIBUTE_TAB_ICON)); | |||||
} | } | ||||
public int getWidgetWidth() { | public int getWidgetWidth() { |
boolean isEmpty = true; | boolean isEmpty = true; | ||||
if (uidl.hasAttribute(AbstractComponentConnector.ATTRIBUTE_ICON)) { | |||||
if (state.getIcon() != null) { | |||||
if (icon == null) { | if (icon == null) { | ||||
icon = new Icon(client); | icon = new Icon(client); | ||||
DOM.insertChild(getElement(), icon.getElement(), 0); | DOM.insertChild(getElement(), icon.getElement(), 0); | ||||
} | } | ||||
icon.setUri(uidl | |||||
.getStringAttribute(AbstractComponentConnector.ATTRIBUTE_ICON)); | |||||
icon.setUri(state.getIcon().getURL()); | |||||
isEmpty = false; | isEmpty = false; | ||||
} else { | } else { | ||||
if (icon != null) { | if (icon != null) { |
public static final String ATTRIBUTE_CHECKED = "checked"; | public static final String ATTRIBUTE_CHECKED = "checked"; | ||||
public static final String ATTRIBUTE_ITEM_DESCRIPTION = "description"; | public static final String ATTRIBUTE_ITEM_DESCRIPTION = "description"; | ||||
public static final String ATTRIBUTE_ITEM_ICON = AbstractComponentConnector.ATTRIBUTE_ICON; | |||||
public static final String ATTRIBUTE_ITEM_ICON = "icon"; | |||||
public static final String ATTRIBUTE_ITEM_DISABLED = "disabled"; | public static final String ATTRIBUTE_ITEM_DISABLED = "disabled"; | ||||
public static final String ATTRIBUTE_ITEM_STYLE = "style"; | public static final String ATTRIBUTE_ITEM_STYLE = "style"; | ||||
public static final String ATTRIBUTE_NOTIFICATION_STYLE = "style"; | public static final String ATTRIBUTE_NOTIFICATION_STYLE = "style"; | ||||
public static final String ATTRIBUTE_NOTIFICATION_CAPTION = "caption"; | public static final String ATTRIBUTE_NOTIFICATION_CAPTION = "caption"; | ||||
public static final String ATTRIBUTE_NOTIFICATION_MESSAGE = "message"; | public static final String ATTRIBUTE_NOTIFICATION_MESSAGE = "message"; | ||||
public static final String ATTRIBUTE_NOTIFICATION_ICON = AbstractComponentConnector.ATTRIBUTE_ICON; | |||||
public static final String ATTRIBUTE_NOTIFICATION_ICON = "icon"; | |||||
public static final String ATTRIBUTE_NOTIFICATION_POSITION = "position"; | public static final String ATTRIBUTE_NOTIFICATION_POSITION = "position"; | ||||
public static final String ATTRIBUTE_NOTIFICATION_DELAY = "delay"; | public static final String ATTRIBUTE_NOTIFICATION_DELAY = "delay"; | ||||
} | } | ||||
} | } | ||||
void setIconUri(UIDL uidl, ApplicationConnection client) { | |||||
final String iconUri = uidl | |||||
.hasAttribute(AbstractComponentConnector.ATTRIBUTE_ICON) ? uidl | |||||
.getStringAttribute(AbstractComponentConnector.ATTRIBUTE_ICON) | |||||
: null; | |||||
void setIconUri(String iconUri, ApplicationConnection client) { | |||||
if (iconUri == null) { | if (iconUri == null) { | ||||
if (icon != null) { | if (icon != null) { | ||||
DOM.removeChild(captionNode, icon.getElement()); | DOM.removeChild(captionNode, icon.getElement()); |
uidl, | uidl, | ||||
uidl.getStringAttribute(TabsheetBaseConnector.ATTRIBUTE_TAB_CAPTION), | uidl.getStringAttribute(TabsheetBaseConnector.ATTRIBUTE_TAB_CAPTION), | ||||
uidl.hasAttribute(TabsheetBaseConnector.ATTRIBUTE_TAB_DISABLED), | uidl.hasAttribute(TabsheetBaseConnector.ATTRIBUTE_TAB_DISABLED), | ||||
uidl.hasAttribute(TabsheetBaseConnector.ATTRIBUTE_TAB_DESCRIPTION)); | |||||
uidl.hasAttribute(TabsheetBaseConnector.ATTRIBUTE_TAB_DESCRIPTION), | |||||
uidl.getStringAttribute(TabsheetBaseConnector.ATTRIBUTE_TAB_ICON)); | |||||
setClosable(uidl.hasAttribute("closable")); | setClosable(uidl.hasAttribute("closable")); | ||||
// Caption must be set before required header size is measured. If | // Caption must be set before required header size is measured. If | ||||
// the caption attribute is missing the caption should be cleared. | // the caption attribute is missing the caption should be cleared. | ||||
getWidget() | |||||
.setCaption( | |||||
getState().getCaption(), | |||||
uidl.getStringAttribute(AbstractComponentConnector.ATTRIBUTE_ICON)); | |||||
String iconURL = null; | |||||
if (getState().getIcon() != null) { | |||||
iconURL = getState().getIcon().getURL(); | |||||
} | |||||
getWidget().setCaption(getState().getCaption(), iconURL); | |||||
} | } | ||||
getWidget().visibilityChangesDisabled = true; | getWidget().visibilityChangesDisabled = true; |
*/ | */ | ||||
public static JSONArray encode(Object value, PaintableIdMapper idMapper) | public static JSONArray encode(Object value, PaintableIdMapper idMapper) | ||||
throws JSONException { | throws JSONException { | ||||
return encode(value, null, idMapper); | |||||
} | |||||
public static JSONArray encode(Object value, Class<?> valueType, | |||||
PaintableIdMapper idMapper) throws JSONException { | |||||
if (null == value) { | if (null == value) { | ||||
// TODO as undefined type? | // TODO as undefined type? | ||||
return combineTypeAndValue(JsonEncoder.VTYPE_UNDEFINED, | return combineTypeAndValue(JsonEncoder.VTYPE_UNDEFINED, | ||||
} else { | } else { | ||||
// Any object that we do not know how to encode we encode by looping | // Any object that we do not know how to encode we encode by looping | ||||
// through fields | // through fields | ||||
return combineTypeAndValue(value.getClass().getCanonicalName(), | |||||
if (valueType == null) { | |||||
valueType = value.getClass(); | |||||
} | |||||
return combineTypeAndValue(valueType.getCanonicalName(), | |||||
encodeObject(value, idMapper)); | encodeObject(value, idMapper)); | ||||
} | } | ||||
} | } | ||||
for (PropertyDescriptor pd : Introspector.getBeanInfo( | for (PropertyDescriptor pd : Introspector.getBeanInfo( | ||||
value.getClass()).getPropertyDescriptors()) { | value.getClass()).getPropertyDescriptors()) { | ||||
String fieldName = pd.getName(); | String fieldName = pd.getName(); | ||||
Class<?> fieldType = pd.getPropertyType(); | |||||
if (pd.getReadMethod() == null || pd.getWriteMethod() == null) { | if (pd.getReadMethod() == null || pd.getWriteMethod() == null) { | ||||
continue; | continue; | ||||
} | } | ||||
Method getterMethod = pd.getReadMethod(); | Method getterMethod = pd.getReadMethod(); | ||||
Object fieldValue = getterMethod.invoke(value, null); | Object fieldValue = getterMethod.invoke(value, null); | ||||
jsonMap.put(fieldName, encode(fieldValue, idMapper)); | |||||
jsonMap.put(fieldName, encode(fieldValue, fieldType, idMapper)); | |||||
} | } | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
// TODO: Should exceptions be handled in a different way? | // TODO: Should exceptions be handled in a different way? |
import com.google.gwt.json.client.JSONObject; | import com.google.gwt.json.client.JSONObject; | ||||
import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; | import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; | ||||
import com.google.gwt.user.rebind.SourceWriter; | import com.google.gwt.user.rebind.SourceWriter; | ||||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | |||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | import com.vaadin.terminal.gwt.client.ConnectorMap; | ||||
import com.vaadin.terminal.gwt.client.communication.JSONSerializer; | |||||
import com.vaadin.terminal.gwt.client.communication.JsonDecoder; | import com.vaadin.terminal.gwt.client.communication.JsonDecoder; | ||||
import com.vaadin.terminal.gwt.client.communication.JsonEncoder; | import com.vaadin.terminal.gwt.client.communication.JsonEncoder; | ||||
import com.vaadin.terminal.gwt.client.communication.SerializerMap; | import com.vaadin.terminal.gwt.client.communication.SerializerMap; | ||||
import com.vaadin.terminal.gwt.client.communication.JSONSerializer; | |||||
/** | /** | ||||
* GWT generator for creating serializer classes for custom classes sent from | * GWT generator for creating serializer classes for custom classes sent from | ||||
// Serializer | // Serializer | ||||
// public JSONValue serialize(Object value, ConnectorMap idMapper) { | |||||
// public JSONValue serialize(Object value, ConnectorMap idMapper, | |||||
// ApplicationConnection connection) { | |||||
sourceWriter.println("public " + JSONObject.class.getName() | sourceWriter.println("public " + JSONObject.class.getName() | ||||
+ " serialize(" + Object.class.getName() + " value, " | + " serialize(" + Object.class.getName() + " value, " | ||||
+ ConnectorMap.class.getName() + " idMapper) {"); | |||||
+ ConnectorMap.class.getName() + " idMapper, " | |||||
+ ApplicationConnection.class.getName() + " connection) {"); | |||||
sourceWriter.indent(); | sourceWriter.indent(); | ||||
// MouseEventDetails castedValue = (MouseEventDetails) value; | // MouseEventDetails castedValue = (MouseEventDetails) value; | ||||
sourceWriter.println(beanQualifiedSourceName + " castedValue = (" | sourceWriter.println(beanQualifiedSourceName + " castedValue = (" | ||||
+ ". Serialization will likely fail"); | + ". Serialization will likely fail"); | ||||
} | } | ||||
// json.put("button", | // json.put("button", | ||||
// JsonEncoder.encode(castedValue.getButton(), idMapper)); | |||||
// JsonEncoder.encode(castedValue.getButton(), idMapper, | |||||
// connection)); | |||||
sourceWriter.println("json.put(\"" + fieldName + "\", " | sourceWriter.println("json.put(\"" + fieldName + "\", " | ||||
+ JsonEncoder.class.getName() + ".encode(castedValue." | + JsonEncoder.class.getName() + ".encode(castedValue." | ||||
+ getterName + "(), idMapper));"); | |||||
+ getterName + "(), idMapper, connection));"); | |||||
} | } | ||||
// return json; | // return json; | ||||
sourceWriter.println("return json;"); | sourceWriter.println("return json;"); | ||||
// Deserializer | // Deserializer | ||||
sourceWriter.println("public " + beanQualifiedSourceName | sourceWriter.println("public " + beanQualifiedSourceName | ||||
+ " deserialize(" + JSONObject.class.getName() + " jsonValue, " | + " deserialize(" + JSONObject.class.getName() + " jsonValue, " | ||||
+ ConnectorMap.class.getName() + " idMapper) {"); | |||||
+ ConnectorMap.class.getName() + " idMapper, " | |||||
+ ApplicationConnection.class.getName() + " connection) {"); | |||||
sourceWriter.indent(); | sourceWriter.indent(); | ||||
// VButtonState state = GWT.create(VButtonState.class); | // VButtonState state = GWT.create(VButtonState.class); | ||||
+ " = (JSONArray) jsonValue.get(\"" + fieldName + "\");"); | + " = (JSONArray) jsonValue.get(\"" + fieldName + "\");"); | ||||
// state.setHeight((String) | // state.setHeight((String) | ||||
// JsonDecoder.convertValue(jsonFieldValue,idMapper)); | |||||
// JsonDecoder.convertValue(jsonFieldValue,idMapper, connection)); | |||||
String fieldType; | String fieldType; | ||||
JPrimitiveType primitiveType = setterParameterType.isPrimitive(); | JPrimitiveType primitiveType = setterParameterType.isPrimitive(); | ||||
sourceWriter.println("state." + setterName + "((" + fieldType | sourceWriter.println("state." + setterName + "((" + fieldType | ||||
+ ") JsonDecoder.convertValue(" + jsonFieldName | + ") JsonDecoder.convertValue(" + jsonFieldName | ||||
+ ", idMapper));"); | |||||
+ ", idMapper, connection));"); | |||||
} | } | ||||
// return state; | // return state; |
import com.google.gwt.core.ext.typeinfo.JMethod; | import com.google.gwt.core.ext.typeinfo.JMethod; | ||||
import com.google.gwt.core.ext.typeinfo.JType; | import com.google.gwt.core.ext.typeinfo.JType; | ||||
import com.google.gwt.core.ext.typeinfo.TypeOracle; | import com.google.gwt.core.ext.typeinfo.TypeOracle; | ||||
import com.google.gwt.json.client.JSONObject; | |||||
import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; | import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; | ||||
import com.google.gwt.user.rebind.SourceWriter; | import com.google.gwt.user.rebind.SourceWriter; | ||||
import com.vaadin.terminal.gwt.client.ApplicationConnection; | |||||
import com.vaadin.terminal.gwt.client.ConnectorMap; | |||||
import com.vaadin.terminal.gwt.client.communication.ClientRpc; | import com.vaadin.terminal.gwt.client.communication.ClientRpc; | ||||
import com.vaadin.terminal.gwt.client.communication.JSONSerializer; | |||||
import com.vaadin.terminal.gwt.client.communication.SerializerMap; | import com.vaadin.terminal.gwt.client.communication.SerializerMap; | ||||
import com.vaadin.terminal.gwt.client.communication.ServerRpc; | import com.vaadin.terminal.gwt.client.communication.ServerRpc; | ||||
import com.vaadin.terminal.gwt.client.communication.SharedState; | import com.vaadin.terminal.gwt.client.communication.SharedState; | ||||
import com.vaadin.terminal.gwt.client.communication.JSONSerializer; | |||||
/** | /** | ||||
* GWT generator that creates a {@link SerializerMap} implementation (mapper | * GWT generator that creates a {@link SerializerMap} implementation (mapper | ||||
TypeOracle typeOracle = context.getTypeOracle(); | TypeOracle typeOracle = context.getTypeOracle(); | ||||
Set<JClassType> typesNeedingSerializers = findTypesNeedingSerializers( | Set<JClassType> typesNeedingSerializers = findTypesNeedingSerializers( | ||||
typeOracle, logger); | typeOracle, logger); | ||||
Set<JClassType> typesWithExistingSerializers = findTypesWithExistingSerializers( | |||||
typeOracle, logger); | |||||
Set<JClassType> serializerMappings = new HashSet<JClassType>(); | |||||
serializerMappings.addAll(typesNeedingSerializers); | |||||
serializerMappings.addAll(typesWithExistingSerializers); | |||||
// get classType and save instance variables | // get classType and save instance variables | ||||
JClassType classType = typeOracle.getType(typeName); | JClassType classType = typeOracle.getType(typeName); | ||||
packageName = classType.getPackage().getName(); | packageName = classType.getPackage().getName(); | ||||
className = classType.getSimpleSourceName() + "Impl"; | className = classType.getSimpleSourceName() + "Impl"; | ||||
// Generate class source code for SerializerMapImpl | // Generate class source code for SerializerMapImpl | ||||
generateSerializerMap(typesNeedingSerializers, logger, context); | |||||
generateSerializerMap(serializerMappings, logger, context); | |||||
SerializerGenerator sg = new SerializerGenerator(); | SerializerGenerator sg = new SerializerGenerator(); | ||||
for (JClassType type : typesNeedingSerializers) { | for (JClassType type : typesNeedingSerializers) { | ||||
return packageName + "." + className; | return packageName + "." + className; | ||||
} | } | ||||
private Set<JClassType> findTypesWithExistingSerializers( | |||||
TypeOracle typeOracle, TreeLogger logger) { | |||||
JClassType serializerInterface = typeOracle | |||||
.findType(JSONSerializer.class.getName()); | |||||
Set<JClassType> types = new HashSet<JClassType>(); | |||||
for (JClassType serializer : serializerInterface.getSubtypes()) { | |||||
JType[] deserializeParamTypes = new JType[] { | |||||
typeOracle.findType(JSONObject.class.getName()), | |||||
typeOracle.findType(ConnectorMap.class.getName()), | |||||
typeOracle.findType(ApplicationConnection.class.getName()) }; | |||||
JMethod deserializeMethod = serializer.findMethod("deserialize", | |||||
deserializeParamTypes); | |||||
if (deserializeMethod == null) { | |||||
continue; | |||||
} | |||||
types.add(deserializeMethod.getReturnType().isClass()); | |||||
} | |||||
return types; | |||||
} | |||||
/** | /** | ||||
* Generate source code for SerializerMapImpl | * Generate source code for SerializerMapImpl | ||||
* | * |
import com.vaadin.terminal.Terminal; | import com.vaadin.terminal.Terminal; | ||||
import com.vaadin.terminal.gwt.client.ComponentState; | import com.vaadin.terminal.gwt.client.ComponentState; | ||||
import com.vaadin.terminal.gwt.client.communication.ClientRpc; | import com.vaadin.terminal.gwt.client.communication.ClientRpc; | ||||
import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector; | |||||
import com.vaadin.terminal.gwt.client.communication.ResourceReference; | |||||
import com.vaadin.terminal.gwt.server.ClientMethodInvocation; | import com.vaadin.terminal.gwt.server.ClientMethodInvocation; | ||||
import com.vaadin.terminal.gwt.server.ComponentSizeValidator; | import com.vaadin.terminal.gwt.server.ComponentSizeValidator; | ||||
import com.vaadin.terminal.gwt.server.RpcManager; | import com.vaadin.terminal.gwt.server.RpcManager; | ||||
*/ | */ | ||||
private Object applicationData; | private Object applicationData; | ||||
/** | |||||
* Icon to be shown together with caption. | |||||
*/ | |||||
private Resource icon; | |||||
/** | /** | ||||
* The container this component resides in. | * The container this component resides in. | ||||
*/ | */ | ||||
* use the default documentation from implemented interface. | * use the default documentation from implemented interface. | ||||
*/ | */ | ||||
public Resource getIcon() { | public Resource getIcon() { | ||||
return icon; | |||||
return ((ResourceReference) getState().getIcon()).getResource(); | |||||
} | } | ||||
/** | /** | ||||
* the icon to be shown with the component's caption. | * the icon to be shown with the component's caption. | ||||
*/ | */ | ||||
public void setIcon(Resource icon) { | public void setIcon(Resource icon) { | ||||
this.icon = icon; | |||||
if (icon == null) { | |||||
getState().setIcon(null); | |||||
} else { | |||||
getState().setIcon(new ResourceReference(icon)); | |||||
} | |||||
requestRepaint(); | requestRepaint(); | ||||
} | } | ||||
// Only paint content of visible components. | // Only paint content of visible components. | ||||
if (isVisible()) { | if (isVisible()) { | ||||
// width and height are only in shared state | |||||
// TODO probably can remove also icon once all the VCaption | |||||
// related code has been updated | |||||
if (getIcon() != null) { | |||||
target.addAttribute( | |||||
AbstractComponentConnector.ATTRIBUTE_ICON, | |||||
getIcon()); | |||||
} | |||||
if (eventIdentifiers != null) { | if (eventIdentifiers != null) { | ||||
target.addAttribute("eventListeners", | target.addAttribute("eventListeners", |
import com.vaadin.terminal.PaintException; | import com.vaadin.terminal.PaintException; | ||||
import com.vaadin.terminal.PaintTarget; | import com.vaadin.terminal.PaintTarget; | ||||
import com.vaadin.terminal.Resource; | import com.vaadin.terminal.Resource; | ||||
import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector; | |||||
import com.vaadin.terminal.gwt.client.ui.TabsheetBaseConnector; | import com.vaadin.terminal.gwt.client.ui.TabsheetBaseConnector; | ||||
import com.vaadin.terminal.gwt.client.ui.TabsheetConnector; | import com.vaadin.terminal.gwt.client.ui.TabsheetConnector; | ||||
import com.vaadin.terminal.gwt.client.ui.VTabsheet; | import com.vaadin.terminal.gwt.client.ui.VTabsheet; | ||||
// VCaption.updateCaption(uidl) | // VCaption.updateCaption(uidl) | ||||
final Resource icon = tab.getIcon(); | final Resource icon = tab.getIcon(); | ||||
if (icon != null) { | if (icon != null) { | ||||
target.addAttribute(AbstractComponentConnector.ATTRIBUTE_ICON, | |||||
target.addAttribute(TabsheetBaseConnector.ATTRIBUTE_TAB_ICON, | |||||
icon); | icon); | ||||
} | } | ||||
final String caption = tab.getCaption(); | final String caption = tab.getCaption(); |