]> source.dussan.org Git - vaadin-framework.git/commitdiff
Split Paintable handling from ApplicationConnection to PaintableMap.
authorArtur Signell <artur@vaadin.com>
Fri, 20 Jan 2012 15:23:55 +0000 (17:23 +0200)
committerArtur Signell <artur@vaadin.com>
Fri, 20 Jan 2012 15:23:55 +0000 (17:23 +0200)
19 files changed:
src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
src/com/vaadin/terminal/gwt/client/ComponentDetail.java
src/com/vaadin/terminal/gwt/client/ComponentLocator.java
src/com/vaadin/terminal/gwt/client/PaintableMap.java [new file with mode: 0644]
src/com/vaadin/terminal/gwt/client/UIDL.java
src/com/vaadin/terminal/gwt/client/Util.java
src/com/vaadin/terminal/gwt/client/VCaption.java
src/com/vaadin/terminal/gwt/client/VDebugConsole.java
src/com/vaadin/terminal/gwt/client/VUIDLBrowser.java
src/com/vaadin/terminal/gwt/client/ui/ClickEventHandler.java
src/com/vaadin/terminal/gwt/client/ui/LayoutClickEventHandler.java
src/com/vaadin/terminal/gwt/client/ui/VDragAndDropWrapper.java
src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java
src/com/vaadin/terminal/gwt/client/ui/VOrderedLayout.java
src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java
src/com/vaadin/terminal/gwt/client/ui/VTextField.java
src/com/vaadin/terminal/gwt/client/ui/dd/VDragSourceIs.java
src/com/vaadin/terminal/gwt/client/ui/dd/VIsOverId.java
src/com/vaadin/terminal/gwt/client/ui/dd/VItemIdIs.java

