]> source.dussan.org Git - vaadin-framework.git/commitdiff
fixes #3969, paintable coding now instance wide. eats more memory but safer on contex...
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Tue, 12 Jan 2010 11:18:09 +0000 (11:18 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Tue, 12 Jan 2010 11:18:09 +0000 (11:18 +0000)
svn changeset:10689/svn branch:6.2

src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java
src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java

index 4ea806e29e3c93655118a811f8908e72243617d1..39f4e845f7b69ab5bcf990fac888bfe12e797814 100644 (file)
@@ -32,6 +32,8 @@ public class ApplicationConfiguration {
 
     private Class<? extends Paintable>[] classes = new Class[1024];
 
+    private String windowId;
+
     private static ArrayList<ApplicationConnection> unstartedApplications = new ArrayList<ApplicationConnection>();
     private static ArrayList<ApplicationConnection> runningApplications = new ArrayList<ApplicationConnection>();
 
@@ -239,7 +241,7 @@ public class ApplicationConfiguration {
     public void addComponentMappings(ValueMap valueMap, WidgetSet widgetSet) {
         JsArrayString keyArray = valueMap.getKeyArray();
         for (int i = 0; i < keyArray.length(); i++) {
-            String key = keyArray.get(i);
+            String key = keyArray.get(i).intern();
             int value = valueMap.getInt(key);
             classes[value] = widgetSet.getImplementationByClassName(key);
             if (classes[value] == VUnknownComponent.class) {
@@ -247,10 +249,20 @@ public class ApplicationConfiguration {
                     unknownComponents = new HashMap<String, String>();
                 }
                 unknownComponents.put("" + value, key);
+            } else if (key == "com.vaadin.ui.Window") {
+                windowId = "" + value;
             }
         }
     }
 
+    /**
+     * @return the integer value that is used to code top level windows
+     *         "com.vaadin.ui.Window"
+     */
+    String getEncodedWindowTag() {
+        return windowId;
+    }
+
     String getUnknownServerClassNameByEncodedTagName(String tag) {
         if (unknownComponents != null) {
             return unknownComponents.get(tag);
index a523e8b00eb5e16b221c7d5bc18f63dde0b5e8d2..70cb99bc233617e69ea7ec8a3fbac6ca6c9c83a2 100755 (executable)
@@ -789,7 +789,8 @@ public class ApplicationConnection {
                     updatedWidgets.add(idToPaintableDetail.get(uidl.getId())
                             .getComponent());
                 } else {
-                    if (!uidl.getTag().equals("0")) {
+                    if (!uidl.getTag().equals(
+                            configuration.getEncodedWindowTag())) {
                         ClientExceptionHandler
                                 .displayError("Received update for "
                                         + uidl.getTag()
index dc2973ebe525925fd2e6e1cb0d060747eb8e67a3..63991b8b5bbaa3145153d519dfbd79f2d18c9a94 100644 (file)
@@ -1841,18 +1841,16 @@ public abstract class AbstractCommunicationManager implements
         }
     }
 
-    private static HashMap<Class<? extends Paintable>, Integer> typeToKey = new HashMap<Class<? extends Paintable>, Integer>();
-    private static int nextTypeKey = 0;
-
-    static String getTagForType(Class<? extends Paintable> class1) {
-        synchronized (typeToKey) {
-            Integer object = typeToKey.get(class1);
-            if (object == null) {
-                object = nextTypeKey++;
-                typeToKey.put(class1, object);
-            }
-            return object.toString();
+    private HashMap<Class<? extends Paintable>, Integer> typeToKey = new HashMap<Class<? extends Paintable>, Integer>();
+    private int nextTypeKey = 0;
+
+    String getTagForType(Class<? extends Paintable> class1) {
+        Integer object = typeToKey.get(class1);
+        if (object == null) {
+            object = nextTypeKey++;
+            typeToKey.put(class1, object);
         }
+        return object.toString();
     }
 
     /**
index 649a5e129db94c6279a7ad81ac877ec02feb9e07..54695fd3dbb2b87dd80f115aeea08ca4000babb9 100644 (file)
@@ -1041,7 +1041,7 @@ public class JsonPaintTarget implements PaintTarget {
         }
 
         usedPaintableTypes.add(class1);
-        return AbstractCommunicationManager.getTagForType(class1);
+        return manager.getTagForType(class1);
 
     }