]> source.dussan.org Git - vaadin-framework.git/commitdiff
Convert CRLF to LF.
authorHenri Sara <hesara@vaadin.com>
Wed, 22 Feb 2012 09:45:29 +0000 (11:45 +0200)
committerHenri Sara <hesara@vaadin.com>
Wed, 22 Feb 2012 09:45:29 +0000 (11:45 +0200)
src/com/vaadin/terminal/gwt/client/communication/SerializerMap.java
src/com/vaadin/terminal/gwt/client/communication/VaadinSerializer.java
src/com/vaadin/terminal/gwt/client/ui/VButtonState.java
src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java
src/com/vaadin/terminal/gwt/widgetsetutils/SerializerMapGenerator.java

index 07b4918b6707795b9ed3c7e4be4311d8a1f2ca91..12983d3579f2330427076f207484818f6ea013a5 100644 (file)
@@ -1,34 +1,34 @@
-/*\r
-@VaadinApache2LicenseForJavaFiles@\r
- */\r
-\r
-package com.vaadin.terminal.gwt.client.communication;\r
-\r
-import com.vaadin.terminal.gwt.widgetsetutils.SerializerMapGenerator;\r
-\r
-/**\r
- * Provide a mapping from a type (communicated between the server and the\r
- * client) and a {@link VaadinSerializer} instance.\r
- * \r
- * An implementation of this class is created at GWT compilation time by\r
- * {@link SerializerMapGenerator}, so this interface can be instantiated with\r
- * GWT.create().\r
- * \r
- * @since 7.0\r
- */\r
-public interface SerializerMap {\r
-\r
-    /**\r
-     * Returns a serializer instance for a given type.\r
-     * \r
-     * @param type\r
-     *            type communicated on between the server and the client\r
-     *            (currently fully qualified class name)\r
-     * @return serializer instance, not null\r
-     * @throws RuntimeException\r
-     *             if no serializer is found\r
-     */\r
-    // TODO better error handling in javadoc and in generator\r
-    public VaadinSerializer getSerializer(String type);\r
-\r
-}\r
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.client.communication;
+
+import com.vaadin.terminal.gwt.widgetsetutils.SerializerMapGenerator;
+
+/**
+ * Provide a mapping from a type (communicated between the server and the
+ * client) and a {@link VaadinSerializer} instance.
+ * 
+ * An implementation of this class is created at GWT compilation time by
+ * {@link SerializerMapGenerator}, so this interface can be instantiated with
+ * GWT.create().
+ * 
+ * @since 7.0
+ */
+public interface SerializerMap {
+
+    /**
+     * Returns a serializer instance for a given type.
+     * 
+     * @param type
+     *            type communicated on between the server and the client
+     *            (currently fully qualified class name)
+     * @return serializer instance, not null
+     * @throws RuntimeException
+     *             if no serializer is found
+     */
+    // TODO better error handling in javadoc and in generator
+    public VaadinSerializer getSerializer(String type);
+
+}
index 5d9be6fbf6a770f03cd25f110c8e3fdd16a62cf5..02484b1e74dbb8046f5e6df6fd9d913ac29ff7b4 100644 (file)
@@ -1,33 +1,33 @@
-/*\r
-@VaadinApache2LicenseForJavaFiles@\r
- */\r
-\r
-package com.vaadin.terminal.gwt.client.communication;\r
-\r
-import com.google.gwt.json.client.JSONObject;\r
-import com.vaadin.terminal.gwt.client.VPaintableMap;\r
-\r
-/**\r
- * Serializer that can deserialize custom objects received from the server.\r
- * \r
- * Each serializer can handle objects of a single type - see\r
- * {@link SerializerMap}.\r
- * \r
- * @since 7.0\r
- */\r
-public interface VaadinSerializer {\r
-\r
-    /**\r
-     * Creates and deserializes an object received from the server.\r
-     * \r
-     * @param jsonValue\r
-     *            JSON map from property name to property value\r
-     * @param idMapper\r
-     *            mapper from paintable id to paintable, used to decode\r
-     *            references to paintables\r
-     * @return deserialized object\r
-     */\r
-    // TODO Object -> something\r
-    Object deserialize(JSONObject jsonValue, VPaintableMap idMapper);\r
-\r
-}\r
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.client.communication;
+
+import com.google.gwt.json.client.JSONObject;
+import com.vaadin.terminal.gwt.client.VPaintableMap;
+
+/**
+ * Serializer that can deserialize custom objects received from the server.
+ * 
+ * Each serializer can handle objects of a single type - see
+ * {@link SerializerMap}.
+ * 
+ * @since 7.0
+ */
+public interface VaadinSerializer {
+
+    /**
+     * Creates and deserializes an object received from the server.
+     * 
+     * @param jsonValue
+     *            JSON map from property name to property value
+     * @param idMapper
+     *            mapper from paintable id to paintable, used to decode
+     *            references to paintables
+     * @return deserialized object
+     */
+    // TODO Object -> something
+    Object deserialize(JSONObject jsonValue, VPaintableMap idMapper);
+
+}
index dd915106c57c3ab313a6ea7dbaa8d32d5e0e9bae..e452ba691006661426130d1417c44b8dd1bac344 100644 (file)
@@ -1,65 +1,65 @@
-/*\r
-@VaadinApache2LicenseForJavaFiles@\r
- */\r
-\r
-package com.vaadin.terminal.gwt.client.ui;\r
-\r
-import com.vaadin.terminal.gwt.client.ComponentState;\r
-import com.vaadin.ui.Button;\r
-\r
-/**\r
- * Shared state for Button and NativeButton.\r
- * \r
- * @see ComponentState\r
- * \r
- * @since 7.0\r
- */\r
-public class VButtonState extends ComponentState {\r
-    private boolean disableOnClick = false;\r
-    private int clickShortcutKeyCode = 0;\r
-\r
-    /**\r
-     * Checks whether the button should be disabled on the client side on next\r
-     * click.\r
-     * \r
-     * @return true if the button should be disabled on click\r
-     */\r
-    public boolean isDisableOnClick() {\r
-        return disableOnClick;\r
-    }\r
-\r
-    /**\r
-     * Sets whether the button should be disabled on the client side on next\r
-     * click.\r
-     * \r
-     * @param disableOnClick\r
-     *            true if the button should be disabled on click\r
-     */\r
-    public void setDisableOnClick(boolean disableOnClick) {\r
-        this.disableOnClick = disableOnClick;\r
-    }\r
-\r
-    /**\r
-     * Returns the key code for activating the button via a keyboard shortcut.\r
-     * \r
-     * See {@link Button#setClickShortcut(int, int...)} for more information.\r
-     * \r
-     * @return key code or 0 for none\r
-     */\r
-    public int getClickShortcutKeyCode() {\r
-        return clickShortcutKeyCode;\r
-    }\r
-\r
-    /**\r
-     * Sets the key code for activating the button via a keyboard shortcut.\r
-     * \r
-     * See {@link Button#setClickShortcut(int, int...)} for more information.\r
-     * \r
-     * @param clickShortcutKeyCode\r
-     *            key code or 0 for none\r
-     */\r
-    public void setClickShortcutKeyCode(int clickShortcutKeyCode) {\r
-        this.clickShortcutKeyCode = clickShortcutKeyCode;\r
-    }\r
-\r
-}\r
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.client.ui;
+
+import com.vaadin.terminal.gwt.client.ComponentState;
+import com.vaadin.ui.Button;
+
+/**
+ * Shared state for Button and NativeButton.
+ * 
+ * @see ComponentState
+ * 
+ * @since 7.0
+ */
+public class VButtonState extends ComponentState {
+    private boolean disableOnClick = false;
+    private int clickShortcutKeyCode = 0;
+
+    /**
+     * Checks whether the button should be disabled on the client side on next
+     * click.
+     * 
+     * @return true if the button should be disabled on click
+     */
+    public boolean isDisableOnClick() {
+        return disableOnClick;
+    }
+
+    /**
+     * Sets whether the button should be disabled on the client side on next
+     * click.
+     * 
+     * @param disableOnClick
+     *            true if the button should be disabled on click
+     */
+    public void setDisableOnClick(boolean disableOnClick) {
+        this.disableOnClick = disableOnClick;
+    }
+
+    /**
+     * Returns the key code for activating the button via a keyboard shortcut.
+     * 
+     * See {@link Button#setClickShortcut(int, int...)} for more information.
+     * 
+     * @return key code or 0 for none
+     */
+    public int getClickShortcutKeyCode() {
+        return clickShortcutKeyCode;
+    }
+
+    /**
+     * Sets the key code for activating the button via a keyboard shortcut.
+     * 
+     * See {@link Button#setClickShortcut(int, int...)} for more information.
+     * 
+     * @param clickShortcutKeyCode
+     *            key code or 0 for none
+     */
+    public void setClickShortcutKeyCode(int clickShortcutKeyCode) {
+        this.clickShortcutKeyCode = clickShortcutKeyCode;
+    }
+
+}
index cd7fdf888f6302d65e139d93dfd8abe71e4ec4fe..a5be3be84d4c2046342bc7166eb41cbbec5de801 100644 (file)
-/*\r
-@VaadinApache2LicenseForJavaFiles@\r
- */\r
-\r
-package com.vaadin.terminal.gwt.widgetsetutils;\r
-\r
-import java.io.PrintWriter;\r
-import java.util.Date;\r
-\r
-import com.google.gwt.core.client.GWT;\r
-import com.google.gwt.core.ext.Generator;\r
-import com.google.gwt.core.ext.GeneratorContext;\r
-import com.google.gwt.core.ext.TreeLogger;\r
-import com.google.gwt.core.ext.TreeLogger.Type;\r
-import com.google.gwt.core.ext.UnableToCompleteException;\r
-import com.google.gwt.core.ext.typeinfo.JClassType;\r
-import com.google.gwt.core.ext.typeinfo.JMethod;\r
-import com.google.gwt.core.ext.typeinfo.JPrimitiveType;\r
-import com.google.gwt.core.ext.typeinfo.JType;\r
-import com.google.gwt.core.ext.typeinfo.TypeOracle;\r
-import com.google.gwt.json.client.JSONArray;\r
-import com.google.gwt.json.client.JSONObject;\r
-import com.google.gwt.user.rebind.ClassSourceFileComposerFactory;\r
-import com.google.gwt.user.rebind.SourceWriter;\r
-import com.vaadin.terminal.gwt.client.VPaintableMap;\r
-import com.vaadin.terminal.gwt.client.communication.JsonDecoder;\r
-import com.vaadin.terminal.gwt.client.communication.VaadinSerializer;\r
-\r
-/**\r
- * GWT generator for creating serializer classes for custom classes sent from\r
- * server to client.\r
- * \r
- * Only fields with a correspondingly named setter are deserialized.\r
- * \r
- * @since 7.0\r
- */\r
-public class SerializerGenerator extends Generator {\r
-\r
-    private String packageName;\r
-    private String beanSerializerClassName;\r
-\r
-    @Override\r
-    public String generate(TreeLogger logger, GeneratorContext context,\r
-            String beanTypeName) throws UnableToCompleteException {\r
-        String beanSerializerTypeName = beanTypeName + "_Serializer";\r
-        try {\r
-            TypeOracle typeOracle = context.getTypeOracle();\r
-\r
-            // get classType and save instance variables\r
-            JClassType classType = typeOracle.getType(beanTypeName);\r
-            packageName = classType.getPackage().getName();\r
-            beanSerializerClassName = classType.getSimpleSourceName()\r
-                    + "_Serializer";\r
-            // Generate class source code\r
-            generateClass(logger, context, beanTypeName, beanSerializerTypeName);\r
-        } catch (Exception e) {\r
-            logger.log(TreeLogger.ERROR, "SerializerGenerator failed for "\r
-                    + beanTypeName, e);\r
-        }\r
-        // return the fully qualifed name of the class generated\r
-        return packageName + "." + beanSerializerClassName;\r
-    }\r
-\r
-    /**\r
-     * Generate source code for a VaadinSerializer implementation.\r
-     * \r
-     * @param logger\r
-     *            Logger object\r
-     * @param context\r
-     *            Generator context\r
-     * @param beanTypeName\r
-     *            bean type for which the serializer is to be generated\r
-     * @param beanSerializerTypeName\r
-     *            name of the serializer class to generate\r
-     */\r
-    private void generateClass(TreeLogger logger, GeneratorContext context,\r
-            String beanTypeName, String beanSerializerTypeName) {\r
-        // get print writer that receives the source code\r
-        PrintWriter printWriter = null;\r
-        printWriter = context.tryCreate(logger, packageName,\r
-                beanSerializerClassName);\r
-\r
-        // print writer if null, source code has ALREADY been generated\r
-        if (printWriter == null) {\r
-            return;\r
-        }\r
-        Date date = new Date();\r
-        TypeOracle typeOracle = context.getTypeOracle();\r
-        logger.log(Type.DEBUG, "Processing serializable type " + beanTypeName\r
-                + "...");\r
-\r
-        // init composer, set class properties, create source writer\r
-        ClassSourceFileComposerFactory composer = null;\r
-        composer = new ClassSourceFileComposerFactory(packageName,\r
-                beanSerializerClassName);\r
-        composer.addImport(GWT.class.getName());\r
-        composer.addImport(JSONArray.class.getName());\r
-        // composer.addImport(JSONObject.class.getName());\r
-        // composer.addImport(VPaintableMap.class.getName());\r
-        composer.addImport(JsonDecoder.class.getName());\r
-        // composer.addImport(VaadinSerializer.class.getName());\r
-\r
-        composer.addImplementedInterface(VaadinSerializer.class.getName());\r
-\r
-        SourceWriter sourceWriter = composer.createSourceWriter(context,\r
-                printWriter);\r
-        sourceWriter.indent();\r
-\r
-        sourceWriter.println("public " + beanTypeName + " deserialize("\r
-                + JSONObject.class.getName() + " jsonValue, "\r
-                + VPaintableMap.class.getName() + " idMapper) {");\r
-        sourceWriter.indent();\r
-\r
-        // VButtonState state = GWT.create(VButtonState.class);\r
-        sourceWriter.println(beanTypeName + " state = GWT.create("\r
-                + beanTypeName + ".class);");\r
-        JClassType beanType = typeOracle.findType(beanTypeName);\r
-        for (JMethod method : beanType.getMethods()) {\r
-            // Process all setters that have corresponding fields\r
-            if (!method.isPublic() || method.isStatic()\r
-                    || !method.getName().startsWith("set")\r
-                    || method.getParameterTypes().length != 1) {\r
-                // Not setter, skip to next method\r
-                continue;\r
-\r
-            }\r
-            String setterName = method.getName();\r
-            String capitalizedFieldName = setterName.substring(3);\r
-            String fieldName = decapitalize(capitalizedFieldName);\r
-            JType setterParameterType = method.getParameterTypes()[0];\r
-\r
-            logger.log(Type.DEBUG, "* Processing field " + fieldName + " in "\r
-                    + beanTypeName);\r
-\r
-            String jsonFieldName = "json" + capitalizedFieldName;\r
-            // JSONArray jsonHeight = (JSONArray) jsonValue.get("height");\r
-            sourceWriter.println("JSONArray " + jsonFieldName\r
-                    + " = (JSONArray) jsonValue.get(\"" + fieldName + "\");");\r
-\r
-            // state.setHeight((String)\r
-            // JsonDecoder.convertValue(jsonFieldValue,idMapper));\r
-\r
-            String fieldType;\r
-            JPrimitiveType primitiveType = setterParameterType.isPrimitive();\r
-            if (primitiveType != null) {\r
-                // This is a primitive type -> must used the boxed type\r
-                fieldType = primitiveType.getQualifiedBoxedSourceName();\r
-            } else {\r
-                fieldType = setterParameterType.getQualifiedSourceName();\r
-            }\r
-\r
-            sourceWriter.println("state." + setterName + "((" + fieldType\r
-                    + ") JsonDecoder.convertValue(" + jsonFieldName\r
-                    + ", idMapper));");\r
-        }\r
-\r
-        // return state;\r
-        sourceWriter.println("return state;");\r
-        sourceWriter.println("}");\r
-        sourceWriter.outdent();\r
-\r
-        // End of class\r
-        sourceWriter.println("}");\r
-        sourceWriter.outdent();\r
-\r
-        // commit generated class\r
-        context.commit(logger, printWriter);\r
-        logger.log(Type.INFO,\r
-                "Done. (" + (new Date().getTime() - date.getTime()) / 1000\r
-                        + "seconds)");\r
-\r
-    }\r
-\r
-    private String decapitalize(String name) {\r
-        return name.substring(0, 1).toLowerCase() + name.substring(1);\r
-    }\r
-}\r
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.widgetsetutils;
+
+import java.io.PrintWriter;
+import java.util.Date;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.core.ext.Generator;
+import com.google.gwt.core.ext.GeneratorContext;
+import com.google.gwt.core.ext.TreeLogger;
+import com.google.gwt.core.ext.TreeLogger.Type;
+import com.google.gwt.core.ext.UnableToCompleteException;
+import com.google.gwt.core.ext.typeinfo.JClassType;
+import com.google.gwt.core.ext.typeinfo.JMethod;
+import com.google.gwt.core.ext.typeinfo.JPrimitiveType;
+import com.google.gwt.core.ext.typeinfo.JType;
+import com.google.gwt.core.ext.typeinfo.TypeOracle;
+import com.google.gwt.json.client.JSONArray;
+import com.google.gwt.json.client.JSONObject;
+import com.google.gwt.user.rebind.ClassSourceFileComposerFactory;
+import com.google.gwt.user.rebind.SourceWriter;
+import com.vaadin.terminal.gwt.client.VPaintableMap;
+import com.vaadin.terminal.gwt.client.communication.JsonDecoder;
+import com.vaadin.terminal.gwt.client.communication.VaadinSerializer;
+
+/**
+ * GWT generator for creating serializer classes for custom classes sent from
+ * server to client.
+ * 
+ * Only fields with a correspondingly named setter are deserialized.
+ * 
+ * @since 7.0
+ */
+public class SerializerGenerator extends Generator {
+
+    private String packageName;
+    private String beanSerializerClassName;
+
+    @Override
+    public String generate(TreeLogger logger, GeneratorContext context,
+            String beanTypeName) throws UnableToCompleteException {
+        String beanSerializerTypeName = beanTypeName + "_Serializer";
+        try {
+            TypeOracle typeOracle = context.getTypeOracle();
+
+            // get classType and save instance variables
+            JClassType classType = typeOracle.getType(beanTypeName);
+            packageName = classType.getPackage().getName();
+            beanSerializerClassName = classType.getSimpleSourceName()
+                    + "_Serializer";
+            // Generate class source code
+            generateClass(logger, context, beanTypeName, beanSerializerTypeName);
+        } catch (Exception e) {
+            logger.log(TreeLogger.ERROR, "SerializerGenerator failed for "
+                    + beanTypeName, e);
+        }
+        // return the fully qualifed name of the class generated
+        return packageName + "." + beanSerializerClassName;
+    }
+
+    /**
+     * Generate source code for a VaadinSerializer implementation.
+     * 
+     * @param logger
+     *            Logger object
+     * @param context
+     *            Generator context
+     * @param beanTypeName
+     *            bean type for which the serializer is to be generated
+     * @param beanSerializerTypeName
+     *            name of the serializer class to generate
+     */
+    private void generateClass(TreeLogger logger, GeneratorContext context,
+            String beanTypeName, String beanSerializerTypeName) {
+        // get print writer that receives the source code
+        PrintWriter printWriter = null;
+        printWriter = context.tryCreate(logger, packageName,
+                beanSerializerClassName);
+
+        // print writer if null, source code has ALREADY been generated
+        if (printWriter == null) {
+            return;
+        }
+        Date date = new Date();
+        TypeOracle typeOracle = context.getTypeOracle();
+        logger.log(Type.DEBUG, "Processing serializable type " + beanTypeName
+                + "...");
+
+        // init composer, set class properties, create source writer
+        ClassSourceFileComposerFactory composer = null;
+        composer = new ClassSourceFileComposerFactory(packageName,
+                beanSerializerClassName);
+        composer.addImport(GWT.class.getName());
+        composer.addImport(JSONArray.class.getName());
+        // composer.addImport(JSONObject.class.getName());
+        // composer.addImport(VPaintableMap.class.getName());
+        composer.addImport(JsonDecoder.class.getName());
+        // composer.addImport(VaadinSerializer.class.getName());
+
+        composer.addImplementedInterface(VaadinSerializer.class.getName());
+
+        SourceWriter sourceWriter = composer.createSourceWriter(context,
+                printWriter);
+        sourceWriter.indent();
+
+        sourceWriter.println("public " + beanTypeName + " deserialize("
+                + JSONObject.class.getName() + " jsonValue, "
+                + VPaintableMap.class.getName() + " idMapper) {");
+        sourceWriter.indent();
+
+        // VButtonState state = GWT.create(VButtonState.class);
+        sourceWriter.println(beanTypeName + " state = GWT.create("
+                + beanTypeName + ".class);");
+        JClassType beanType = typeOracle.findType(beanTypeName);
+        for (JMethod method : beanType.getMethods()) {
+            // Process all setters that have corresponding fields
+            if (!method.isPublic() || method.isStatic()
+                    || !method.getName().startsWith("set")
+                    || method.getParameterTypes().length != 1) {
+                // Not setter, skip to next method
+                continue;
+
+            }
+            String setterName = method.getName();
+            String capitalizedFieldName = setterName.substring(3);
+            String fieldName = decapitalize(capitalizedFieldName);
+            JType setterParameterType = method.getParameterTypes()[0];
+
+            logger.log(Type.DEBUG, "* Processing field " + fieldName + " in "
+                    + beanTypeName);
+
+            String jsonFieldName = "json" + capitalizedFieldName;
+            // JSONArray jsonHeight = (JSONArray) jsonValue.get("height");
+            sourceWriter.println("JSONArray " + jsonFieldName
+                    + " = (JSONArray) jsonValue.get(\"" + fieldName + "\");");
+
+            // state.setHeight((String)
+            // JsonDecoder.convertValue(jsonFieldValue,idMapper));
+
+            String fieldType;
+            JPrimitiveType primitiveType = setterParameterType.isPrimitive();
+            if (primitiveType != null) {
+                // This is a primitive type -> must used the boxed type
+                fieldType = primitiveType.getQualifiedBoxedSourceName();
+            } else {
+                fieldType = setterParameterType.getQualifiedSourceName();
+            }
+
+            sourceWriter.println("state." + setterName + "((" + fieldType
+                    + ") JsonDecoder.convertValue(" + jsonFieldName
+                    + ", idMapper));");
+        }
+
+        // return state;
+        sourceWriter.println("return state;");
+        sourceWriter.println("}");
+        sourceWriter.outdent();
+
+        // End of class
+        sourceWriter.println("}");
+        sourceWriter.outdent();
+
+        // commit generated class
+        context.commit(logger, printWriter);
+        logger.log(Type.INFO,
+                "Done. (" + (new Date().getTime() - date.getTime()) / 1000
+                        + "seconds)");
+
+    }
+
+    private String decapitalize(String name) {
+        return name.substring(0, 1).toLowerCase() + name.substring(1);
+    }
+}
index 2255dbdd2ab00822b0fad56b86a48b622f02ed04..3536cbd1177a3d5d6186ed9552a865aee3e69bed 100644 (file)
-/*\r
-@VaadinApache2LicenseForJavaFiles@\r
- */\r
-\r
-package com.vaadin.terminal.gwt.widgetsetutils;\r
-\r
-import java.io.PrintWriter;\r
-import java.util.Date;\r
-\r
-import com.google.gwt.core.ext.Generator;\r
-import com.google.gwt.core.ext.GeneratorContext;\r
-import com.google.gwt.core.ext.TreeLogger;\r
-import com.google.gwt.core.ext.TreeLogger.Type;\r
-import com.google.gwt.core.ext.UnableToCompleteException;\r
-import com.google.gwt.core.ext.typeinfo.JClassType;\r
-import com.google.gwt.core.ext.typeinfo.TypeOracle;\r
-import com.google.gwt.user.rebind.ClassSourceFileComposerFactory;\r
-import com.google.gwt.user.rebind.SourceWriter;\r
-import com.vaadin.terminal.gwt.client.communication.SerializerMap;\r
-import com.vaadin.terminal.gwt.client.communication.SharedState;\r
-import com.vaadin.terminal.gwt.client.communication.VaadinSerializer;\r
-\r
-/**\r
- * GWT generator that creates a {@link SerializerMap} implementation (mapper\r
- * from type string to serializer instance) and serializer classes for all\r
- * subclasses of {@link SharedState}.\r
- * \r
- * @since 7.0\r
- */\r
-public class SerializerMapGenerator extends Generator {\r
-\r
-    private String packageName;\r
-    private String className;\r
-\r
-    @Override\r
-    public String generate(TreeLogger logger, GeneratorContext context,\r
-            String typeName) throws UnableToCompleteException {\r
-\r
-        try {\r
-            TypeOracle typeOracle = context.getTypeOracle();\r
-\r
-            // get classType and save instance variables\r
-            JClassType classType = typeOracle.getType(typeName);\r
-            packageName = classType.getPackage().getName();\r
-            className = classType.getSimpleSourceName() + "Impl";\r
-            // Generate class source code for SerializerMapImpl\r
-            generateClass(logger, context);\r
-\r
-            // Generate serializer classes for each subclass of SharedState\r
-            JClassType serializerType = typeOracle.findType(SharedState.class\r
-                    .getName());\r
-            JClassType[] serializerSubtypes = serializerType.getSubtypes();\r
-            SerializerGenerator sg = new SerializerGenerator();\r
-            for (JClassType type : serializerSubtypes) {\r
-                sg.generate(logger, context, type.getQualifiedSourceName());\r
-            }\r
-        } catch (Exception e) {\r
-            logger.log(TreeLogger.ERROR,\r
-                    "SerializerMapGenerator creation failed", e);\r
-        }\r
-        // return the fully qualifed name of the class generated\r
-        return packageName + "." + className;\r
-    }\r
-\r
-    /**\r
-     * Generate source code for WidgetMapImpl\r
-     * \r
-     * @param logger\r
-     *            Logger object\r
-     * @param context\r
-     *            Generator context\r
-     */\r
-    private void generateClass(TreeLogger logger, GeneratorContext context) {\r
-        // get print writer that receives the source code\r
-        PrintWriter printWriter = null;\r
-        printWriter = context.tryCreate(logger, packageName, className);\r
-        // print writer if null, source code has ALREADY been generated,\r
-        // return (WidgetMap is equal to all permutations atm)\r
-        if (printWriter == null) {\r
-            return;\r
-        }\r
-        logger.log(Type.INFO, "Detecting serializable data types...");\r
-        Date date = new Date();\r
-        TypeOracle typeOracle = context.getTypeOracle();\r
-        JClassType serializerType = typeOracle.findType(SharedState.class\r
-                .getName());\r
-        JClassType[] serializerSubtypes = serializerType.getSubtypes();\r
-\r
-        // init composer, set class properties, create source writer\r
-        ClassSourceFileComposerFactory composer = null;\r
-        composer = new ClassSourceFileComposerFactory(packageName, className);\r
-        composer.addImport("com.google.gwt.core.client.GWT");\r
-        composer.addImplementedInterface(SerializerMap.class.getName());\r
-        SourceWriter sourceWriter = composer.createSourceWriter(context,\r
-                printWriter);\r
-        sourceWriter.indent();\r
-\r
-        sourceWriter.println("public " + VaadinSerializer.class.getName()\r
-                + " getSerializer(String type) {");\r
-        sourceWriter.indent();\r
-\r
-        // TODO cache serializer instances in a map\r
-        for (JClassType type : serializerSubtypes) {\r
-            sourceWriter.println("if (type.equals(\""\r
-                    + type.getQualifiedSourceName() + "\")) {");\r
-            sourceWriter.indent();\r
-            sourceWriter.println("return GWT.create("\r
-                    + type.getQualifiedSourceName() + "_Serializer.class);");\r
-            sourceWriter.outdent();\r
-            sourceWriter.println("}");\r
-            logger.log(Type.INFO, "Configured serializer for " + type.getName());\r
-        }\r
-        sourceWriter\r
-                .println("throw new RuntimeException(\"No serializer found for class \"+type);");\r
-        sourceWriter.outdent();\r
-        sourceWriter.println("}");\r
-\r
-        // close generated class\r
-        sourceWriter.outdent();\r
-        sourceWriter.println("}");\r
-        // commit generated class\r
-        context.commit(logger, printWriter);\r
-        logger.log(Type.INFO,\r
-                "Done. (" + (new Date().getTime() - date.getTime()) / 1000\r
-                        + "seconds)");\r
-\r
-    }\r
-}\r
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.widgetsetutils;
+
+import java.io.PrintWriter;
+import java.util.Date;
+
+import com.google.gwt.core.ext.Generator;
+import com.google.gwt.core.ext.GeneratorContext;
+import com.google.gwt.core.ext.TreeLogger;
+import com.google.gwt.core.ext.TreeLogger.Type;
+import com.google.gwt.core.ext.UnableToCompleteException;
+import com.google.gwt.core.ext.typeinfo.JClassType;
+import com.google.gwt.core.ext.typeinfo.TypeOracle;
+import com.google.gwt.user.rebind.ClassSourceFileComposerFactory;
+import com.google.gwt.user.rebind.SourceWriter;
+import com.vaadin.terminal.gwt.client.communication.SerializerMap;
+import com.vaadin.terminal.gwt.client.communication.SharedState;
+import com.vaadin.terminal.gwt.client.communication.VaadinSerializer;
+
+/**
+ * GWT generator that creates a {@link SerializerMap} implementation (mapper
+ * from type string to serializer instance) and serializer classes for all
+ * subclasses of {@link SharedState}.
+ * 
+ * @since 7.0
+ */
+public class SerializerMapGenerator extends Generator {
+
+    private String packageName;
+    private String className;
+
+    @Override
+    public String generate(TreeLogger logger, GeneratorContext context,
+            String typeName) throws UnableToCompleteException {
+
+        try {
+            TypeOracle typeOracle = context.getTypeOracle();
+
+            // get classType and save instance variables
+            JClassType classType = typeOracle.getType(typeName);
+            packageName = classType.getPackage().getName();
+            className = classType.getSimpleSourceName() + "Impl";
+            // Generate class source code for SerializerMapImpl
+            generateClass(logger, context);
+
+            // Generate serializer classes for each subclass of SharedState
+            JClassType serializerType = typeOracle.findType(SharedState.class
+                    .getName());
+            JClassType[] serializerSubtypes = serializerType.getSubtypes();
+            SerializerGenerator sg = new SerializerGenerator();
+            for (JClassType type : serializerSubtypes) {
+                sg.generate(logger, context, type.getQualifiedSourceName());
+            }
+        } catch (Exception e) {
+            logger.log(TreeLogger.ERROR,
+                    "SerializerMapGenerator creation failed", e);
+        }
+        // return the fully qualifed name of the class generated
+        return packageName + "." + className;
+    }
+
+    /**
+     * Generate source code for WidgetMapImpl
+     * 
+     * @param logger
+     *            Logger object
+     * @param context
+     *            Generator context
+     */
+    private void generateClass(TreeLogger logger, GeneratorContext context) {
+        // get print writer that receives the source code
+        PrintWriter printWriter = null;
+        printWriter = context.tryCreate(logger, packageName, className);
+        // print writer if null, source code has ALREADY been generated,
+        // return (WidgetMap is equal to all permutations atm)
+        if (printWriter == null) {
+            return;
+        }
+        logger.log(Type.INFO, "Detecting serializable data types...");
+        Date date = new Date();
+        TypeOracle typeOracle = context.getTypeOracle();
+        JClassType serializerType = typeOracle.findType(SharedState.class
+                .getName());
+        JClassType[] serializerSubtypes = serializerType.getSubtypes();
+
+        // init composer, set class properties, create source writer
+        ClassSourceFileComposerFactory composer = null;
+        composer = new ClassSourceFileComposerFactory(packageName, className);
+        composer.addImport("com.google.gwt.core.client.GWT");
+        composer.addImplementedInterface(SerializerMap.class.getName());
+        SourceWriter sourceWriter = composer.createSourceWriter(context,
+                printWriter);
+        sourceWriter.indent();
+
+        sourceWriter.println("public " + VaadinSerializer.class.getName()
+                + " getSerializer(String type) {");
+        sourceWriter.indent();
+
+        // TODO cache serializer instances in a map
+        for (JClassType type : serializerSubtypes) {
+            sourceWriter.println("if (type.equals(\""
+                    + type.getQualifiedSourceName() + "\")) {");
+            sourceWriter.indent();
+            sourceWriter.println("return GWT.create("
+                    + type.getQualifiedSourceName() + "_Serializer.class);");
+            sourceWriter.outdent();
+            sourceWriter.println("}");
+            logger.log(Type.INFO, "Configured serializer for " + type.getName());
+        }
+        sourceWriter
+                .println("throw new RuntimeException(\"No serializer found for class \"+type);");
+        sourceWriter.outdent();
+        sourceWriter.println("}");
+
+        // close generated class
+        sourceWriter.outdent();
+        sourceWriter.println("}");
+        // commit generated class
+        context.commit(logger, printWriter);
+        logger.log(Type.INFO,
+                "Done. (" + (new Date().getTime() - date.getTime()) / 1000
+                        + "seconds)");
+
+    }
+}