List of usage examples for com.vaadin.shared Connector getConnectorId
public String getConnectorId();
From source file:com.haulmont.cuba.web.widgets.client.addons.dragdroplayouts.ui.VDDLayoutStateDragImageProvider.java
License:Apache License
@Override public Element getDragImageElement(Widget w) { ComponentConnector component = Util.findConnectorFor(w); Connector dragImage = state.referenceImageComponents.get(component); if (dragImage != null) { return ConnectorMap.get(component.getConnection()).getElement(dragImage.getConnectorId()); }//from w w w .ja v a 2 s. c o m return null; }
From source file:org.vaadin.alump.offlinebuilder.client.offline.JsonEncoder.java
License:Open Source License
/** * Encode a value to a JSON representation for transport from the client to * the server.//from w w w . j av a 2 s . com * * @param value * value to convert * @param connection * @return JSON representation of the value */ public static JSONValue encode(Object value, Type type, ApplicationConnection connection) { if (null == value) { return JSONNull.getInstance(); } else if (value instanceof JSONValue) { return (JSONValue) value; } else if (value instanceof String[]) { String[] array = (String[]) value; JSONArray jsonArray = new JSONArray(); for (int i = 0; i < array.length; ++i) { jsonArray.set(i, new JSONString(array[i])); } return jsonArray; } else if (value instanceof String) { return new JSONString((String) value); } else if (value instanceof Boolean) { return JSONBoolean.getInstance((Boolean) value); // --- added to this class to get offline mode working (start) --- } else if (value instanceof Short) { return new JSONNumber(((Short) value).shortValue()); } else if (value instanceof Integer) { return new JSONNumber(((Integer) value).intValue()); } else if (value instanceof Long) { return new JSONNumber(((Long) value).longValue()); } else if (value instanceof Double) { return new JSONNumber(((Double) value).doubleValue()); } else if (value instanceof Float) { return new JSONNumber(((Float) value).floatValue()); // --- added to this class to get offline mode working (end) --- } else if (value instanceof Byte) { return new JSONNumber((Byte) value); } else if (value instanceof Character) { return new JSONString(String.valueOf(value)); } else if (value instanceof Object[] && type == null) { // Non-legacy arrays handed by generated serializer return encodeLegacyObjectArray((Object[]) value, connection); } else if (value instanceof Enum) { return encodeEnum((Enum<?>) value, connection); } else if (value instanceof Map) { return encodeMap((Map) value, type, connection); } else if (value instanceof Connector) { Connector connector = (Connector) value; return new JSONString(connector.getConnectorId()); } else if (value instanceof Collection) { return encodeCollection((Collection) value, type, connection); } else if (value instanceof UidlValue) { return encodeVariableChange((UidlValue) value, connection); } else { // First see if there's a custom serializer JSONSerializer<Object> serializer = null; if (type != null) { serializer = (JSONSerializer<Object>) type.findSerializer(); if (serializer != null) { return serializer.serialize(value, connection); } } String transportType = getTransportType(value); if (transportType != null) { // Send the string value for remaining legacy types return new JSONString(String.valueOf(value)); } else if (type != null) { // And finally try using bean serialization logic try { JsArrayObject<Property> properties = type.getPropertiesAsArray(); JSONObject jsonObject = new JSONObject(); int size = properties.size(); for (int i = 0; i < size; i++) { Property property = properties.get(i); Object propertyValue = property.getValue(value); Type propertyType = property.getType(); JSONValue encodedPropertyValue = encode(propertyValue, propertyType, connection); jsonObject.put(property.getName(), encodedPropertyValue); } return jsonObject; } catch (NoDataException e) { throw new RuntimeException("Can not encode " + type.getSignature(), e); } } else { throw new RuntimeException("Can't encode " + value.getClass() + " without type information"); } } }
From source file:org.vaadin.alump.offlinebuilder.client.offline.JsonEncoder.java
License:Open Source License
private static JSONValue encodeConnectorMap(Map<Object, Object> map, Type type, ApplicationConnection connection) { JSONObject jsonMap = new JSONObject(); for (Map.Entry<?, ?> entry : map.entrySet()) { Connector connector = (Connector) entry.getKey(); JSONValue encodedValue = encodeChildValue(entry.getValue(), type, 1, connection); jsonMap.put(connector.getConnectorId(), encodedValue); }/*w w w . j a v a2 s . com*/ return jsonMap; }
From source file:org.vaadin.alump.offlinebuilder.client.offline.OfflineFactory.java
License:Open Source License
public void writeRootState(OfflineUIExtensionState state, ApplicationConnection connection) { OfflineStorage.clearAllItems();//www. j a v a 2 s . co m OfflineStorage.set(generateRootKey(TITLE_KEY), state.title); Connector rootConnector = state.offlineRoot; OfflineStorage.set(generateRootKey(ROOT_KEY), rootConnector != null ? rootConnector.getConnectorId() : null); if (rootConnector != null) { writeState((OfflineConnector) rootConnector); } if (connection != null) { OfflineStorage.set(generateRootKey(UI_CLASS_KEY), connection.getUIConnector().getWidget().getElement().getClassName()); OfflineStorage.set(generateRootKey(PARENT_CLASS_KEY), connection.getUIConnector().getWidget().getElement().getParentElement().getClassName()); } else { OfflineStorage.set(generateRootKey(UI_CLASS_KEY), ""); OfflineStorage.set(generateRootKey(PARENT_CLASS_KEY), ""); } }