From: Artur Signell Date: Mon, 12 Mar 2012 10:24:56 +0000 (+0200) Subject: Connector -> ServerConnector X-Git-Tag: 7.0.0.alpha2~349 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0158bd12912bede8f78203ca303fca981465d535;p=vaadin-framework.git Connector -> ServerConnector --- diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java index c331ae4d6c..24b0bca664 100644 --- a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java +++ b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java @@ -1109,7 +1109,7 @@ public class ApplicationConnection { try { String connectorId = keyArray.get(i); String connectorType = types.getString(connectorId); - Connector connector = connectorMap + ServerConnector connector = connectorMap .getConnector(connectorId); if (connector != null) { continue; @@ -1185,7 +1185,7 @@ public class ApplicationConnection { for (int i = 0; i < keyArray.length(); i++) { try { String connectorId = keyArray.get(i); - Connector paintable = connectorMap + ServerConnector paintable = connectorMap .getConnector(connectorId); if (null != paintable) { @@ -1224,7 +1224,7 @@ public class ApplicationConnection { for (int i = 0; i < hierarchyKeys.length(); i++) { try { String connectorId = hierarchyKeys.get(i); - Connector connector = connectorMap + ServerConnector connector = connectorMap .getConnector(connectorId); if (!(connector instanceof ComponentContainerConnector)) { VConsole.error("Retrieved a hierarchy update for a connector (" @@ -1238,7 +1238,7 @@ public class ApplicationConnection { .getJSStringArray(connectorId); int childConnectorSize = childConnectorIds.length(); - List newChildren = new ArrayList(); + List newChildren = new ArrayList(); for (int connectorIndex = 0; connectorIndex < childConnectorSize; connectorIndex++) { String childConnectorId = childConnectorIds .get(connectorIndex); @@ -1489,7 +1489,7 @@ public class ApplicationConnection { * true if the update is to be sent as soon as possible */ public void updateVariable(String paintableId, String variableName, - Connector newValue, boolean immediate) { + ServerConnector newValue, boolean immediate) { addVariableToQueue(paintableId, variableName, newValue, immediate); } @@ -2155,7 +2155,7 @@ public class ApplicationConnection { } @Deprecated - public void unregisterPaintable(Connector p) { + public void unregisterPaintable(ServerConnector p) { connectorMap.unregisterConnector(p); } diff --git a/src/com/vaadin/terminal/gwt/client/ComponentConnector.java b/src/com/vaadin/terminal/gwt/client/ComponentConnector.java index 65cbbcaf06..7be7799604 100644 --- a/src/com/vaadin/terminal/gwt/client/ComponentConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ComponentConnector.java @@ -14,7 +14,7 @@ import com.google.gwt.user.client.ui.Widget; * Updates can be sent back to the server using the * {@link ApplicationConnection#updateVariable()} methods. */ -public interface ComponentConnector extends Connector { +public interface ComponentConnector extends ServerConnector { /* * (non-Javadoc) diff --git a/src/com/vaadin/terminal/gwt/client/Connector.java b/src/com/vaadin/terminal/gwt/client/Connector.java deleted file mode 100644 index 7e5635861a..0000000000 --- a/src/com/vaadin/terminal/gwt/client/Connector.java +++ /dev/null @@ -1,97 +0,0 @@ -/* -@VaadinApache2LicenseForJavaFiles@ - */ -package com.vaadin.terminal.gwt.client; - -import java.util.Collection; - -import com.vaadin.terminal.gwt.client.communication.ClientRpc; -import com.vaadin.terminal.gwt.client.communication.SharedState; - -/** - * Interface implemented by all client side classes that can be communicate with - * the server. Classes implementing this interface are initialized by the - * framework when needed and have the ability to communicate with the server. - * - * @author Vaadin Ltd - * @version @VERSION@ - * @since 7.0.0 - */ -public interface Connector { - /** - * TODO - * - * @param uidl - * @param client - */ - public void updateFromUIDL(UIDL uidl, ApplicationConnection client); - - /** - * Gets the current shared state of the connector. - * - * @return state - */ - public SharedState getState(); - - /** - * Sets a new state for the connector. - * - * @param state - * The new state - * @deprecated This should be removed. Framework should update what is - * returned by getState() instead of setting a new state object. - */ - @Deprecated - public void setState(SharedState state); - - /** - * Returns the id for this connector. This must always be what has been set - * in {@link #doInit(String, ApplicationConnection)} and must never change. - * - * @return The id for the connector. - */ - public String getId(); - - /** - * Gets ApplicationConnection instance that created this connector. - * - * @return The ApplicationConnection as set by - * {@link #doInit(String, ApplicationConnection)} - */ - public ApplicationConnection getConnection(); - - /** - * Tests whether the connector is enabled or not. Disabled connectors will - * ignore all attempts at communications. Received messages will be - * discarded. This method must check that the connector is enabled in - * context, that is if it's parent is disabled, this method must return - * false. - * - * @return true if the connector is enabled, false otherwise - */ - public boolean isEnabled(); - - /** - * - * Called once by the framework to initialize the connector. - *

- * Note that the shared state is not yet available at this point nor any - * hierarchy information. - */ - public void doInit(String connectorId, ApplicationConnection connection); - - /** - * For internal use by the framework: returns the registered RPC - * implementations for an RPC interface identifier. - * - * TODO interface identifier type or format may change - * - * @param rpcInterfaceId - * RPC interface identifier: fully qualified interface type name - * @return RPC interface implementations registered for an RPC interface, - * not null - */ - public Collection getRpcImplementations( - String rpcInterfaceId); - -} diff --git a/src/com/vaadin/terminal/gwt/client/ConnectorHierarchyChangedEvent.java b/src/com/vaadin/terminal/gwt/client/ConnectorHierarchyChangedEvent.java index 849ec0788c..c7abcbeb32 100644 --- a/src/com/vaadin/terminal/gwt/client/ConnectorHierarchyChangedEvent.java +++ b/src/com/vaadin/terminal/gwt/client/ConnectorHierarchyChangedEvent.java @@ -3,7 +3,7 @@ package com.vaadin.terminal.gwt.client; import java.util.List; /** - * Event for containing data related to a change in the {@link Connector} + * Event for containing data related to a change in the {@link ServerConnector} * hierarchy. A {@link ConnectorHierarchyChangedEvent} is fired when an update * from the server has been fully processed and all hierarchy updates have been * completed. diff --git a/src/com/vaadin/terminal/gwt/client/ConnectorMap.java b/src/com/vaadin/terminal/gwt/client/ConnectorMap.java index 601d01c92c..286b8396cd 100644 --- a/src/com/vaadin/terminal/gwt/client/ConnectorMap.java +++ b/src/com/vaadin/terminal/gwt/client/ConnectorMap.java @@ -21,7 +21,7 @@ import com.vaadin.terminal.gwt.client.RenderInformation.Size; public class ConnectorMap { - private Map idToConnector = new HashMap(); + private Map idToConnector = new HashMap(); public static ConnectorMap get(ApplicationConnection applicationConnection) { return applicationConnection.getConnectorMap(); @@ -34,14 +34,14 @@ public class ConnectorMap { private Set unregistryBag = new HashSet(); /** - * Returns a {@link Connector} by its id + * Returns a {@link ServerConnector} by its id * * @param id * The connector id * @return A connector or null if a connector with the given id has not been * registered */ - public Connector getConnector(String connectorId) { + public ServerConnector getConnector(String connectorId) { return idToConnector.get(connectorId); } @@ -91,7 +91,7 @@ public class ConnectorMap { return getConnector(widget.getElement()); } - public void registerConnector(String id, Connector connector) { + public void registerConnector(String id, ServerConnector connector) { ComponentDetail componentDetail = GWT.create(ComponentDetail.class); idToComponentDetail.put(id, componentDetail); idToConnector.put(id, connector); @@ -117,10 +117,10 @@ public class ConnectorMap { * the connector whose id is needed * @return the id for the given connector or null if the connector could not * be found - * @deprecated use {@link Connector#getId()} instead + * @deprecated use {@link ServerConnector#getId()} instead */ @Deprecated - public String getConnectorId(Connector connector) { + public String getConnectorId(ServerConnector connector) { if (connector == null) { return null; } @@ -135,7 +135,7 @@ public class ConnectorMap { /** * Gets the connector id using a DOM element - the element should be the * root element for a connector, otherwise no id will be found. Use - * {@link #getConnectorId(Connector)} instead whenever possible. + * {@link #getConnectorId(ServerConnector)} instead whenever possible. * * @see #getConnectorId(Paintable) * @param el @@ -156,7 +156,7 @@ public class ConnectorMap { * @return the element for the connector corresponding to the id */ public Element getElement(String connectorId) { - Connector p = getConnector(connectorId); + ServerConnector p = getConnector(connectorId); if (p instanceof ComponentConnector) { return ((ComponentConnector) p).getWidget().getElement(); } @@ -173,7 +173,7 @@ public class ConnectorMap { * @param connector * the connector to remove */ - public void unregisterConnector(Connector connector) { + public void unregisterConnector(ServerConnector connector) { // add to unregistry queue @@ -203,7 +203,7 @@ public class ConnectorMap { public ComponentConnector[] getRegisteredComponentConnectors() { ArrayList result = new ArrayList(); - for (Connector connector : getConnectors()) { + for (ServerConnector connector : getConnectors()) { if (connector instanceof ComponentConnector) { ComponentConnector componentConnector = (ComponentConnector) connector; if (!unregistryBag.contains(connector.getId())) { @@ -219,7 +219,7 @@ public class ConnectorMap { if (unregisterConnectors) { for (String connectorId : unregistryBag) { // TODO purge shared state for pid - Connector connector = getConnector(connectorId); + ServerConnector connector = getConnector(connectorId); if (connector == null) { /* * this should never happen, but it does :-( See e.g. @@ -261,7 +261,7 @@ public class ConnectorMap { * not unregister the given container itself. Does not actually remove the * widgets from the DOM. * - * @see #unregisterConnector(Connector) + * @see #unregisterConnector(ServerConnector) * @param container * The container that contains the connectors that should be * unregistered @@ -347,7 +347,7 @@ public class ConnectorMap { return getTooltipInfo(getConnector(widget), key); } - public Collection getConnectors() { + public Collection getConnectors() { return Collections.unmodifiableCollection(idToConnector.values()); } diff --git a/src/com/vaadin/terminal/gwt/client/LayoutManager.java b/src/com/vaadin/terminal/gwt/client/LayoutManager.java index 44b652b530..bc1a0c8bba 100644 --- a/src/com/vaadin/terminal/gwt/client/LayoutManager.java +++ b/src/com/vaadin/terminal/gwt/client/LayoutManager.java @@ -166,7 +166,7 @@ public class LayoutManager { for (int i = 0; i < needsWidthUpdateArray.length(); i++) { String pid = needsWidthUpdateArray.get(i); - Connector paintable = paintableMap.getConnector(pid); + ServerConnector paintable = paintableMap.getConnector(pid); if (paintable instanceof DirectionalManagedLayout) { DirectionalManagedLayout cl = (DirectionalManagedLayout) paintable; cl.layoutHorizontally(); diff --git a/src/com/vaadin/terminal/gwt/client/ServerConnector.java b/src/com/vaadin/terminal/gwt/client/ServerConnector.java new file mode 100644 index 0000000000..ef10cc2566 --- /dev/null +++ b/src/com/vaadin/terminal/gwt/client/ServerConnector.java @@ -0,0 +1,97 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.terminal.gwt.client; + +import java.util.Collection; + +import com.vaadin.terminal.gwt.client.communication.ClientRpc; +import com.vaadin.terminal.gwt.client.communication.SharedState; + +/** + * Interface implemented by all client side classes that can be communicate with + * the server. Classes implementing this interface are initialized by the + * framework when needed and have the ability to communicate with the server. + * + * @author Vaadin Ltd + * @version @VERSION@ + * @since 7.0.0 + */ +public interface ServerConnector { + /** + * TODO + * + * @param uidl + * @param client + */ + public void updateFromUIDL(UIDL uidl, ApplicationConnection client); + + /** + * Gets the current shared state of the connector. + * + * @return state + */ + public SharedState getState(); + + /** + * Sets a new state for the connector. + * + * @param state + * The new state + * @deprecated This should be removed. Framework should update what is + * returned by getState() instead of setting a new state object. + */ + @Deprecated + public void setState(SharedState state); + + /** + * Returns the id for this connector. This must always be what has been set + * in {@link #doInit(String, ApplicationConnection)} and must never change. + * + * @return The id for the connector. + */ + public String getId(); + + /** + * Gets ApplicationConnection instance that created this connector. + * + * @return The ApplicationConnection as set by + * {@link #doInit(String, ApplicationConnection)} + */ + public ApplicationConnection getConnection(); + + /** + * Tests whether the connector is enabled or not. Disabled connectors will + * ignore all attempts at communications. Received messages will be + * discarded. This method must check that the connector is enabled in + * context, that is if it's parent is disabled, this method must return + * false. + * + * @return true if the connector is enabled, false otherwise + */ + public boolean isEnabled(); + + /** + * + * Called once by the framework to initialize the connector. + *

+ * Note that the shared state is not yet available at this point nor any + * hierarchy information. + */ + public void doInit(String connectorId, ApplicationConnection connection); + + /** + * For internal use by the framework: returns the registered RPC + * implementations for an RPC interface identifier. + * + * TODO interface identifier type or format may change + * + * @param rpcInterfaceId + * RPC interface identifier: fully qualified interface type name + * @return RPC interface implementations registered for an RPC interface, + * not null + */ + public Collection getRpcImplementations( + String rpcInterfaceId); + +} diff --git a/src/com/vaadin/terminal/gwt/client/UIDL.java b/src/com/vaadin/terminal/gwt/client/UIDL.java index 70ecf01672..9476b0bbd1 100644 --- a/src/com/vaadin/terminal/gwt/client/UIDL.java +++ b/src/com/vaadin/terminal/gwt/client/UIDL.java @@ -516,7 +516,7 @@ public final class UIDL extends JavaScriptObject { * the name of the attribute * @return the Paintable referenced by the attribute, if it exists */ - public Connector getPaintableAttribute(String name, + public ServerConnector getPaintableAttribute(String name, ApplicationConnection connection) { return ConnectorMap.get(connection).getConnector( getStringAttribute(name)); @@ -529,7 +529,7 @@ public final class UIDL extends JavaScriptObject { * the name of the variable * @return the Paintable referenced by the variable, if it exists */ - public Connector getPaintableVariable(String name, + public ServerConnector getPaintableVariable(String name, ApplicationConnection connection) { return ConnectorMap.get(connection).getConnector( getStringVariable(name)); diff --git a/src/com/vaadin/terminal/gwt/client/Util.java b/src/com/vaadin/terminal/gwt/client/Util.java index 39962de907..708483f3ba 100644 --- a/src/com/vaadin/terminal/gwt/client/Util.java +++ b/src/com/vaadin/terminal/gwt/client/Util.java @@ -106,7 +106,7 @@ public class Util { } String pid = paintableMap.getConnectorId(paintable); if (pid != null) { - Connector otherPaintable = paintableMap.getConnector(pid); + ServerConnector otherPaintable = paintableMap.getConnector(pid); if (otherPaintable == paintable) { return applicationConnection; } @@ -834,9 +834,9 @@ public class Util { Object value = parameters[1]; // TODO paintables inside lists/maps get rendered as // components in the debug console - String formattedValue = value instanceof Connector ? c + String formattedValue = value instanceof ServerConnector ? c .getConnectorMap() - .getConnectorId((Connector) value) : String + .getConnectorId((ServerConnector) value) : String .valueOf(value); formattedParams = parameters[0] + " : " + formattedValue; } diff --git a/src/com/vaadin/terminal/gwt/client/communication/JsonDecoder.java b/src/com/vaadin/terminal/gwt/client/communication/JsonDecoder.java index 5fbb801e87..0eaa106b43 100644 --- a/src/com/vaadin/terminal/gwt/client/communication/JsonDecoder.java +++ b/src/com/vaadin/terminal/gwt/client/communication/JsonDecoder.java @@ -15,7 +15,7 @@ import com.google.gwt.json.client.JSONArray; import com.google.gwt.json.client.JSONObject; import com.google.gwt.json.client.JSONString; import com.vaadin.terminal.gwt.client.ApplicationConnection; -import com.vaadin.terminal.gwt.client.Connector; +import com.vaadin.terminal.gwt.client.ServerConnector; import com.vaadin.terminal.gwt.client.ConnectorMap; /** @@ -39,7 +39,7 @@ public class JsonDecoder { * @param jsonArray * JSON array with two elements * @param idMapper - * mapper between connector ID and {@link Connector} objects + * mapper between connector ID and {@link ServerConnector} objects * @param connection * reference to the current ApplicationConnection * @return decoded value (does not contain JSON types) diff --git a/src/com/vaadin/terminal/gwt/client/communication/JsonEncoder.java b/src/com/vaadin/terminal/gwt/client/communication/JsonEncoder.java index 874313ba02..6cedba1b31 100644 --- a/src/com/vaadin/terminal/gwt/client/communication/JsonEncoder.java +++ b/src/com/vaadin/terminal/gwt/client/communication/JsonEncoder.java @@ -14,7 +14,7 @@ import com.google.gwt.json.client.JSONObject; import com.google.gwt.json.client.JSONString; import com.google.gwt.json.client.JSONValue; import com.vaadin.terminal.gwt.client.ApplicationConnection; -import com.vaadin.terminal.gwt.client.Connector; +import com.vaadin.terminal.gwt.client.ServerConnector; import com.vaadin.terminal.gwt.client.ConnectorMap; /** @@ -91,8 +91,8 @@ public class JsonEncoder { jsonMap.put(mapKey, encode(mapValue, connectorMap, connection)); } return combineTypeAndValue(VTYPE_MAP, jsonMap); - } else if (value instanceof Connector) { - Connector paintable = (Connector) value; + } else if (value instanceof ServerConnector) { + ServerConnector paintable = (ServerConnector) value; return combineTypeAndValue(VTYPE_PAINTABLE, new JSONString( connectorMap.getConnectorId(paintable))); } else { @@ -123,7 +123,7 @@ public class JsonEncoder { private static String getTransportType(Object value) { if (value instanceof String) { return VTYPE_STRING; - } else if (value instanceof Connector) { + } else if (value instanceof ServerConnector) { return VTYPE_PAINTABLE; } else if (value instanceof Boolean) { return VTYPE_BOOLEAN; diff --git a/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java b/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java index 174b242492..f83944271e 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java @@ -10,7 +10,7 @@ import java.util.HashMap; import java.util.Map; import com.vaadin.terminal.gwt.client.ApplicationConnection; -import com.vaadin.terminal.gwt.client.Connector; +import com.vaadin.terminal.gwt.client.ServerConnector; import com.vaadin.terminal.gwt.client.communication.ClientRpc; /** @@ -21,7 +21,7 @@ import com.vaadin.terminal.gwt.client.communication.ClientRpc; * @since 7.0.0 * */ -public abstract class AbstractConnector implements Connector { +public abstract class AbstractConnector implements ServerConnector { private ApplicationConnection connection; private String id; diff --git a/src/com/vaadin/terminal/gwt/client/ui/VDragAndDropWrapper.java b/src/com/vaadin/terminal/gwt/client/ui/VDragAndDropWrapper.java index d2d4ed4f79..00a0ca73e3 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VDragAndDropWrapper.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VDragAndDropWrapper.java @@ -24,7 +24,7 @@ import com.google.gwt.xhr.client.ReadyStateChangeHandler; import com.google.gwt.xhr.client.XMLHttpRequest; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.ComponentConnector; -import com.vaadin.terminal.gwt.client.Connector; +import com.vaadin.terminal.gwt.client.ServerConnector; import com.vaadin.terminal.gwt.client.ConnectorMap; import com.vaadin.terminal.gwt.client.MouseEventDetailsBuilder; import com.vaadin.terminal.gwt.client.RenderInformation; @@ -420,7 +420,7 @@ public class VDragAndDropWrapper extends VCustomComponent implements } private String getPid() { - return ConnectorMap.get(client).getConnectorId((Connector) this); + return ConnectorMap.get(client).getConnectorId((ServerConnector) this); } public VDropHandler getDropHandler() { diff --git a/src/com/vaadin/terminal/gwt/widgetsetutils/RpcManagerGenerator.java b/src/com/vaadin/terminal/gwt/widgetsetutils/RpcManagerGenerator.java index 0d28980148..2899061204 100644 --- a/src/com/vaadin/terminal/gwt/widgetsetutils/RpcManagerGenerator.java +++ b/src/com/vaadin/terminal/gwt/widgetsetutils/RpcManagerGenerator.java @@ -20,7 +20,7 @@ import com.google.gwt.core.ext.typeinfo.JType; import com.google.gwt.core.ext.typeinfo.TypeOracle; import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; import com.google.gwt.user.rebind.SourceWriter; -import com.vaadin.terminal.gwt.client.Connector; +import com.vaadin.terminal.gwt.client.ServerConnector; import com.vaadin.terminal.gwt.client.ConnectorMap; import com.vaadin.terminal.gwt.client.communication.ClientRpc; import com.vaadin.terminal.gwt.client.communication.MethodInvocation; @@ -130,7 +130,7 @@ public class RpcManagerGenerator extends Generator { } } sourceWriter - .println(Connector.class.getName() + .println(ServerConnector.class.getName() + " connector = connectorMap.getConnector(invocation.getConnectorId());"); sourceWriter .println("for ("