]> source.dussan.org Git - vaadin-framework.git/commitdiff
Use update from deserialize instead of generating the same code again
authorLeif Åstrand <leif@vaadin.com>
Tue, 5 Jun 2012 12:56:53 +0000 (15:56 +0300)
committerLeif Åstrand <leif@vaadin.com>
Wed, 6 Jun 2012 10:33:55 +0000 (13:33 +0300)
Also slightly improve indenting in generated code

src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java

index 6e1ebdfc7f785144a64adeb3e170e4aa717faf1f..060d0fa96a98571ae7d7a5f3b5a55628bb467ac3 100644 (file)
@@ -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,