index 0b50c115973ff694822bfa2068b71240bd8d5a48..04703b2dd0001d7506b8f84e2f40034586687b91 100644 (file)
@@ -106,9 +106,6 @@ public class ApplicationConnection {
 
     private final ArrayList<String> pendingVariables = new ArrayList<String>();
 
-    private final ComponentDetailMap idToPaintableDetail = ComponentDetailMap
-            .create();
-
     private WidgetSet widgetSet;
 
     private VContextMenu contextMenu = null;
@@ -149,8 +146,6 @@ public class ApplicationConnection {
 
     private Set<Paintable> zeroHeightComponents = null;
 
-    private Set<String> unregistryBag = new HashSet<String>();
-
     public ApplicationConnection() {
         view = GWT.create(VView.class);
     }
@@ -418,7 +413,7 @@ public class ApplicationConnection {
      */
     void highlightComponent(Paintable paintable) {
         String params = getRepaintAllParameters() + "&highlightComponent="
-                + getPid(paintable);
+                + paintableMap.getPid(paintable);
         makeUidlRequest("", params, false);
     }
 
@@ -775,7 +770,8 @@ public class ApplicationConnection {
         for (int i = 1; i < variableBurst.size(); i += 2) {
             String id = variableBurst.get(i);
             id = id.substring(0, id.indexOf(VAR_FIELD_SEPARATOR));
-            if (!idToPaintableDetail.containsKey(id) && !id.startsWith("DD")) {
+            if (!getPaintableMap().hasPaintable(id)
+                    && !getPaintableMap().isDragAndDropPaintable(id)) {
                 // variable owner does not exist anymore
                 variableBurst.remove(i - 1);
                 variableBurst.remove(i - 1);
@@ -932,7 +928,7 @@ public class ApplicationConnection {
                     if (meta.containsKey("repaintAll")) {
                         repaintAll = true;
                         view.clear();
-                        idToPaintableDetail.clear();
+                        getPaintableMap().clear();
                         if (meta.containsKey("invalidLayouts")) {
                             validatingLayouts = true;
                             zeroWidthComponents = new HashSet<Paintable>();
@@ -970,16 +966,13 @@ public class ApplicationConnection {
                         final UIDL change = changes.get(i).cast();
                         final UIDL uidl = change.getChildUIDL(0);
                         // TODO optimize
-                        final Paintable paintable = getPaintable(uidl.getId());
+                        final Paintable paintable = paintableMap
+                                .getPaintable(uidl.getId());
                         if (paintable != null) {
                             paintable.updateFromUIDL(uidl,
                                     ApplicationConnection.this);
-                            // paintable may have changed during render to
-                            // another
-                            // implementation, use the new one for updated
-                            // widgets map
-                            updatedWidgets.add(idToPaintableDetail.get(
-                                    uidl.getId()).getComponent());
+
+                            updatedWidgets.add(paintable);
                         } else {
                             if (!uidl.getTag().equals(
                                     configuration.getEncodedWindowTag())) {
@@ -989,14 +982,13 @@ public class ApplicationConnection {
                                         + uidl.getId() + ") rendered.");
                             } else {
                                 String pid = uidl.getId();
-                                if (!idToPaintableDetail.containsKey(pid)) {
-                                    registerPaintable(pid, view);
+                                if (!paintableMap.hasPaintable(pid)) {
+                                    paintableMap.registerPaintable(pid, view);
                                 }
                                 // VView does not call updateComponent so we
                                 // register any event listeners here
-                                ComponentDetail cd = idToPaintableDetail
-                                        .get(pid);
-                                cd.registerEventListenersFromUIDL(uidl);
+                                paintableMap.registerEventListenersFromUIDL(
+                                        pid, uidl);
 
                                 // Finally allow VView to update itself
                                 view.updateFromUIDL(uidl,
@@ -1021,16 +1013,14 @@ public class ApplicationConnection {
                 sizeUpdatedWidgets.addAll(componentCaptionSizeChanges);
 
                 for (Paintable paintable : updatedWidgets) {
-                    ComponentDetail detail = idToPaintableDetail
-                            .get(getPid(paintable));
-                    Widget widget = (Widget) paintable;
-                    Size oldSize = detail.getOffsetSize();
+                    Widget widget = paintableMap.getWidget(paintable);
+                    Size oldSize = paintableMap.getOffsetSize(paintable);
                     Size newSize = new Size(widget.getOffsetWidth(),
                             widget.getOffsetHeight());
 
                     if (oldSize == null || !oldSize.equals(newSize)) {
                         sizeUpdatedWidgets.add(paintable);
-                        detail.setOffsetSize(newSize);
+                        paintableMap.setOffsetSize(paintable, newSize);
                     }
 
                 }
@@ -1084,9 +1074,9 @@ public class ApplicationConnection {
                      * idToPaintableDetail is already cleanded at the start of
                      * the changeset handling, bypass cleanup.
                      */
-                    unregistryBag.clear();
+                    paintableMap.purgeUnregistryBag(false);
                 } else {
-                    purgeUnregistryBag();
+                    paintableMap.purgeUnregistryBag(true);
                 }
 
                 // TODO build profiling for widget impl loading time
@@ -1096,8 +1086,7 @@ public class ApplicationConnection {
                 VConsole.log(" Processing time was "
                         + String.valueOf(prosessingTime) + "ms for "
                         + jsonText.length() + " characters of JSON");
-                VConsole.log("Referenced paintables: "
-                        + idToPaintableDetail.size());
+                VConsole.log("Referenced paintables: " + paintableMap.size());
 
                 endRequest();
 
@@ -1116,164 +1105,6 @@ public class ApplicationConnection {
        }
     }-*/;
 
-    public void registerPaintable(String pid, Paintable paintable) {
-        ComponentDetail componentDetail = new ComponentDetail(this, pid,
-                paintable);
-        idToPaintableDetail.put(pid, componentDetail);
-        setPid(((Widget) paintable).getElement(), pid);
-    }
-
-    private native void setPid(Element el, String pid)
-    /*-{
-       el.tkPid = pid;
-    }-*/;
-
-    /**
-     * Gets the paintableId for a specific paintable (a.k.a Vaadin Widget).
-     * <p>
-     * The paintableId is used in the UIDL to identify a specific widget
-     * instance, effectively linking the widget with it's server side Component.
-     * </p>
-     * 
-     * @param paintable
-     *            the paintable who's id is needed
-     * @return the id for the given paintable
-     */
-    public String getPid(Paintable paintable) {
-        return getPid(((Widget) paintable).getElement());
-    }
-
-    /**
-     * Gets the paintableId using a DOM element - the element should be the main
-     * element for a paintable otherwise no id will be found. Use
-     * {@link #getPid(Paintable)} instead whenever possible.
-     * 
-     * @see #getPid(Paintable)
-     * @param el
-     *            element of the paintable whose pid is desired
-     * @return the pid of the element's paintable, if it's a paintable
-     */
-    public native String getPid(Element el)
-    /*-{
-       return el.tkPid;
-    }-*/;
-
-    /**
-     * Gets the main element for the paintable with the given id. The revers of
-     * {@link #getPid(Element)}.
-     * 
-     * @param pid
-     *            the pid of the widget whose element is desired
-     * @return the element for the paintable corresponding to the pid
-     */
-    public Element getElementByPid(String pid) {
-        return ((Widget) getPaintable(pid)).getElement();
-    }
-
-    /**
-     * Unregisters the given paintable; always use after removing a paintable.
-     * This method does not remove the paintable from the DOM, but marks the
-     * paintable so that ApplicationConnection may clean up its references to
-     * it. Removing the widget from DOM is component containers responsibility.
-     * 
-     * @param p
-     *            the paintable to remove
-     */
-    public void unregisterPaintable(Paintable p) {
-
-        // add to unregistry que
-
-        if (p == null) {
-            VConsole.error("WARN: Trying to unregister null paintable");
-            return;
-        }
-        String id = getPid(p);
-        if (id == null) {
-            /*
-             * Uncomment the following to debug unregistring components. No
-             * paintables with null id should end here. At least one exception
-             * is our VScrollTableRow, that is hacked to fake it self as a
-             * Paintable to build support for sizing easier.
-             */
-            // if (!(p instanceof VScrollTableRow)) {
-            // VConsole.log("Trying to unregister Paintable not created by Application Connection.");
-            // }
-            if (p instanceof HasWidgets) {
-                unregisterChildPaintables((HasWidgets) p);
-            }
-        } else {
-            unregistryBag.add(id);
-            if (p instanceof HasWidgets) {
-                unregisterChildPaintables((HasWidgets) p);
-            }
-        }
-    }
-
-    private void purgeUnregistryBag() {
-        for (String id : unregistryBag) {
-            ComponentDetail componentDetail = idToPaintableDetail.get(id);
-            if (componentDetail == null) {
-                /*
-                 * this should never happen, but it does :-( See e.g.
-                 * com.vaadin.tests.components.accordion.RemoveTabs (with test
-                 * script)
-                 */
-                VConsole.error("ApplicationConnetion tried to unregister component (id="
-                        + id
-                        + ") that is never registered (or already unregistered)");
-                continue;
-            }
-            // check if can be cleaned
-            Widget component = (Widget) componentDetail.getComponent();
-            if (!component.isAttached()) {
-                // clean reference from ac to paintable
-                idToPaintableDetail.remove(id);
-            }
-            /*
-             * else NOP : same component has been reattached to another parent
-             * or replaced by another component implementation.
-             */
-        }
-
-        unregistryBag.clear();
-    }
-
-    /**
-     * Unregisters a paintable and all it's child paintables recursively. Use
-     * when after removing a paintable that contains other paintables. Does not
-     * unregister the given container itself. Does not actually remove the
-     * paintable from the DOM.
-     * 
-     * @see #unregisterPaintable(Paintable)
-     * @param container
-     */
-    public void unregisterChildPaintables(HasWidgets container) {
-        final Iterator<Widget> it = container.iterator();
-        while (it.hasNext()) {
-            final Widget w = it.next();
-            if (w instanceof Paintable) {
-                unregisterPaintable((Paintable) w);
-            } else if (w instanceof HasWidgets) {
-                unregisterChildPaintables((HasWidgets) w);
-            }
-        }
-    }
-
-    /**
-     * Returns Paintable element by its id
-     * 
-     * @param id
-     *            Paintable ID
-     */
-    public Paintable getPaintable(String id) {
-        ComponentDetail componentDetail = idToPaintableDetail.get(id);
-        if (componentDetail == null) {
-            return null;
-        } else {
-            return componentDetail.getComponent();
-        }
-    }
-
     private void addVariableToQueue(String paintableId, String variableName,
             String encodedValue, boolean immediate, char type) {
         final String id = paintableId + VAR_FIELD_SEPARATOR + variableName
@@ -1396,7 +1227,7 @@ public class ApplicationConnection {
      */
     public void updateVariable(String paintableId, String variableName,
             Paintable newValue, boolean immediate) {
-        String pid = (newValue != null) ? getPid(newValue) : null;
+        String pid = paintableMap.getPid(newValue);
         addVariableToQueue(paintableId, variableName, pid, immediate, 'p');
     }
 
@@ -1556,7 +1387,7 @@ public class ApplicationConnection {
      *            the id of the paintable that owns the variable
      * @param variableName
      *            the name of the variable
-     * @param newValue
+     * @param map
      *            the new value to be sent
      * @param immediate
      *            true if the update is to be sent as soon as possible
@@ -1573,7 +1404,7 @@ public class ApplicationConnection {
             buf.append(escapeVariableValue(key));
             buf.append(VAR_ARRAYITEM_SEPARATOR);
             if (transportType == 'p') {
-                buf.append(getPid((Paintable) value));
+                buf.append(paintableMap.getPid((Paintable) value));
             } else {
                 buf.append(escapeVariableValue(String.valueOf(value)));
             }
@@ -1674,7 +1505,7 @@ public class ApplicationConnection {
                 // first char tells the type in array
                 buf.append(transportType);
                 if (transportType == 'p') {
-                    buf.append(getPid((Paintable) value));
+                    buf.append(paintableMap.getPid((Paintable) value));
                 } else {
                     buf.append(escapeVariableValue(String.valueOf(value)));
                 }
@@ -1757,22 +1588,15 @@ public class ApplicationConnection {
      */
     public boolean updateComponent(Widget component, UIDL uidl,
             boolean manageCaption) {
-        String pid = getPid(component.getElement());
+        Paintable paintable = paintableMap.getPaintable(component);
+
+        String pid = paintableMap.getPid(paintable);
         if (pid == null) {
             VConsole.error("Trying to update an unregistered component: "
                     + Util.getSimpleName(component));
             return true;
         }
 
-        ComponentDetail componentDetail = idToPaintableDetail.get(pid);
-
-        if (componentDetail == null) {
-            VConsole.error("ComponentDetail not found for "
-                    + Util.getSimpleName(component) + " with PID " + pid
-                    + ". This should not happen.");
-            return true;
-        }
-
         // If the server request that a cached instance should be used, do
         // nothing
         if (uidl.getBooleanAttribute("cached")) {
@@ -1781,7 +1605,7 @@ public class ApplicationConnection {
 
         // register the listened events by the server-side to the event-handler
         // of the component
-        componentDetail.registerEventListenersFromUIDL(uidl);
+        paintableMap.registerEventListenersFromUIDL(pid, uidl);
 
         // Visibility
         boolean visible = !uidl.getBooleanAttribute("invisible");
@@ -1807,7 +1631,7 @@ public class ApplicationConnection {
         if (!visible) {
             // component is invisible, delete old size to notify parent, if
             // later make visible
-            componentDetail.setOffsetSize(null);
+            paintableMap.setOffsetSize(paintable, null);
             return true;
         }
 
@@ -1821,8 +1645,8 @@ public class ApplicationConnection {
                 final Container parent = Util.getLayout(component);
                 if (parent != null) {
                     parent.replaceChildComponent(component, w);
-                    unregisterPaintable((Paintable) component);
-                    registerPaintable(uidl.getId(), (Paintable) w);
+                    paintableMap.unregisterPaintable(paintable);
+                    paintableMap.registerPaintable(uidl.getId(), (Paintable) w);
                     ((Paintable) w).updateFromUIDL(uidl, this);
                     return true;
                 }
@@ -1877,7 +1701,7 @@ public class ApplicationConnection {
             styleBuf.append(MODIFIED_CLASSNAME);
         }
 
-        TooltipInfo tooltipInfo = componentDetail.getTooltipInfo(null);
+        TooltipInfo tooltipInfo = paintableMap.getTooltipInfo(paintable, null);
         // Update tooltip
         if (uidl.hasAttribute(ATTRIBUTE_DESCRIPTION)) {
             tooltipInfo
@@ -1918,12 +1742,12 @@ public class ApplicationConnection {
          * taken into account
          */
 
-        updateComponentSize(componentDetail, uidl);
+        updateComponentSize(paintable, uidl);
 
         return false;
     }
 
-    private void updateComponentSize(ComponentDetail cd, UIDL uidl) {
+    private void updateComponentSize(Paintable paintable, UIDL uidl) {
         String w = uidl.hasAttribute("width") ? uidl
                 .getStringAttribute("width") : "";
 
@@ -1938,20 +1762,22 @@ public class ApplicationConnection {
             // One or both is relative
             FloatSize relativeSize = new FloatSize(relativeWidth,
                     relativeHeight);
-            if (cd.getRelativeSize() == null && cd.getOffsetSize() != null) {
+
+            if (paintableMap.getRelativeSize(paintable) == null
+                    && paintableMap.getOffsetSize(paintable) != null) {
                 // The component has changed from absolute size to relative size
-                relativeSizeChanges.add(cd.getComponent());
+                relativeSizeChanges.add(paintable);
             }
-            cd.setRelativeSize(relativeSize);
+            paintableMap.setRelativeSize(paintable, relativeSize);
         } else if (relativeHeight < 0.0 && relativeWidth < 0.0) {
-            if (cd.getRelativeSize() != null) {
+            if (paintableMap.getRelativeSize(paintable) != null) {
                 // The component has changed from relative size to absolute size
-                relativeSizeChanges.add(cd.getComponent());
+                relativeSizeChanges.add(paintable);
             }
-            cd.setRelativeSize(null);
+            paintableMap.setRelativeSize(paintable, null);
         }
 
-        Widget component = (Widget) cd.getComponent();
+        Widget component = paintableMap.getWidget(paintable);
         // Set absolute sizes
         if (relativeHeight < 0.0) {
             component.setHeight(h);
@@ -1963,7 +1789,7 @@ public class ApplicationConnection {
         // Set relative sizes
         if (relativeHeight >= 0.0 || relativeWidth >= 0.0) {
             // One or both is relative
-            handleComponentRelativeSize(cd);
+            handleComponentRelativeSize(paintable);
         }
 
     }
@@ -1996,9 +1822,7 @@ public class ApplicationConnection {
      */
     public void forceLayout() {
         Set<Paintable> set = new HashSet<Paintable>();
-        for (ComponentDetail cd : idToPaintableDetail.values()) {
-            set.add(cd.getComponent());
-        }
+        set.addAll(paintableMap.getPaintables());
         Util.componentSizeUpdated(set);
     }
 
@@ -2040,31 +1864,31 @@ public class ApplicationConnection {
      * @param child
      * @return true if the child has a relative size
      */
-    private boolean handleComponentRelativeSize(ComponentDetail cd) {
-        if (cd == null) {
+    private boolean handleComponentRelativeSize(Paintable paintable) {
+        if (paintable == null) {
             return false;
         }
         boolean debugSizes = false;
 
-        FloatSize relativeSize = cd.getRelativeSize();
+        FloatSize relativeSize = paintableMap.getRelativeSize(paintable);
         if (relativeSize == null) {
             return false;
         }
-        Widget widget = (Widget) cd.getComponent();
+        Widget widget = paintableMap.getWidget(paintable);
 
         boolean horizontalScrollBar = false;
         boolean verticalScrollBar = false;
 
-        Container parent = Util.getLayout(widget);
+        Container parentPaintable = Util.getLayout(widget);
         RenderSpace renderSpace;
 
         // Parent-less components (like sub-windows) are relative to browser
         // window.
-        if (parent == null) {
+        if (parentPaintable == null) {
             renderSpace = new RenderSpace(Window.getClientWidth(),
                     Window.getClientHeight());
         } else {
-            renderSpace = parent.getAllocatedSpace(widget);
+            renderSpace = parentPaintable.getAllocatedSpace(widget);
         }
 
         if (relativeSize.getHeight() >= 0) {
@@ -2088,7 +1912,7 @@ public class ApplicationConnection {
                     height -= renderSpace.getScrollbarSize();
                 }
                 if (validatingLayouts && height <= 0) {
-                    zeroHeightComponents.add(cd.getComponent());
+                    zeroHeightComponents.add(paintable);
                 }
 
                 height = (int) (height * relativeSize.getHeight() / 100.0);
@@ -2098,14 +1922,20 @@ public class ApplicationConnection {
                 }
 
                 if (debugSizes) {
-                    VConsole.log("Widget " + Util.getSimpleName(widget) + "/"
-                            + getPid(widget.getElement()) + " relative height "
-                            + relativeSize.getHeight() + "% of "
-                            + renderSpace.getHeight() + "px (reported by "
-
-                            + Util.getSimpleName(parent) + "/"
-                            + (parent == null ? "?" : parent.hashCode())
-                            + ") : " + height + "px");
+                    VConsole.log("Widget "
+                            + Util.getSimpleName(widget)
+                            + "/"
+                            + paintableMap.getPid(paintable)
+                            + " relative height "
+                            + relativeSize.getHeight()
+                            + "% of "
+                            + renderSpace.getHeight()
+                            + "px (reported by "
+
+                            + Util.getSimpleName(parentPaintable)
+                            + "/"
+                            + (parentPaintable == null ? "?" : parentPaintable
+                                    .hashCode()) + ") : " + height + "px");
                 }
                 widget.setHeight(height + "px");
             } else {
@@ -2137,7 +1967,7 @@ public class ApplicationConnection {
                     width -= renderSpace.getScrollbarSize();
                 }
                 if (validatingLayouts && width <= 0) {
-                    zeroWidthComponents.add(cd.getComponent());
+                    zeroWidthComponents.add(paintable);
                 }
 
                 width = (int) (width * relativeSize.getWidth() / 100.0);
@@ -2147,13 +1977,20 @@ public class ApplicationConnection {
                 }
 
                 if (debugSizes) {
-                    VConsole.log("Widget " + Util.getSimpleName(widget) + "/"
-                            + getPid(widget.getElement()) + " relative width "
-                            + relativeSize.getWidth() + "% of "
-                            + renderSpace.getWidth() + "px (reported by "
-                            + Util.getSimpleName(parent) + "/"
-                            + (parent == null ? "?" : getPid(parent)) + ") : "
-                            + width + "px");
+                    VConsole.log("Widget "
+                            + Util.getSimpleName(widget)
+                            + "/"
+                            + paintableMap.getPid(paintable)
+                            + " relative width "
+                            + relativeSize.getWidth()
+                            + "% of "
+                            + renderSpace.getWidth()
+                            + "px (reported by "
+                            + Util.getSimpleName(parentPaintable)
+                            + "/"
+                            + (parentPaintable == null ? "?" : paintableMap
+                                    .getPid(parentPaintable)) + ") : " + width
+                            + "px");
                 }
                 widget.setWidth(width + "px");
             } else {
@@ -2173,9 +2010,8 @@ public class ApplicationConnection {
      * @param child
      * @return true if the child has a relative size
      */
-    public boolean handleComponentRelativeSize(Widget child) {
-        return handleComponentRelativeSize(idToPaintableDetail.get(getPid(child
-                .getElement())));
+    public boolean handleComponentRelativeSize(Widget widget) {
+        return handleComponentRelativeSize(paintableMap.getPaintable(widget));
 
     }
 
@@ -2187,8 +2023,7 @@ public class ApplicationConnection {
      * @return the the size if the paintable is relatively sized, -1 otherwise
      */
     public FloatSize getRelativeSize(Widget widget) {
-        return idToPaintableDetail.get(getPid(widget.getElement()))
-                .getRelativeSize();
+        return paintableMap.getRelativeSize(paintableMap.getPaintable(widget));
     }
 
     /**
@@ -2204,26 +2039,13 @@ public class ApplicationConnection {
      * @return Either existing or new Paintable corresponding to UIDL.
      */
     public Paintable getPaintable(UIDL uidl) {
-        final String id = uidl.getId();
-        Paintable w = getPaintable(id);
-        if (w != null) {
-            return w;
-        } else {
-            w = widgetSet.createWidget(uidl, configuration);
-            registerPaintable(id, w);
-            return w;
-
+        final String pid = uidl.getId();
+        if (!paintableMap.hasPaintable(pid)) {
+            // Create and register a new paintable if no old was found
+            Paintable p = widgetSet.createWidget(uidl, configuration);
+            paintableMap.registerPaintable(pid, p);
         }
-    }
-
-    /**
-     * Returns a Paintable element by its root element
-     * 
-     * @param element
-     *            Root element of the paintable
-     */
-    public Paintable getPaintable(Element element) {
-        return getPaintable(getPid(element));
+        return paintableMap.getPaintable(pid);
     }
 
     /**
@@ -2320,12 +2142,7 @@ public class ApplicationConnection {
         if (null == titleOwner) {
             return null;
         }
-        ComponentDetail cd = idToPaintableDetail.get(getPid(titleOwner));
-        if (null != cd) {
-            return cd.getTooltipInfo(key);
-        } else {
-            return null;
-        }
+        return paintableMap.getTooltipInfo(titleOwner, key);
     }
 
     private final VTooltip tooltip = new VTooltip(this);
@@ -2387,6 +2204,8 @@ public class ApplicationConnection {
         }
     };
 
+    private PaintableMap paintableMap = new PaintableMap();
+
     /**
      * Components can call this function to run all layout functions. This is
      * usually done, when component knows that its size has changed.
@@ -2443,9 +2262,7 @@ public class ApplicationConnection {
      */
     public void registerTooltip(Paintable paintable, Object key,
             TooltipInfo tooltip) {
-        ComponentDetail componentDetail = idToPaintableDetail
-                .get(getPid(paintable));
-        componentDetail.putAdditionalTooltip(key, tooltip);
+        paintableMap.registerTooltip(paintable, key, tooltip);
     }
 
     /**
@@ -2470,8 +2287,7 @@ public class ApplicationConnection {
      *         for the event identified by eventIdentifier.
      */
     public boolean hasEventListeners(Paintable paintable, String eventIdentifier) {
-        return idToPaintableDetail.get(getPid(paintable)).hasEventListeners(
-                eventIdentifier);
+        return paintableMap.hasEventListeners(paintable, eventIdentifier);
     }
 
     /**
@@ -2515,4 +2331,14 @@ public class ApplicationConnection {
         return uri;
     }
 
+    PaintableMap getPaintableMap() {
+        return paintableMap;
+    }
+
+    @Deprecated
+    public void unregisterPaintable(Paintable p) {
+        paintableMap.unregisterPaintable(p);
+
+    }
+
 }
index 7fc93b2a3e490dc44ebecc9568d8dedaf8d359fe..c83c5700689923024b77cc69b64e74fe5b79a7bf 100644 (file)
@@ -11,16 +11,20 @@ import com.vaadin.terminal.gwt.client.RenderInformation.Size;
 
 class ComponentDetail {
 
-    private Paintable component;
+    // private Paintable paintable;
     private TooltipInfo tooltipInfo = new TooltipInfo();
-    private String pid;
 
-    public ComponentDetail(ApplicationConnection client, String pid,
-            Paintable component) {
-        this.component = component;
-        this.pid = pid;
+    // private String pid;
+
+    public ComponentDetail() {
+
     }
 
+    // public ComponentDetail(String pid, Paintable paintable) {
+    // this.paintable = paintable;
+    // this.pid = pid;
+    // }
+
     /**
      * Returns a TooltipInfo assosiated with Component. If element is given,
      * returns an additional TooltipInfo.
@@ -52,19 +56,19 @@ class ComponentDetail {
     private Size offsetSize;
     private HashMap<Object, TooltipInfo> additionalTooltips;
 
-    /**
-     * @return the pid
-     */
-    String getPid() {
-        return pid;
-    }
-
-    /**
-     * @return the component
-     */
-    Paintable getComponent() {
-        return component;
-    }
+    // /**
+    // * @return the pid
+    // */
+    // String getPid() {
+    // return pid;
+    // }
+
+    // /**
+    // * @return the component
+    // */
+    // Paintable getPaintable() {
+    // return paintable;
+    // }
 
     /**
      * @return the relativeSize
index b4489df81e3cb85e48f554698f3d90aa29934b53..9206e3c0688737adc871f407134839c5b6e00d37 100644 (file)
@@ -78,7 +78,7 @@ public class ComponentLocator {
         Element e = targetElement;
 
         while (true) {
-            pid = client.getPid(e);
+            pid = PaintableMap.get(client).getPid(e);
             if (pid != null) {
                 break;
             }
@@ -94,7 +94,7 @@ public class ComponentLocator {
             // If we found a Paintable then we use that as reference. We should
             // find the Paintable for all but very special cases (like
             // overlays).
-            w = (Widget) client.getPaintable(pid);
+            w = (Widget) PaintableMap.get(client).getPaintable(pid);
 
             /*
              * Still if the Paintable contains a widget that implements
@@ -364,7 +364,7 @@ public class ComponentLocator {
             return null;
         }
 
-        String pid = client.getPid(w.getElement());
+        String pid = PaintableMap.get(client).getPid(w.getElement());
         if (isStaticPid(pid)) {
             return pid;
         }
@@ -437,7 +437,7 @@ public class ComponentLocator {
                 w = client.getView();
             } else if (w == null) {
                 // Must be static pid (PID_S*)
-                w = (Widget) client.getPaintable(part);
+                w = (Widget) PaintableMap.get(client).getPaintable(part);
             } else if (part.startsWith("domChild[")) {
                 // The target widget has been found and the rest identifies the
                 // element
diff --git a/src/com/vaadin/terminal/gwt/client/PaintableMap.java b/src/com/vaadin/terminal/gwt/client/PaintableMap.java
new file mode 100644 (file)
index 0000000..cbdc4ef
--- /dev/null
@@ -0,0 +1,356 @@
+package com.vaadin.terminal.gwt.client;\r
+\r
+import java.util.Collection;\r
+import java.util.Collections;\r
+import java.util.HashMap;\r
+import java.util.HashSet;\r
+import java.util.Iterator;\r
+import java.util.Map;\r
+import java.util.Set;\r
+\r
+import com.google.gwt.core.client.GWT;\r
+import com.google.gwt.user.client.Element;\r
+import com.google.gwt.user.client.ui.HasWidgets;\r
+import com.google.gwt.user.client.ui.Widget;\r
+import com.vaadin.terminal.gwt.client.RenderInformation.FloatSize;\r
+import com.vaadin.terminal.gwt.client.RenderInformation.Size;\r
+\r
+public class PaintableMap {\r
+\r
+    private Map<String, Paintable> idToPaintable = new HashMap<String, Paintable>();\r
+\r
+    @Deprecated\r
+    private final ComponentDetailMap idToComponentDetail = ComponentDetailMap\r
+            .create();\r
+\r
+    private Set<String> unregistryBag = new HashSet<String>();\r
+\r
+    /**\r
+     * Returns a Paintable by its paintable id\r
+     * \r
+     * @param id\r
+     *            The Paintable id\r
+     */\r
+    public Paintable getPaintable(String pid) {\r
+        return idToPaintable.get(pid);\r
+    }\r
+\r
+    /**\r
+     * Returns a Paintable element by its root element\r
+     * \r
+     * @param element\r
+     *            Root element of the paintable\r
+     */\r
+    public Paintable getPaintable(Element element) {\r
+        return getPaintable(getPid(element));\r
+    }\r
+\r
+    public static PaintableMap get(ApplicationConnection applicationConnection) {\r
+        return applicationConnection.getPaintableMap();\r
+    }\r
+\r
+    /**\r
+     * FIXME: What does this even do and why?\r
+     * \r
+     * @param pid\r
+     * @return\r
+     */\r
+    public boolean isDragAndDropPaintable(String pid) {\r
+        return (pid.startsWith("DD"));\r
+    }\r
+\r
+    /**\r
+     * Checks if a paintable with the given paintable id has been registered.\r
+     * \r
+     * @param pid\r
+     *            The paintable id to check for\r
+     * @return true if a paintable has been registered with the given paintable\r
+     *         id, false otherwise\r
+     */\r
+    public boolean hasPaintable(String pid) {\r
+        return idToPaintable.containsKey(pid);\r
+    }\r
+\r
+    /**\r
+     * Removes all registered paintable ids\r
+     */\r
+    public void clear() {\r
+        idToPaintable.clear();\r
+        idToComponentDetail.clear();\r
+    }\r
+\r
+    @Deprecated\r
+    public Widget getWidget(Paintable paintable) {\r
+        return (Widget) paintable;\r
+    }\r
+\r
+    @Deprecated\r
+    public Paintable getPaintable(Widget widget) {\r
+        return (Paintable) widget;\r
+    }\r
+\r
+    public void registerPaintable(String pid, Paintable paintable) {\r
+        ComponentDetail componentDetail = GWT.create(ComponentDetail.class);\r
+        idToComponentDetail.put(pid, componentDetail);\r
+        idToPaintable.put(pid, paintable);\r
+        setPid(((Widget) paintable).getElement(), pid);\r
+    }\r
+\r
+    private native void setPid(Element el, String pid)\r
+    /*-{\r
+        el.tkPid = pid;\r
+    }-*/;\r
+\r
+    /**\r
+     * Gets the paintableId for a specific paintable.\r
+     * <p>\r
+     * The paintableId is used in the UIDL to identify a specific widget\r
+     * instance, effectively linking the widget with it's server side Component.\r
+     * </p>\r
+     * \r
+     * @param paintable\r
+     *            the paintable who's id is needed\r
+     * @return the id for the given paintable or null if the paintable could not\r
+     *         be found\r
+     */\r
+    public String getPid(Paintable paintable) {\r
+        return getPid(getWidget(paintable));\r
+    }\r
+\r
+    @Deprecated\r
+    public String getPid(Widget widget) {\r
+        if (widget == null) {\r
+            return null;\r
+        }\r
+        return getPid(widget.getElement());\r
+    }\r
+\r
+    /**\r
+     * Gets the paintableId using a DOM element - the element should be the main\r
+     * element for a paintable otherwise no id will be found. Use\r
+     * {@link #getPid(Paintable)} instead whenever possible.\r
+     * \r
+     * @see #getPid(Paintable)\r
+     * @param el\r
+     *            element of the paintable whose pid is desired\r
+     * @return the pid of the element's paintable, if it's a paintable\r
+     */\r
+    native String getPid(Element el)\r
+    /*-{\r
+        return el.tkPid;\r
+    }-*/;\r
+\r
+    /**\r
+     * Gets the main element for the paintable with the given id. The revers of\r
+     * {@link #getPid(Element)}.\r
+     * \r
+     * @param pid\r
+     *            the pid of the widget whose element is desired\r
+     * @return the element for the paintable corresponding to the pid\r
+     */\r
+    public Element getElement(String pid) {\r
+        return ((Widget) getPaintable(pid)).getElement();\r
+    }\r
+\r
+    /**\r
+     * Unregisters the given paintable; always use after removing a paintable.\r
+     * This method does not remove the paintable from the DOM, but marks the\r
+     * paintable so that ApplicationConnection may clean up its references to\r
+     * it. Removing the widget from DOM is component containers responsibility.\r
+     * \r
+     * @param p\r
+     *            the paintable to remove\r
+     */\r
+    public void unregisterPaintable(Paintable p) {\r
+\r
+        // add to unregistry que\r
+\r
+        if (p == null) {\r
+            VConsole.error("WARN: Trying to unregister null paintable");\r
+            return;\r
+        }\r
+        String id = getPid(p);\r
+        if (id == null) {\r
+            /*\r
+             * Uncomment the following to debug unregistring components. No\r
+             * paintables with null id should end here. At least one exception\r
+             * is our VScrollTableRow, that is hacked to fake it self as a\r
+             * Paintable to build support for sizing easier.\r
+             */\r
+            // if (!(p instanceof VScrollTableRow)) {\r
+            // VConsole.log("Trying to unregister Paintable not created by Application Connection.");\r
+            // }\r
+            if (p instanceof HasWidgets) {\r
+                unregisterChildPaintables((HasWidgets) p);\r
+            }\r
+        } else {\r
+            unregistryBag.add(id);\r
+            if (p instanceof HasWidgets) {\r
+                unregisterChildPaintables((HasWidgets) p);\r
+            }\r
+        }\r
+    }\r
+\r
+    void purgeUnregistryBag(boolean unregisterPaintables) {\r
+        if (unregisterPaintables) {\r
+            for (String pid : unregistryBag) {\r
+                Paintable paintable = getPaintable(pid);\r
+                if (paintable == null) {\r
+                    /*\r
+                     * this should never happen, but it does :-( See e.g.\r
+                     * com.vaadin.tests.components.accordion.RemoveTabs (with\r
+                     * test script)\r
+                     */\r
+                    VConsole.error("Tried to unregister component (id="\r
+                            + pid\r
+                            + ") that is never registered (or already unregistered)");\r
+                    continue;\r
+                }\r
+                // check if can be cleaned\r
+                Widget component = getWidget(paintable);\r
+                if (!component.isAttached()) {\r
+                    // clean reference to paintable\r
+                    idToComponentDetail.remove(pid);\r
+                    idToPaintable.remove(pid);\r
+                }\r
+                /*\r
+                 * else NOP : same component has been reattached to another\r
+                 * parent or replaced by another component implementation.\r
+                 */\r
+            }\r
+        }\r
+\r
+        unregistryBag.clear();\r
+    }\r
+\r
+    /**\r
+     * Unregisters a paintable and all it's child paintables recursively. Use\r
+     * when after removing a paintable that contains other paintables. Does not\r
+     * unregister the given container itself. Does not actually remove the\r
+     * paintable from the DOM.\r
+     * \r
+     * @see #unregisterPaintable(Paintable)\r
+     * @param container\r
+     */\r
+    public void unregisterChildPaintables(HasWidgets container) {\r
+        final Iterator<Widget> it = container.iterator();\r
+        while (it.hasNext()) {\r
+            final Widget w = it.next();\r
+            if (w instanceof Paintable) {\r
+                unregisterPaintable((Paintable) w);\r
+            } else if (w instanceof HasWidgets) {\r
+                unregisterChildPaintables((HasWidgets) w);\r
+            }\r
+        }\r
+    }\r
+\r
+    /**\r
+     * FIXME: Should not be here\r
+     * \r
+     * @param pid\r
+     * @param uidl\r
+     */\r
+    @Deprecated\r
+    public void registerEventListenersFromUIDL(String pid, UIDL uidl) {\r
+        ComponentDetail cd = idToComponentDetail.get(pid);\r
+        if (cd == null) {\r
+            throw new IllegalArgumentException("Pid must not be null");\r
+        }\r
+\r
+        cd.registerEventListenersFromUIDL(uidl);\r
+\r
+    }\r
+\r
+    /**\r
+     * FIXME: Should not be here\r
+     * \r
+     * @param paintable\r
+     * @return\r
+     */\r
+    @Deprecated\r
+    public Size getOffsetSize(Paintable paintable) {\r
+        return getComponentDetail(paintable).getOffsetSize();\r
+    }\r
+\r
+    /**\r
+     * FIXME: Should not be here\r
+     * \r
+     * @param paintable\r
+     * @return\r
+     */\r
+    @Deprecated\r
+    public FloatSize getRelativeSize(Paintable paintable) {\r
+        return getComponentDetail(paintable).getRelativeSize();\r
+    }\r
+\r
+    /**\r
+     * FIXME: Should not be here\r
+     * \r
+     * @param paintable\r
+     * @return\r
+     */\r
+    @Deprecated\r
+    public void setOffsetSize(Paintable paintable, Size newSize) {\r
+        getComponentDetail(paintable).setOffsetSize(newSize);\r
+    }\r
+\r
+    /**\r
+     * FIXME: Should not be here\r
+     * \r
+     * @param paintable\r
+     * @return\r
+     */\r
+    @Deprecated\r
+    public void setRelativeSize(Paintable paintable, FloatSize relativeSize) {\r
+        getComponentDetail(paintable).setRelativeSize(relativeSize);\r
+\r
+    }\r
+\r
+    private ComponentDetail getComponentDetail(Paintable paintable) {\r
+        return idToComponentDetail.get(getPid(paintable));\r
+    }\r
+\r
+    public int size() {\r
+        return idToPaintable.size();\r
+    }\r
+\r
+    /**\r
+     * FIXME: Should not be here\r
+     * \r
+     * @param paintable\r
+     * @return\r
+     */\r
+    @Deprecated\r
+    public TooltipInfo getTooltipInfo(Paintable paintable, Object key) {\r
+        return getComponentDetail(paintable).getTooltipInfo(key);\r
+    }\r
+\r
+    public Collection<? extends Paintable> getPaintables() {\r
+        return Collections.unmodifiableCollection(idToPaintable.values());\r
+    }\r
+\r
+    /**\r
+     * FIXME: Should not be here\r
+     * \r
+     * @param paintable\r
+     * @return\r
+     */\r
+    @Deprecated\r
+    public void registerTooltip(Paintable paintable, Object key,\r
+            TooltipInfo tooltip) {\r
+        getComponentDetail(paintable).putAdditionalTooltip(key, tooltip);\r
+\r
+    }\r
+\r
+    /**\r
+     * FIXME: Should not be here\r
+     * \r
+     * @param paintable\r
+     * @return\r
+     */\r
+    @Deprecated\r
+    public boolean hasEventListeners(Paintable paintable, String eventIdentifier) {\r
+        return getComponentDetail(paintable).hasEventListeners(eventIdentifier);\r
+    }\r
+\r
+}\r
index a6298af8d1f52e43e42135165075dfe176f12d1e..12bbe563d77219f23f0455528029c992c7ae36b2 100644 (file)
@@ -518,7 +518,8 @@ public final class UIDL extends JavaScriptObject {
      */
     public Paintable getPaintableAttribute(String name,
             ApplicationConnection connection) {
-        return connection.getPaintable(getStringAttribute(name));
+        return PaintableMap.get(connection).getPaintable(
+                getStringAttribute(name));
     }
 
     /**
@@ -530,7 +531,8 @@ public final class UIDL extends JavaScriptObject {
      */
     public Paintable getPaintableVariable(String name,
             ApplicationConnection connection) {
-        return connection.getPaintable(getStringVariable(name));
+        return PaintableMap.get(connection).getPaintable(
+                getStringVariable(name));
     }
 
     /**
index af5ad0616f7c9c5cfcdd3fbe89d783b46cf86d7e..3b3c761e84e89683e36643d0366eeea14d7ae5af 100644 (file)
@@ -747,11 +747,12 @@ public class Util {
             ApplicationConnection client, Container parent, Element element) {
         Element rootElement = ((Widget) parent).getElement();
         while (element != null && element != rootElement) {
-            Paintable paintable = client.getPaintable(element);
+            Paintable paintable = PaintableMap.get(client)
+                    .getPaintable(element);
             if (paintable == null) {
                 String ownerPid = VCaption.getCaptionOwnerPid(element);
                 if (ownerPid != null) {
-                    paintable = client.getPaintable(ownerPid);
+                    paintable = PaintableMap.get(client).getPaintable(ownerPid);
                 }
             }
 
@@ -796,11 +797,12 @@ public class Util {
             ApplicationConnection client, Widget parent, Element element) {
         Element rootElement = parent.getElement();
         while (element != null && element != rootElement) {
-            Paintable paintable = client.getPaintable(element);
+            Paintable paintable = PaintableMap.get(client)
+                    .getPaintable(element);
             if (paintable == null) {
                 String ownerPid = VCaption.getCaptionOwnerPid(element);
                 if (ownerPid != null) {
-                    paintable = client.getPaintable(ownerPid);
+                    paintable = PaintableMap.get(client).getPaintable(ownerPid);
                 }
             }
 
@@ -946,7 +948,7 @@ public class Util {
 
     private static void printPaintablesVariables(ArrayList<String[]> vars,
             String id, ApplicationConnection c) {
-        Paintable paintable = c.getPaintable(id);
+        Paintable paintable = PaintableMap.get(c).getPaintable(id);
         if (paintable != null) {
             VConsole.log("\t" + id + " (" + paintable.getClass() + ") :");
             for (String[] var : vars) {
index 16d18f93f6ea198790be858ac710310ce2bb62fb..12347b76bd1932abee2e11aa03b93895f8e7d6ec 100644 (file)
@@ -54,7 +54,7 @@ public class VCaption extends HTML {
         owner = component;
 
         if (client != null && owner != null) {
-            setOwnerPid(getElement(), client.getPid(owner));
+            setOwnerPid(getElement(), PaintableMap.get(client).getPid(owner));
         }
 
         setStyleName(CLASSNAME);
index e180c05aaa5e02f4e9365d9206c87f2d9f316bb6..259f6ea5ced96e94350b766a500ae46d81a483ab 100644 (file)
@@ -97,7 +97,7 @@ public class VDebugConsole extends VOverlay implements Console {
                                 RootPanel.get(), eventTarget);
                     }
                     if (paintable != null) {
-                        String pid = a.getPid(paintable);
+                        String pid = PaintableMap.get(a).getPid(paintable);
                         VUIDLBrowser.highlight(paintable);
                         label.setText("Currently focused  :"
                                 + paintable.getClass() + " ID:" + pid);
@@ -547,7 +547,7 @@ public class VDebugConsole extends VOverlay implements Console {
     private void printLayoutError(ValueMap valueMap, SimpleTree root,
             final ApplicationConnection ac) {
         final String pid = valueMap.getString("id");
-        final Paintable paintable = ac.getPaintable(pid);
+        final Paintable paintable = PaintableMap.get(ac).getPaintable(pid);
 
         SimpleTree errorNode = new SimpleTree();
         VerticalPanel errorDetails = new VerticalPanel();
index 142fbe293a991a56c46d3badf7a660bfd541a49c..dc6fa142d46204c00efbcb6cbdcde646506c2665 100644 (file)
@@ -126,8 +126,8 @@ public class VUIDLBrowser extends SimpleTree {
             // same
             // host page
             for (ApplicationConnection applicationConnection : runningApplications) {
-                Paintable paintable = applicationConnection.getPaintable(uidl
-                        .getId());
+                Paintable paintable = PaintableMap.get(applicationConnection)
+                        .getPaintable(uidl.getId());
                 highlight(paintable);
                 if (event != null && event.getNativeEvent().getShiftKey()) {
                     applicationConnection.highlightComponent(paintable);
index 3deb140d3062c67e37de2f2b2888049f50cd5dd7..f87f3dd9046b7c4371d7de5d34cd413693339461 100644 (file)
@@ -21,6 +21,7 @@ import com.google.gwt.user.client.ui.Widget;
 import com.vaadin.terminal.gwt.client.ApplicationConnection;
 import com.vaadin.terminal.gwt.client.MouseEventDetails;
 import com.vaadin.terminal.gwt.client.Paintable;
+import com.vaadin.terminal.gwt.client.PaintableMap;
 
 public abstract class ClickEventHandler implements DoubleClickHandler,
         ContextMenuHandler, MouseUpHandler {
@@ -81,7 +82,8 @@ public abstract class ClickEventHandler implements DoubleClickHandler,
 
     protected void fireClick(NativeEvent event) {
         ApplicationConnection client = getApplicationConnection();
-        String pid = getApplicationConnection().getPid(paintable);
+        String pid = PaintableMap.get(getApplicationConnection()).getPid(
+                paintable);
 
         MouseEventDetails mouseDetails = new MouseEventDetails(event,
                 getRelativeToElement());
index 3a4048907f207a6cd7123ea08a100afed5a155f8..1ad69d19cf384572fa92cf5b5216b29125423bca 100644 (file)
@@ -11,6 +11,7 @@ import com.google.gwt.user.client.Element;
 import com.vaadin.terminal.gwt.client.ApplicationConnection;
 import com.vaadin.terminal.gwt.client.MouseEventDetails;
 import com.vaadin.terminal.gwt.client.Paintable;
+import com.vaadin.terminal.gwt.client.PaintableMap;
 
 public abstract class LayoutClickEventHandler extends ClickEventHandler {
 
@@ -24,7 +25,8 @@ public abstract class LayoutClickEventHandler extends ClickEventHandler {
     @Override
     protected void fireClick(NativeEvent event) {
         ApplicationConnection client = getApplicationConnection();
-        String pid = getApplicationConnection().getPid(paintable);
+        String pid = PaintableMap.get(getApplicationConnection()).getPid(
+                paintable);
 
         MouseEventDetails mouseDetails = new MouseEventDetails(event,
                 getRelativeToElement());
index 072754e0ce121a138349e34c2bd528967715d6a5..f4a876a7ba56375d581a27eafb50ac89d1223d5f 100644 (file)
@@ -27,6 +27,7 @@ import com.google.gwt.xhr.client.XMLHttpRequest;
 import com.vaadin.terminal.gwt.client.ApplicationConnection;
 import com.vaadin.terminal.gwt.client.MouseEventDetails;
 import com.vaadin.terminal.gwt.client.Paintable;
+import com.vaadin.terminal.gwt.client.PaintableMap;
 import com.vaadin.terminal.gwt.client.RenderInformation;
 import com.vaadin.terminal.gwt.client.RenderInformation.Size;
 import com.vaadin.terminal.gwt.client.UIDL;
@@ -468,7 +469,7 @@ public class VDragAndDropWrapper extends VCustomComponent implements
     }
 
     private String getPid() {
-        return client.getPid(this);
+        return PaintableMap.get(client).getPid((Paintable) this);
     }
 
     public VDropHandler getDropHandler() {
index 5ab28de91397b7559f0b966639e06dad0a7be718..4311d82802343251c35548099163501fd0cccf6e 100644 (file)
@@ -36,6 +36,7 @@ import com.vaadin.terminal.gwt.client.ApplicationConnection;
 import com.vaadin.terminal.gwt.client.BrowserInfo;
 import com.vaadin.terminal.gwt.client.ContainerResizedListener;
 import com.vaadin.terminal.gwt.client.Paintable;
+import com.vaadin.terminal.gwt.client.PaintableMap;
 import com.vaadin.terminal.gwt.client.TooltipInfo;
 import com.vaadin.terminal.gwt.client.UIDL;
 import com.vaadin.terminal.gwt.client.Util;
@@ -219,8 +220,8 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable,
             moreItem.setHTML(itemHTML.toString());
             moreItem.setCommand(emptyCommand);
 
-            collapsedRootItems = new VMenuBar(true,
-                    (VMenuBar) client.getPaintable(uidlId));
+            collapsedRootItems = new VMenuBar(true, (VMenuBar) PaintableMap
+                    .get(client).getPaintable(uidlId));
             moreItem.setSubMenu(collapsedRootItems);
             moreItem.addStyleName(CLASSNAME + "-more-menuitem");
         }
index 84a22bc2721664059e49d78ffa71d327f1456389..c719639961c2773a0aa7e23c9d6554da60ee263d 100644 (file)
@@ -18,6 +18,7 @@ import com.vaadin.terminal.gwt.client.ApplicationConnection;
 import com.vaadin.terminal.gwt.client.BrowserInfo;
 import com.vaadin.terminal.gwt.client.EventId;
 import com.vaadin.terminal.gwt.client.Paintable;
+import com.vaadin.terminal.gwt.client.PaintableMap;
 import com.vaadin.terminal.gwt.client.RenderInformation.FloatSize;
 import com.vaadin.terminal.gwt.client.RenderInformation.Size;
 import com.vaadin.terminal.gwt.client.RenderSpace;
@@ -898,7 +899,7 @@ public class VOrderedLayout extends CellBasedLayout {
 
         for (int i = 0; i < renderedWidgets.size(); i++) {
             Widget widget = renderedWidgets.get(i);
-            String pid = client.getPid(widget.getElement());
+            String pid = PaintableMap.get(client).getPid(widget);
 
             ChildComponentContainer container = getComponentContainer(widget);
 
index 9f0f3c725a27b6c4fd6cb91523fec7bf4dcb0805..3301e73202221c00beb8ce503541d452ece855c6 100644 (file)
@@ -62,6 +62,7 @@ import com.vaadin.terminal.gwt.client.Container;
 import com.vaadin.terminal.gwt.client.Focusable;
 import com.vaadin.terminal.gwt.client.MouseEventDetails;
 import com.vaadin.terminal.gwt.client.Paintable;
+import com.vaadin.terminal.gwt.client.PaintableMap;
 import com.vaadin.terminal.gwt.client.RenderSpace;
 import com.vaadin.terminal.gwt.client.TooltipInfo;
 import com.vaadin.terminal.gwt.client.UIDL;
@@ -1304,7 +1305,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
     private void purgeUnregistryBag() {
         for (Iterator<Panel> iterator = lazyUnregistryBag.iterator(); iterator
                 .hasNext();) {
-            client.unregisterChildPaintables(iterator.next());
+            PaintableMap.get(client).unregisterChildPaintables(iterator.next());
         }
         lazyUnregistryBag.clear();
     }
index 4d97e113f31ef44a30d25ebd296638875049a698..5142dda3574c0f51eaf4d69c7c5774d8b85f4cf2 100644 (file)
@@ -462,7 +462,7 @@ public class VTextField extends TextBoxBase implements Paintable, Field,
         }
         focusedTextField = this;
         if (client.hasEventListeners(this, EventId.FOCUS)) {
-            client.updateVariable(client.getPid(this), EventId.FOCUS, "", true);
+            client.updateVariable(id, EventId.FOCUS, "", true);
         }
     }
 
index 1278ed7fdbae45823810799dfe33ae6e14ecf0ed..e0c0cafd635cb8b2e63730a19028500c801115b8 100644 (file)
@@ -4,6 +4,7 @@
 package com.vaadin.terminal.gwt.client.ui.dd;
 
 import com.vaadin.terminal.gwt.client.Paintable;
+import com.vaadin.terminal.gwt.client.PaintableMap;
 import com.vaadin.terminal.gwt.client.UIDL;
 
 /**
@@ -21,8 +22,10 @@ final public class VDragSourceIs extends VAcceptCriterion {
             for (int i = 0; i < c; i++) {
                 String requiredPid = configuration
                         .getStringAttribute("component" + i);
-                Paintable paintable = VDragAndDropManager.get()
-                        .getCurrentDropHandler().getApplicationConnection()
+                VDropHandler currentDropHandler = VDragAndDropManager.get()
+                        .getCurrentDropHandler();
+                Paintable paintable = PaintableMap.get(
+                        currentDropHandler.getApplicationConnection())
                         .getPaintable(requiredPid);
                 if (paintable == component) {
                     return true;
index 58dc0d39560ea63d6d6f6031694f43b2507fbb4c..78974f060e7292b69f16ca95be77ccdbe91c2ccd 100644 (file)
@@ -7,6 +7,7 @@
 package com.vaadin.terminal.gwt.client.ui.dd;
 
 import com.vaadin.terminal.gwt.client.Paintable;
+import com.vaadin.terminal.gwt.client.PaintableMap;
 import com.vaadin.terminal.gwt.client.UIDL;
 
 final public class VIsOverId extends VAcceptCriterion {
@@ -16,10 +17,13 @@ final public class VIsOverId extends VAcceptCriterion {
         try {
 
             String pid = configuration.getStringAttribute("s");
-            Paintable paintable = VDragAndDropManager.get()
-                    .getCurrentDropHandler().getPaintable();
-            String pid2 = VDragAndDropManager.get().getCurrentDropHandler()
-                    .getApplicationConnection().getPid(paintable);
+            VDropHandler currentDropHandler = VDragAndDropManager.get()
+                    .getCurrentDropHandler();
+            Paintable paintable = currentDropHandler.getPaintable();
+            PaintableMap paintableMap = PaintableMap.get(currentDropHandler
+                    .getApplicationConnection());
+
+            String pid2 = paintableMap.getPid(paintable);
             if (pid2.equals(pid)) {
                 Object searchedId = drag.getDropDetails().get("itemIdOver");
                 String[] stringArrayAttribute = configuration
index ada7a3c78aa974baa45cbec57f4ebd3c4fe17a4d..80f140a4585f67bc7f58205e2611b91e6c21be20 100644 (file)
@@ -7,6 +7,7 @@
 package com.vaadin.terminal.gwt.client.ui.dd;
 
 import com.vaadin.terminal.gwt.client.Paintable;
+import com.vaadin.terminal.gwt.client.PaintableMap;
 import com.vaadin.terminal.gwt.client.UIDL;
 
 final public class VItemIdIs extends VAcceptCriterion {
@@ -16,8 +17,11 @@ final public class VItemIdIs extends VAcceptCriterion {
         try {
             String pid = configuration.getStringAttribute("s");
             Paintable dragSource = drag.getTransferable().getDragSource();
-            String pid2 = VDragAndDropManager.get().getCurrentDropHandler()
-                    .getApplicationConnection().getPid(dragSource);
+            VDropHandler currentDropHandler = VDragAndDropManager.get()
+                    .getCurrentDropHandler();
+            String pid2 = PaintableMap.get(
+                    currentDropHandler.getApplicationConnection()).getPid(
+                    dragSource);
             if (pid2.equals(pid)) {
                 Object searchedId = drag.getTransferable().getData("itemId");
                 String[] stringArrayAttribute = configuration