From a462479569bb86db07f03fac3e8a24de1da14e4b Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Sun, 25 Mar 2012 18:42:39 +0300 Subject: [PATCH] Paintable -> Connector --- .../gwt/client/ApplicationConnection.java | 11 ++---- .../terminal/gwt/client/ConnectorMap.java | 3 +- .../server/AbstractCommunicationManager.java | 39 ++++++++++--------- .../vaadin/terminal/gwt/server/JsonCodec.java | 5 +-- .../terminal/gwt/server/JsonPaintTarget.java | 2 +- .../terminal/gwt/server/ServerRpcManager.java | 12 +++--- 6 files changed, 34 insertions(+), 38 deletions(-) diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java index 11947720f8..975a5eec57 100644 --- a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java +++ b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java @@ -57,13 +57,10 @@ import com.vaadin.terminal.gwt.server.AbstractCommunicationManager; * communication with its server side counterpart * {@link AbstractCommunicationManager}. * - * Client-side widgets receive updates from the corresponding server-side - * components as calls to - * {@link ComponentConnector#updateFromUIDL(UIDL, ApplicationConnection)} (not - * to be confused with the server side interface - * {@link com.vaadin.terminal.Paintable} ). Any client-side changes (typically - * resulting from user actions) are sent back to the server as variable changes - * (see {@link #updateVariable()}). + * Client-side connectors receive updates from the corresponding server-side + * connector (typically component) as state updates or RPC calls. The connector + * has the possibility to communicate back with its server side counter part + * through RPC calls. * * TODO document better * diff --git a/src/com/vaadin/terminal/gwt/client/ConnectorMap.java b/src/com/vaadin/terminal/gwt/client/ConnectorMap.java index 6fe04ee2c0..3c35842f12 100644 --- a/src/com/vaadin/terminal/gwt/client/ConnectorMap.java +++ b/src/com/vaadin/terminal/gwt/client/ConnectorMap.java @@ -12,7 +12,6 @@ import java.util.Map; import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Element; import com.google.gwt.user.client.ui.Widget; -import com.vaadin.terminal.Paintable; public class ConnectorMap { @@ -130,7 +129,7 @@ public class ConnectorMap { * root element for a connector, otherwise no id will be found. Use * {@link #getConnectorId(ServerConnector)} instead whenever possible. * - * @see #getConnectorId(Paintable) + * @see #getConnectorId(ServerConnector) * @param el * element of the connector whose id is desired * @return the id of the element's connector, if it's a connector diff --git a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java index 337f6ec3f8..ea5817ab79 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java @@ -1059,7 +1059,8 @@ public abstract class AbstractCommunicationManager implements Serializable { outWriter.print("\""); outWriter.print(canonicalName); outWriter.print("\" : "); - outWriter.print(getTagForType(class1)); + outWriter + .print(getTagForType((Class) class1)); } } if (typeMappingsOpen) { @@ -1077,33 +1078,33 @@ public abstract class AbstractCommunicationManager implements Serializable { private void legacyPaint(PaintTarget paintTarget, ArrayList dirtyVisibleConnectors) throws PaintException { - List paintables = new ArrayList(); + List legacyComponents = new ArrayList(); for (Connector connector : dirtyVisibleConnectors) { if (connector instanceof Paintable) { - paintables.add((Paintable) connector); + // All legacy Components must be Paintables as Component extends + // Paintable in Vaadin 6 + legacyComponents.add((Component) connector); } } - sortByHierarchy(paintables); - for (Paintable p : paintables) { - logger.info("Painting legacy Paintable " + p.getClass().getName() - + "@" + Integer.toHexString(p.hashCode())); + sortByHierarchy(legacyComponents); + for (Component c : legacyComponents) { + logger.info("Painting legacy Component " + c.getClass().getName() + + "@" + Integer.toHexString(c.hashCode())); paintTarget.startTag("change"); - final String pid = ((Connector) p).getConnectorId(); + final String pid = c.getConnectorId(); paintTarget.addAttribute("pid", pid); - p.paint(paintTarget); + c.paint(paintTarget); paintTarget.endTag("change"); } } - private void sortByHierarchy(List paintables) { + private void sortByHierarchy(List paintables) { // Vaadin 6 requires parents to be painted before children as component // containers rely on that their updateFromUIDL method has been called // before children start calling e.g. updateCaption - Collections.sort(paintables, new Comparator() { - public int compare(Paintable o1, Paintable o2) { - Component c1 = (Component) o1; - Component c2 = (Component) o2; + Collections.sort(paintables, new Comparator() { + public int compare(Component c1, Component c2) { int depth1 = 0; while (c1.getParent() != null) { depth1++; @@ -1195,11 +1196,11 @@ public abstract class AbstractCommunicationManager implements Serializable { } /** - * Collects all pending RPC calls from listed {@link Paintable}s and clears - * their RPC queues. + * Collects all pending RPC calls from listed {@link ClientConnector}s and + * clears their RPC queues. * * @param rpcPendingQueue - * list of {@link Paintable} of interest + * list of {@link ClientConnector} of interest * @return ordered list of pending RPC calls */ private List collectPendingRpcCalls( @@ -1994,12 +1995,12 @@ public abstract class AbstractCommunicationManager implements Serializable { } - private final HashMap, Integer> typeToKey = new HashMap, Integer>(); + private final HashMap, Integer> typeToKey = new HashMap, Integer>(); private int nextTypeKey = 0; private BootstrapHandler bootstrapHandler; - String getTagForType(Class class1) { + String getTagForType(Class class1) { Integer object = typeToKey.get(class1); if (object == null) { object = nextTypeKey++; diff --git a/src/com/vaadin/terminal/gwt/server/JsonCodec.java b/src/com/vaadin/terminal/gwt/server/JsonCodec.java index 402d219a70..380aec12bf 100644 --- a/src/com/vaadin/terminal/gwt/server/JsonCodec.java +++ b/src/com/vaadin/terminal/gwt/server/JsonCodec.java @@ -23,7 +23,6 @@ import com.vaadin.Application; import com.vaadin.external.json.JSONArray; import com.vaadin.external.json.JSONException; import com.vaadin.external.json.JSONObject; -import com.vaadin.terminal.Paintable; import com.vaadin.terminal.gwt.client.Connector; import com.vaadin.terminal.gwt.client.communication.JsonEncoder; @@ -70,7 +69,7 @@ public class JsonCodec implements Serializable { * @param value * JSON array with two elements * @param application - * mapper between paintable ID and {@link Paintable} objects + * mapper between connector ID and {@link Connector} objects * @return converted value (does not contain JSON types) * @throws JSONException * if the conversion fails @@ -177,7 +176,7 @@ public class JsonCodec implements Serializable { * @param value * value to convert * @param application - * mapper between paintable ID and {@link Paintable} objects + * mapper between connector ID and {@link Connector} objects * @return JSON representation of the value * @throws JSONException * if encoding a value fails (e.g. NaN or infinite number) diff --git a/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java b/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java index 15ff22deb5..54122401c4 100644 --- a/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java +++ b/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java @@ -1023,7 +1023,7 @@ public class JsonPaintTarget implements PaintTarget { } usedPaintableTypes.add(class1); - return manager.getTagForType(class1); + return manager.getTagForType((Class) class1); } diff --git a/src/com/vaadin/terminal/gwt/server/ServerRpcManager.java b/src/com/vaadin/terminal/gwt/server/ServerRpcManager.java index 9e80fdfac7..061f079ca0 100644 --- a/src/com/vaadin/terminal/gwt/server/ServerRpcManager.java +++ b/src/com/vaadin/terminal/gwt/server/ServerRpcManager.java @@ -10,15 +10,15 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import com.vaadin.terminal.Paintable; +import com.vaadin.terminal.gwt.client.Connector; import com.vaadin.terminal.gwt.client.communication.MethodInvocation; /** * Server side RPC manager that handles RPC calls coming from the client. * - * Each {@link RpcTarget} (typically a {@link Paintable}) should have its own - * instance of {@link ServerRpcManager} if it wants to receive RPC calls from - * the client. + * Each {@link RpcTarget} (typically a {@link ClientConnector}) should have its + * own instance of {@link ServerRpcManager} if it wants to receive RPC calls + * from the client. * * @since 7.0 */ @@ -51,7 +51,7 @@ public class ServerRpcManager implements RpcManager { * Create a RPC manager for an RPC target. * * @param target - * RPC call target (normally a {@link Paintable}) + * RPC call target (normally a {@link Connector}) * @param implementation * RPC interface implementation for the target * @param rpcInterface @@ -96,7 +96,7 @@ public class ServerRpcManager implements RpcManager { /** * Returns the RPC target of this RPC manager instance. * - * @return RpcTarget, typically a {@link Paintable} + * @return RpcTarget, typically a {@link Connector} */ public RpcTarget getTarget() { return target; -- 2.39.5