From b77b4e6a2ed7253a48eb21fb5ac734f1c11fb6ff Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 7 Feb 2012 10:04:05 +0200 Subject: [PATCH] #8324 Automatically set paintable id when paintable is created --- .../gwt/client/ApplicationConnection.java | 8 ++- .../terminal/gwt/client/VPaintable.java | 54 ++++++++++--------- .../gwt/client/ui/VViewPaintable.java | 4 +- 3 files changed, 36 insertions(+), 30 deletions(-) diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java index 2beb5a5734..882251852b 100644 --- a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java +++ b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java @@ -38,7 +38,6 @@ import com.vaadin.terminal.gwt.client.ApplicationConfiguration.ErrorMessage; import com.vaadin.terminal.gwt.client.RenderInformation.FloatSize; import com.vaadin.terminal.gwt.client.RenderInformation.Size; import com.vaadin.terminal.gwt.client.ui.Field; -import com.vaadin.terminal.gwt.client.ui.VAbstractPaintableWidget; import com.vaadin.terminal.gwt.client.ui.VContextMenu; import com.vaadin.terminal.gwt.client.ui.VNotification; import com.vaadin.terminal.gwt.client.ui.VNotification.HideEvent; @@ -2098,10 +2097,9 @@ public class ApplicationConnection { if (!paintableMap.hasPaintable(pid)) { // Create and register a new paintable if no old was found VPaintableWidget p = widgetSet.createWidget(uidl, configuration); - if (p instanceof VAbstractPaintableWidget) { - ((VAbstractPaintableWidget) p).setConnection(this); - ((VAbstractPaintableWidget) p).init(); - } + p.setConnection(this); + p.setId(pid); + p.init(); paintableMap.registerPaintable(pid, p); } return (VPaintableWidget) paintableMap.getPaintable(pid); diff --git a/src/com/vaadin/terminal/gwt/client/VPaintable.java b/src/com/vaadin/terminal/gwt/client/VPaintable.java index f7b7eaba83..032058b8d5 100644 --- a/src/com/vaadin/terminal/gwt/client/VPaintable.java +++ b/src/com/vaadin/terminal/gwt/client/VPaintable.java @@ -21,28 +21,27 @@ public interface VPaintable { */ public void updateFromUIDL(UIDL uidl, ApplicationConnection client); - // /** - // * Returns the id for this VPaintable. This must always be what has been - // set - // * using {@link #setId(String)}. - // * - // * @return The id for the VPaintable. - // */ - // public String getId(); - // - // /** - // * Sets the id for the VPaintable. This method is called once by the - // * framework when the VPaintable is initialized and should never be called - // * otherwise. - // *

- // * The VPaintable id is used to map the server and the client paintables - // * together. It is unique in this root and assigned by the framework. - // *

- // * - // * @param id - // * The id of the paintable. - // */ - // public void setId(String id); + /** + * Returns the id for this VPaintable. This must always be what has been set + * using {@link #setId(String)}. + * + * @return The id for the VPaintable. + */ + public String getId(); + + /** + * Sets the id for the VPaintable. This method is called once by the + * framework when the VPaintable is initialized and should never be called + * otherwise. + *

+ * The VPaintable id is used to map the server and the client paintables + * together. It is unique in this root and assigned by the framework. + *

+ * + * @param id + * The id of the paintable. + */ + public void setId(String id); /** * Gets ApplicationConnection instance that created this VPaintable. @@ -50,7 +49,7 @@ public interface VPaintable { * @return The ApplicationConnection as set by * {@link #setConnection(ApplicationConnection)} */ - // public ApplicationConnection getConnection(); + public ApplicationConnection getConnection(); /** * Sets the reference to ApplicationConnection. This method is called by the @@ -60,7 +59,7 @@ public interface VPaintable { * @param connection * The ApplicationConnection that created this VPaintable */ - // public void setConnection(ApplicationConnection connection); + public void setConnection(ApplicationConnection connection); /** * Tests whether the component is enabled or not. A user can not interact @@ -71,4 +70,11 @@ public interface VPaintable { * @return true if the component is enabled, false otherwise */ // public boolean isEnabled(); + + /** + * + * Called once when the connection and id has been set + */ + public void init(); + } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VViewPaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VViewPaintable.java index 079dfad962..94e7bfd9af 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VViewPaintable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VViewPaintable.java @@ -33,7 +33,9 @@ public class VViewPaintable extends VAbstractPaintableWidgetContainer { public void updateFromUIDL(final UIDL uidl, ApplicationConnection client) { getWidgetForPaintable().rendering = true; - + // As VView is not created in the same way as all other paintables we + // have to set the id here + setId(uidl.getId()); getWidgetForPaintable().id = uidl.getId(); boolean firstPaint = getWidgetForPaintable().connection == null; getWidgetForPaintable().connection = client; -- 2.39.5