Parcourir la source

Paintable -> Connector

tags/7.0.0.alpha2
Artur Signell il y a 12 ans
Parent
révision
a462479569

+ 4
- 7
src/com/vaadin/terminal/gwt/client/ApplicationConnection.java Voir le fichier

* communication with its server side counterpart * communication with its server side counterpart
* {@link AbstractCommunicationManager}. * {@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 * TODO document better
* *

+ 1
- 2
src/com/vaadin/terminal/gwt/client/ConnectorMap.java Voir le fichier

import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.Paintable;


public class ConnectorMap { public class ConnectorMap {


* root element for a connector, otherwise no id will be found. Use * root element for a connector, otherwise no id will be found. Use
* {@link #getConnectorId(ServerConnector)} instead whenever possible. * {@link #getConnectorId(ServerConnector)} instead whenever possible.
* *
* @see #getConnectorId(Paintable)
* @see #getConnectorId(ServerConnector)
* @param el * @param el
* element of the connector whose id is desired * element of the connector whose id is desired
* @return the id of the element's connector, if it's a connector * @return the id of the element's connector, if it's a connector

+ 20
- 19
src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java Voir le fichier

outWriter.print("\""); outWriter.print("\"");
outWriter.print(canonicalName); outWriter.print(canonicalName);
outWriter.print("\" : "); outWriter.print("\" : ");
outWriter.print(getTagForType(class1));
outWriter
.print(getTagForType((Class<? extends ClientConnector>) class1));
} }
} }
if (typeMappingsOpen) { if (typeMappingsOpen) {
private void legacyPaint(PaintTarget paintTarget, private void legacyPaint(PaintTarget paintTarget,
ArrayList<ClientConnector> dirtyVisibleConnectors) ArrayList<ClientConnector> dirtyVisibleConnectors)
throws PaintException { throws PaintException {
List<Paintable> paintables = new ArrayList<Paintable>();
List<Component> legacyComponents = new ArrayList<Component>();
for (Connector connector : dirtyVisibleConnectors) { for (Connector connector : dirtyVisibleConnectors) {
if (connector instanceof Paintable) { 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"); paintTarget.startTag("change");
final String pid = ((Connector) p).getConnectorId();
final String pid = c.getConnectorId();
paintTarget.addAttribute("pid", pid); paintTarget.addAttribute("pid", pid);
p.paint(paintTarget);
c.paint(paintTarget);
paintTarget.endTag("change"); paintTarget.endTag("change");
} }


} }


private void sortByHierarchy(List<Paintable> paintables) {
private void sortByHierarchy(List<Component> paintables) {
// Vaadin 6 requires parents to be painted before children as component // Vaadin 6 requires parents to be painted before children as component
// containers rely on that their updateFromUIDL method has been called // containers rely on that their updateFromUIDL method has been called
// before children start calling e.g. updateCaption // before children start calling e.g. updateCaption
Collections.sort(paintables, new Comparator<Paintable>() {
public int compare(Paintable o1, Paintable o2) {
Component c1 = (Component) o1;
Component c2 = (Component) o2;
Collections.sort(paintables, new Comparator<Component>() {
public int compare(Component c1, Component c2) {
int depth1 = 0; int depth1 = 0;
while (c1.getParent() != null) { while (c1.getParent() != null) {
depth1++; depth1++;
} }


/** /**
* 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 * @param rpcPendingQueue
* list of {@link Paintable} of interest
* list of {@link ClientConnector} of interest
* @return ordered list of pending RPC calls * @return ordered list of pending RPC calls
*/ */
private List<ClientMethodInvocation> collectPendingRpcCalls( private List<ClientMethodInvocation> collectPendingRpcCalls(


} }


private final HashMap<Class<? extends Paintable>, Integer> typeToKey = new HashMap<Class<? extends Paintable>, Integer>();
private final HashMap<Class<? extends ClientConnector>, Integer> typeToKey = new HashMap<Class<? extends ClientConnector>, Integer>();
private int nextTypeKey = 0; private int nextTypeKey = 0;


private BootstrapHandler bootstrapHandler; private BootstrapHandler bootstrapHandler;


String getTagForType(Class<? extends Paintable> class1) {
String getTagForType(Class<? extends ClientConnector> class1) {
Integer object = typeToKey.get(class1); Integer object = typeToKey.get(class1);
if (object == null) { if (object == null) {
object = nextTypeKey++; object = nextTypeKey++;

+ 2
- 3
src/com/vaadin/terminal/gwt/server/JsonCodec.java Voir le fichier

import com.vaadin.external.json.JSONArray; import com.vaadin.external.json.JSONArray;
import com.vaadin.external.json.JSONException; import com.vaadin.external.json.JSONException;
import com.vaadin.external.json.JSONObject; import com.vaadin.external.json.JSONObject;
import com.vaadin.terminal.Paintable;
import com.vaadin.terminal.gwt.client.Connector; import com.vaadin.terminal.gwt.client.Connector;
import com.vaadin.terminal.gwt.client.communication.JsonEncoder; import com.vaadin.terminal.gwt.client.communication.JsonEncoder;


* @param value * @param value
* JSON array with two elements * JSON array with two elements
* @param application * @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) * @return converted value (does not contain JSON types)
* @throws JSONException * @throws JSONException
* if the conversion fails * if the conversion fails
* @param value * @param value
* value to convert * value to convert
* @param application * @param application
* mapper between paintable ID and {@link Paintable} objects
* mapper between connector ID and {@link Connector} objects
* @return JSON representation of the value * @return JSON representation of the value
* @throws JSONException * @throws JSONException
* if encoding a value fails (e.g. NaN or infinite number) * if encoding a value fails (e.g. NaN or infinite number)

+ 1
- 1
src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java Voir le fichier

} }


usedPaintableTypes.add(class1); usedPaintableTypes.add(class1);
return manager.getTagForType(class1);
return manager.getTagForType((Class<? extends ClientConnector>) class1);


} }



+ 6
- 6
src/com/vaadin/terminal/gwt/server/ServerRpcManager.java Voir le fichier

import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; 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; import com.vaadin.terminal.gwt.client.communication.MethodInvocation;


/** /**
* Server side RPC manager that handles RPC calls coming from the client. * 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 * @since 7.0
*/ */
* Create a RPC manager for an RPC target. * Create a RPC manager for an RPC target.
* *
* @param target * @param target
* RPC call target (normally a {@link Paintable})
* RPC call target (normally a {@link Connector})
* @param implementation * @param implementation
* RPC interface implementation for the target * RPC interface implementation for the target
* @param rpcInterface * @param rpcInterface
/** /**
* Returns the RPC target of this RPC manager instance. * Returns the RPC target of this RPC manager instance.
* *
* @return RpcTarget, typically a {@link Paintable}
* @return RpcTarget, typically a {@link Connector}
*/ */
public RpcTarget getTarget() { public RpcTarget getTarget() {
return target; return target;

Chargement…
Annuler
Enregistrer