Browse Source

#8324 Automatically set paintable id when paintable is created

tags/7.0.0.alpha2
Artur Signell 12 years ago
parent
commit
b77b4e6a2e

+ 3
- 5
src/com/vaadin/terminal/gwt/client/ApplicationConnection.java View File

@@ -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);

+ 30
- 24
src/com/vaadin/terminal/gwt/client/VPaintable.java View File

@@ -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.
// * <p>
// * 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.
// * </p>
// *
// * @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.
* <p>
* 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.
* </p>
*
* @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();

}

+ 3
- 1
src/com/vaadin/terminal/gwt/client/ui/VViewPaintable.java View File

@@ -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;

Loading…
Cancel
Save