diff options
author | Matti Tahvonen <matti.tahvonen@itmill.com> | 2009-12-14 14:04:09 +0000 |
---|---|---|
committer | Matti Tahvonen <matti.tahvonen@itmill.com> | 2009-12-14 14:04:09 +0000 |
commit | 4e76225bd7a5c3b0b2156a438aa677cadea7eb16 (patch) | |
tree | d642558c28e51f522acd6b349a4260e50ee2722b /src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java | |
parent | 0b56aba609eb1b50114e87ec3c8a0c9a8b774fe8 (diff) | |
download | vaadin-framework-4e76225bd7a5c3b0b2156a438aa677cadea7eb16.tar.gz vaadin-framework-4e76225bd7a5c3b0b2156a438aa677cadea7eb16.zip |
replaced(depracated) paintReference with addAttribute(String,Paintable) and added addVariable(VariableOwner, String, Paintable) method (updates already worked)
fixes #3654, #2854
svn changeset:10286/svn branch:6.2
Diffstat (limited to 'src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java')
-rw-r--r-- | src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java | 249 |
1 files changed, 44 insertions, 205 deletions
diff --git a/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java b/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java index 7a653e93e9..8128e99f00 100644 --- a/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java +++ b/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java @@ -77,7 +77,7 @@ public class JsonPaintTarget implements PaintTarget { /** * Creates a new XMLPrintWriter, without automatic line flushing. - * + * * @param variableMap * @param manager * @param outWriter @@ -85,8 +85,9 @@ public class JsonPaintTarget implements PaintTarget { * @throws PaintException * if the paint operation failed. */ - public JsonPaintTarget(AbstractCommunicationManager manager, PrintWriter outWriter, - boolean cachingRequired) throws PaintException { + public JsonPaintTarget(AbstractCommunicationManager manager, + PrintWriter outWriter, boolean cachingRequired) + throws PaintException { this.manager = manager; @@ -105,18 +106,18 @@ public class JsonPaintTarget implements PaintTarget { /** * Prints the element start tag. - * + * * <pre> * Todo: * Checking of input values - * + * * </pre> - * + * * @param tagName * the name of the start tag. * @throws PaintException * if the paint operation failed. - * + * */ public void startTag(String tagName, boolean isChildNode) throws PaintException { @@ -149,10 +150,10 @@ public class JsonPaintTarget implements PaintTarget { /** * Prints the element end tag. - * + * * If the parent tag is closed before every child tag is closed an * PaintException is raised. - * + * * @param tag * the name of the end tag. * @throws Paintexception @@ -205,7 +206,7 @@ public class JsonPaintTarget implements PaintTarget { /** * Substitutes the XML sensitive characters with predefined XML entities. - * + * * @param xml * the String to be substituted. * @return A new string instance where all occurrences of XML sensitive @@ -220,12 +221,12 @@ public class JsonPaintTarget implements PaintTarget { /** * Substitutes the XML sensitive characters with predefined XML entities. - * + * * @param xml * the String to be substituted. * @return A new StringBuilder instance where all occurrences of XML * sensitive characters are substituted with entities. - * + * */ static StringBuilder escapeXML(StringBuilder xml) { if (xml == null || xml.length() <= 0) { @@ -296,7 +297,7 @@ public class JsonPaintTarget implements PaintTarget { /** * Substitutes a XML sensitive character with predefined XML entity. - * + * * @param c * the Character to be replaced with an entity. * @return String of the entity or null if character is not to be replaced @@ -321,43 +322,20 @@ public class JsonPaintTarget implements PaintTarget { /** * Prints XML-escaped text. - * + * * @param str * @throws PaintException * if the paint operation failed. - * + * */ public void addText(String str) throws PaintException { tag.addData("\"" + escapeJSON(str) + "\""); } - /** - * Adds a boolean attribute to component. Atributes must be added before any - * content is written. - * - * @param name - * the Attribute name. - * @param value - * the Attribute value. - * @throws PaintException - * if the paint operation failed. - */ public void addAttribute(String name, boolean value) throws PaintException { tag.addAttribute("\"" + name + "\":" + (value ? "true" : "false")); } - /** - * Adds a resource attribute to component. Attributes must be added before - * any content is written. - * - * @param name - * the Attribute name. - * @param value - * the Attribute value. - * - * @throws PaintException - * if the paint operation failed. - */ public void addAttribute(String name, Resource value) throws PaintException { if (value instanceof ExternalResource) { @@ -395,82 +373,22 @@ public class JsonPaintTarget implements PaintTarget { } - /** - * Adds a integer attribute to component. Atributes must be added before any - * content is written. - * - * @param name - * the Attribute name. - * @param value - * the Attribute value. - * - * @throws PaintException - * if the paint operation failed. - */ public void addAttribute(String name, int value) throws PaintException { tag.addAttribute("\"" + name + "\":" + String.valueOf(value)); } - /** - * Adds a long attribute to component. Atributes must be added before any - * content is written. - * - * @param name - * the Attribute name. - * @param value - * the Attribute value. - * - * @throws PaintException - * if the paint operation failed. - */ public void addAttribute(String name, long value) throws PaintException { tag.addAttribute("\"" + name + "\":" + String.valueOf(value)); } - /** - * Adds a float attribute to component. Atributes must be added before any - * content is written. - * - * @param name - * the Attribute name. - * @param value - * the Attribute value. - * - * @throws PaintException - * if the paint operation failed. - */ public void addAttribute(String name, float value) throws PaintException { tag.addAttribute("\"" + name + "\":" + String.valueOf(value)); } - /** - * Adds a double attribute to component. Atributes must be added before any - * content is written. - * - * @param name - * the Attribute name. - * @param value - * the Attribute value. - * - * @throws PaintException - * if the paint operation failed. - */ public void addAttribute(String name, double value) throws PaintException { tag.addAttribute("\"" + name + "\":" + String.valueOf(value)); } - /** - * Adds a string attribute to component. Atributes must be added before any - * content is written. - * - * @param name - * the String attribute name. - * @param value - * the String attribute value. - * - * @throws PaintException - * if the paint operation failed. - */ public void addAttribute(String name, String value) throws PaintException { // In case of null data output nothing: if ((value == null) || (name == null)) { @@ -490,6 +408,12 @@ public class JsonPaintTarget implements PaintTarget { } + public void addAttribute(String name, Paintable value) + throws PaintException { + final String id = getPaintIdentifier(value); + addAttribute(name, id); + } + public void addAttribute(String name, Map<?, ?> value) throws PaintException { @@ -548,127 +472,42 @@ public class JsonPaintTarget implements PaintTarget { tag.addAttribute(buf.toString()); } - /** - * Adds a string type variable. - * - * @param owner - * the Listener for variable changes. - * @param name - * the Variable name. - * @param value - * the Variable initial value. - * - * @throws PaintException - * if the paint operation failed. - */ public void addVariable(VariableOwner owner, String name, String value) throws PaintException { tag.addVariable(new StringVariable(owner, name, escapeJSON(value))); } - /** - * Adds a int type variable. - * - * @param owner - * the Listener for variable changes. - * @param name - * the Variable name. - * @param value - * the Variable initial value. - * - * @throws PaintException - * if the paint operation failed. - */ + public void addVariable(VariableOwner owner, String name, Paintable value) + throws PaintException { + tag.addVariable(new StringVariable(owner, name, + getPaintIdentifier(value))); + } + public void addVariable(VariableOwner owner, String name, int value) throws PaintException { tag.addVariable(new IntVariable(owner, name, value)); } - /** - * Adds a long type variable. - * - * @param owner - * the Listener for variable changes. - * @param name - * the Variable name. - * @param value - * the Variable initial value. - * - * @throws PaintException - * if the paint operation failed. - */ public void addVariable(VariableOwner owner, String name, long value) throws PaintException { tag.addVariable(new LongVariable(owner, name, value)); } - /** - * Adds a float type variable. - * - * @param owner - * the Listener for variable changes. - * @param name - * the Variable name. - * @param value - * the Variable initial value. - * - * @throws PaintException - * if the paint operation failed. - */ public void addVariable(VariableOwner owner, String name, float value) throws PaintException { tag.addVariable(new FloatVariable(owner, name, value)); } - /** - * Adds a double type variable. - * - * @param owner - * the Listener for variable changes. - * @param name - * the Variable name. - * @param value - * the Variable initial value. - * - * @throws PaintException - * if the paint operation failed. - */ public void addVariable(VariableOwner owner, String name, double value) throws PaintException { tag.addVariable(new DoubleVariable(owner, name, value)); } - /** - * Adds a boolean type variable. - * - * @param owner - * the Listener for variable changes. - * @param name - * the Variable name. - * @param value - * the Variable initial value. - * - * @throws PaintException - * if the paint operation failed. - */ public void addVariable(VariableOwner owner, String name, boolean value) throws PaintException { tag.addVariable(new BooleanVariable(owner, name, value)); } - /** - * Adds a string array type variable. - * - * @param owner - * the Listener for variable changes. - * @param name - * the Variable name. - * @param value - * the Variable initial value. - * - * @throws PaintException - * if the paint operation failed. - */ public void addVariable(VariableOwner owner, String name, String[] value) throws PaintException { tag.addVariable(new ArrayVariable(owner, name, value)); @@ -676,14 +515,14 @@ public class JsonPaintTarget implements PaintTarget { /** * Adds a upload stream type variable. - * + * * TODO not converted for JSON - * + * * @param owner * the Listener for variable changes. * @param name * the Variable name. - * + * * @throws PaintException * if the paint operation failed. */ @@ -696,9 +535,9 @@ public class JsonPaintTarget implements PaintTarget { /** * Prints the single text section. - * + * * Prints full text section. The section data is escaped - * + * * @param sectionTagName * the name of the tag. * @param sectionData @@ -714,7 +553,7 @@ public class JsonPaintTarget implements PaintTarget { /** * Adds XML directly to UIDL. - * + * * @param xml * the Xml to be added. * @throws PaintException @@ -740,7 +579,7 @@ public class JsonPaintTarget implements PaintTarget { /** * Adds XML section with namespace. - * + * * @param sectionTagName * the name of the tag. * @param sectionData @@ -749,7 +588,7 @@ public class JsonPaintTarget implements PaintTarget { * the namespace to be added. * @throws PaintException * if the paint operation failed. - * + * * @see com.vaadin.terminal.PaintTarget#addXMLSection(String, String, * String) */ @@ -776,7 +615,7 @@ public class JsonPaintTarget implements PaintTarget { /** * Gets the UIDL already printed to stream. Paint target must be closed * before the <code>getUIDL</code> can be called. - * + * * @return the UIDL. */ public String getUIDL() { @@ -792,7 +631,7 @@ public class JsonPaintTarget implements PaintTarget { * <code>getUIDL</code> can be called. Subsequent attempts to write to paint * target. If the target was already closed, call to this function is * ignored. will generate an exception. - * + * * @throws PaintException * if the paint operation failed. */ @@ -813,7 +652,7 @@ public class JsonPaintTarget implements PaintTarget { /* * (non-Javadoc) - * + * * @see com.vaadin.terminal.PaintTarget#startTag(com.vaadin.terminal * .Paintable, java.lang.String) */ @@ -853,7 +692,7 @@ public class JsonPaintTarget implements PaintTarget { /* * (non-Javadoc) - * + * * @see com.vaadin.terminal.PaintTarget#addCharacterData(java.lang.String ) */ public void addCharacterData(String text) throws PaintException { @@ -865,9 +704,9 @@ public class JsonPaintTarget implements PaintTarget { /** * This is basically a container for UI components variables, that will be * added at the end of JSON object. - * + * * @author mattitahvonen - * + * */ class JsonTag implements Serializable { boolean firstField = false; @@ -938,7 +777,7 @@ public class JsonPaintTarget implements PaintTarget { } /** - * + * * @param s * json string, object or array */ @@ -1146,7 +985,7 @@ public class JsonPaintTarget implements PaintTarget { /** * Method to check if paintable is already painted into this target. - * + * * @param p * @return true if is not yet painted into this target and is connected to * app |