From c284b3c3881b23cd0275a5adad055dd2aa3c3252 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leif=20=C3=85strand?= Date: Tue, 5 Jun 2012 15:56:53 +0300 Subject: [PATCH] Use update from deserialize instead of generating the same code again Also slightly improve indenting in generated code --- .../widgetsetutils/SerializerGenerator.java | 28 ++++++++----------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java b/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java index 6e1ebdfc7f..060d0fa96a 100644 --- a/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java +++ b/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java @@ -157,7 +157,7 @@ public class SerializerGenerator extends Generator { + ApplicationConnection.class.getName() + " connection) {"); sourceWriter.indent(); - writeBeanDeserializer(logger, sourceWriter, beanType, true); + writeBeanDeserializer(logger, sourceWriter, beanType); sourceWriter.outdent(); sourceWriter.println("}"); @@ -175,14 +175,20 @@ public class SerializerGenerator extends Generator { if (isEnum) { writeEnumDeserializer(logger, sourceWriter, beanType.isEnum()); } else { - writeBeanDeserializer(logger, sourceWriter, beanType, false); + sourceWriter.println(beanQualifiedSourceName + + " target = GWT.create(" + beanQualifiedSourceName + + ".class);"); + sourceWriter + .println("update(target, type, jsonValue, connection);"); + // return target; + sourceWriter.println("return target;"); } - sourceWriter.println("}"); sourceWriter.outdent(); + sourceWriter.println("}"); // End of class - sourceWriter.println("}"); sourceWriter.outdent(); + sourceWriter.println("}"); // commit generated class context.commit(logger, printWriter); @@ -207,15 +213,9 @@ public class SerializerGenerator extends Generator { } private void writeBeanDeserializer(TreeLogger logger, - SourceWriter sourceWriter, JClassType beanType, boolean update) { + SourceWriter sourceWriter, JClassType beanType) { String beanQualifiedSourceName = beanType.getQualifiedSourceName(); - if (!update) { - sourceWriter.println(beanQualifiedSourceName - + " target = GWT.create(" + beanQualifiedSourceName - + ".class);"); - } - // JSONOBject json = (JSONObject)jsonValue; sourceWriter.println(JSONObject.class.getName() + " json = (" + JSONObject.class.getName() + ")jsonValue;"); @@ -268,12 +268,6 @@ public class SerializerGenerator extends Generator { sourceWriter.outdent(); sourceWriter.println("}"); } - - if (!update) { - // return target; - sourceWriter.println("return target;"); - } - } private void writeEnumSerializer(TreeLogger logger, -- 2.39.5