Browse Source

Connector -> ServerConnector

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

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

try { try {
String connectorId = keyArray.get(i); String connectorId = keyArray.get(i);
String connectorType = types.getString(connectorId); String connectorType = types.getString(connectorId);
Connector connector = connectorMap
ServerConnector connector = connectorMap
.getConnector(connectorId); .getConnector(connectorId);
if (connector != null) { if (connector != null) {
continue; continue;
for (int i = 0; i < keyArray.length(); i++) { for (int i = 0; i < keyArray.length(); i++) {
try { try {
String connectorId = keyArray.get(i); String connectorId = keyArray.get(i);
Connector paintable = connectorMap
ServerConnector paintable = connectorMap
.getConnector(connectorId); .getConnector(connectorId);
if (null != paintable) { if (null != paintable) {


for (int i = 0; i < hierarchyKeys.length(); i++) { for (int i = 0; i < hierarchyKeys.length(); i++) {
try { try {
String connectorId = hierarchyKeys.get(i); String connectorId = hierarchyKeys.get(i);
Connector connector = connectorMap
ServerConnector connector = connectorMap
.getConnector(connectorId); .getConnector(connectorId);
if (!(connector instanceof ComponentContainerConnector)) { if (!(connector instanceof ComponentContainerConnector)) {
VConsole.error("Retrieved a hierarchy update for a connector (" VConsole.error("Retrieved a hierarchy update for a connector ("
.getJSStringArray(connectorId); .getJSStringArray(connectorId);
int childConnectorSize = childConnectorIds.length(); int childConnectorSize = childConnectorIds.length();


List<Connector> newChildren = new ArrayList<Connector>();
List<ServerConnector> newChildren = new ArrayList<ServerConnector>();
for (int connectorIndex = 0; connectorIndex < childConnectorSize; connectorIndex++) { for (int connectorIndex = 0; connectorIndex < childConnectorSize; connectorIndex++) {
String childConnectorId = childConnectorIds String childConnectorId = childConnectorIds
.get(connectorIndex); .get(connectorIndex);
* true if the update is to be sent as soon as possible * true if the update is to be sent as soon as possible
*/ */
public void updateVariable(String paintableId, String variableName, public void updateVariable(String paintableId, String variableName,
Connector newValue, boolean immediate) {
ServerConnector newValue, boolean immediate) {
addVariableToQueue(paintableId, variableName, newValue, immediate); addVariableToQueue(paintableId, variableName, newValue, immediate);
} }


} }


@Deprecated @Deprecated
public void unregisterPaintable(Connector p) {
public void unregisterPaintable(ServerConnector p) {
connectorMap.unregisterConnector(p); connectorMap.unregisterConnector(p);
} }



+ 1
- 1
src/com/vaadin/terminal/gwt/client/ComponentConnector.java View File

* Updates can be sent back to the server using the * Updates can be sent back to the server using the
* {@link ApplicationConnection#updateVariable()} methods. * {@link ApplicationConnection#updateVariable()} methods.
*/ */
public interface ComponentConnector extends Connector {
public interface ComponentConnector extends ServerConnector {


/* /*
* (non-Javadoc) * (non-Javadoc)

+ 1
- 1
src/com/vaadin/terminal/gwt/client/ConnectorHierarchyChangedEvent.java View File

import java.util.List; 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 * hierarchy. A {@link ConnectorHierarchyChangedEvent} is fired when an update
* from the server has been fully processed and all hierarchy updates have been * from the server has been fully processed and all hierarchy updates have been
* completed. * completed.

+ 13
- 13
src/com/vaadin/terminal/gwt/client/ConnectorMap.java View File



public class ConnectorMap { public class ConnectorMap {


private Map<String, Connector> idToConnector = new HashMap<String, Connector>();
private Map<String, ServerConnector> idToConnector = new HashMap<String, ServerConnector>();


public static ConnectorMap get(ApplicationConnection applicationConnection) { public static ConnectorMap get(ApplicationConnection applicationConnection) {
return applicationConnection.getConnectorMap(); return applicationConnection.getConnectorMap();
private Set<String> unregistryBag = new HashSet<String>(); private Set<String> unregistryBag = new HashSet<String>();


/** /**
* Returns a {@link Connector} by its id
* Returns a {@link ServerConnector} by its id
* *
* @param id * @param id
* The connector id * The connector id
* @return A connector or null if a connector with the given id has not been * @return A connector or null if a connector with the given id has not been
* registered * registered
*/ */
public Connector getConnector(String connectorId) {
public ServerConnector getConnector(String connectorId) {
return idToConnector.get(connectorId); return idToConnector.get(connectorId);
} }


return getConnector(widget.getElement()); return getConnector(widget.getElement());
} }


public void registerConnector(String id, Connector connector) {
public void registerConnector(String id, ServerConnector connector) {
ComponentDetail componentDetail = GWT.create(ComponentDetail.class); ComponentDetail componentDetail = GWT.create(ComponentDetail.class);
idToComponentDetail.put(id, componentDetail); idToComponentDetail.put(id, componentDetail);
idToConnector.put(id, connector); idToConnector.put(id, connector);
* the connector whose id is needed * the connector whose id is needed
* @return the id for the given connector or null if the connector could not * @return the id for the given connector or null if the connector could not
* be found * be found
* @deprecated use {@link Connector#getId()} instead
* @deprecated use {@link ServerConnector#getId()} instead
*/ */
@Deprecated @Deprecated
public String getConnectorId(Connector connector) {
public String getConnectorId(ServerConnector connector) {
if (connector == null) { if (connector == null) {
return null; return null;
} }
/** /**
* Gets the connector id using a DOM element - the element should be the * 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 * 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) * @see #getConnectorId(Paintable)
* @param el * @param el
* @return the element for the connector corresponding to the id * @return the element for the connector corresponding to the id
*/ */
public Element getElement(String connectorId) { public Element getElement(String connectorId) {
Connector p = getConnector(connectorId);
ServerConnector p = getConnector(connectorId);
if (p instanceof ComponentConnector) { if (p instanceof ComponentConnector) {
return ((ComponentConnector) p).getWidget().getElement(); return ((ComponentConnector) p).getWidget().getElement();
} }
* @param connector * @param connector
* the connector to remove * the connector to remove
*/ */
public void unregisterConnector(Connector connector) {
public void unregisterConnector(ServerConnector connector) {


// add to unregistry queue // add to unregistry queue


public ComponentConnector[] getRegisteredComponentConnectors() { public ComponentConnector[] getRegisteredComponentConnectors() {
ArrayList<ComponentConnector> result = new ArrayList<ComponentConnector>(); ArrayList<ComponentConnector> result = new ArrayList<ComponentConnector>();


for (Connector connector : getConnectors()) {
for (ServerConnector connector : getConnectors()) {
if (connector instanceof ComponentConnector) { if (connector instanceof ComponentConnector) {
ComponentConnector componentConnector = (ComponentConnector) connector; ComponentConnector componentConnector = (ComponentConnector) connector;
if (!unregistryBag.contains(connector.getId())) { if (!unregistryBag.contains(connector.getId())) {
if (unregisterConnectors) { if (unregisterConnectors) {
for (String connectorId : unregistryBag) { for (String connectorId : unregistryBag) {
// TODO purge shared state for pid // TODO purge shared state for pid
Connector connector = getConnector(connectorId);
ServerConnector connector = getConnector(connectorId);
if (connector == null) { if (connector == null) {
/* /*
* this should never happen, but it does :-( See e.g. * this should never happen, but it does :-( See e.g.
* not unregister the given container itself. Does not actually remove the * not unregister the given container itself. Does not actually remove the
* widgets from the DOM. * widgets from the DOM.
* *
* @see #unregisterConnector(Connector)
* @see #unregisterConnector(ServerConnector)
* @param container * @param container
* The container that contains the connectors that should be * The container that contains the connectors that should be
* unregistered * unregistered
return getTooltipInfo(getConnector(widget), key); return getTooltipInfo(getConnector(widget), key);
} }


public Collection<? extends Connector> getConnectors() {
public Collection<? extends ServerConnector> getConnectors() {
return Collections.unmodifiableCollection(idToConnector.values()); return Collections.unmodifiableCollection(idToConnector.values());
} }



+ 1
- 1
src/com/vaadin/terminal/gwt/client/LayoutManager.java View File

for (int i = 0; i < needsWidthUpdateArray.length(); i++) { for (int i = 0; i < needsWidthUpdateArray.length(); i++) {
String pid = needsWidthUpdateArray.get(i); String pid = needsWidthUpdateArray.get(i);


Connector paintable = paintableMap.getConnector(pid);
ServerConnector paintable = paintableMap.getConnector(pid);
if (paintable instanceof DirectionalManagedLayout) { if (paintable instanceof DirectionalManagedLayout) {
DirectionalManagedLayout cl = (DirectionalManagedLayout) paintable; DirectionalManagedLayout cl = (DirectionalManagedLayout) paintable;
cl.layoutHorizontally(); cl.layoutHorizontally();

src/com/vaadin/terminal/gwt/client/Connector.java → src/com/vaadin/terminal/gwt/client/ServerConnector.java View File

* @version @VERSION@ * @version @VERSION@
* @since 7.0.0 * @since 7.0.0
*/ */
public interface Connector {
public interface ServerConnector {
/** /**
* TODO * TODO
* *

+ 2
- 2
src/com/vaadin/terminal/gwt/client/UIDL.java View File

* the name of the attribute * the name of the attribute
* @return the Paintable referenced by the attribute, if it exists * @return the Paintable referenced by the attribute, if it exists
*/ */
public Connector getPaintableAttribute(String name,
public ServerConnector getPaintableAttribute(String name,
ApplicationConnection connection) { ApplicationConnection connection) {
return ConnectorMap.get(connection).getConnector( return ConnectorMap.get(connection).getConnector(
getStringAttribute(name)); getStringAttribute(name));
* the name of the variable * the name of the variable
* @return the Paintable referenced by the variable, if it exists * @return the Paintable referenced by the variable, if it exists
*/ */
public Connector getPaintableVariable(String name,
public ServerConnector getPaintableVariable(String name,
ApplicationConnection connection) { ApplicationConnection connection) {
return ConnectorMap.get(connection).getConnector( return ConnectorMap.get(connection).getConnector(
getStringVariable(name)); getStringVariable(name));

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

} }
String pid = paintableMap.getConnectorId(paintable); String pid = paintableMap.getConnectorId(paintable);
if (pid != null) { if (pid != null) {
Connector otherPaintable = paintableMap.getConnector(pid);
ServerConnector otherPaintable = paintableMap.getConnector(pid);
if (otherPaintable == paintable) { if (otherPaintable == paintable) {
return applicationConnection; return applicationConnection;
} }
Object value = parameters[1]; Object value = parameters[1];
// TODO paintables inside lists/maps get rendered as // TODO paintables inside lists/maps get rendered as
// components in the debug console // components in the debug console
String formattedValue = value instanceof Connector ? c
String formattedValue = value instanceof ServerConnector ? c
.getConnectorMap() .getConnectorMap()
.getConnectorId((Connector) value) : String
.getConnectorId((ServerConnector) value) : String
.valueOf(value); .valueOf(value);
formattedParams = parameters[0] + " : " + formattedValue; formattedParams = parameters[0] + " : " + formattedValue;
} }

+ 2
- 2
src/com/vaadin/terminal/gwt/client/communication/JsonDecoder.java View File

import com.google.gwt.json.client.JSONObject; import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONString; import com.google.gwt.json.client.JSONString;
import com.vaadin.terminal.gwt.client.ApplicationConnection; 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; import com.vaadin.terminal.gwt.client.ConnectorMap;


/** /**
* @param jsonArray * @param jsonArray
* JSON array with two elements * JSON array with two elements
* @param idMapper * @param idMapper
* mapper between connector ID and {@link Connector} objects
* mapper between connector ID and {@link ServerConnector} objects
* @param connection * @param connection
* reference to the current ApplicationConnection * reference to the current ApplicationConnection
* @return decoded value (does not contain JSON types) * @return decoded value (does not contain JSON types)

+ 4
- 4
src/com/vaadin/terminal/gwt/client/communication/JsonEncoder.java View File

import com.google.gwt.json.client.JSONString; import com.google.gwt.json.client.JSONString;
import com.google.gwt.json.client.JSONValue; import com.google.gwt.json.client.JSONValue;
import com.vaadin.terminal.gwt.client.ApplicationConnection; 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; import com.vaadin.terminal.gwt.client.ConnectorMap;


/** /**
jsonMap.put(mapKey, encode(mapValue, connectorMap, connection)); jsonMap.put(mapKey, encode(mapValue, connectorMap, connection));
} }
return combineTypeAndValue(VTYPE_MAP, jsonMap); 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( return combineTypeAndValue(VTYPE_PAINTABLE, new JSONString(
connectorMap.getConnectorId(paintable))); connectorMap.getConnectorId(paintable)));
} else { } else {
private static String getTransportType(Object value) { private static String getTransportType(Object value) {
if (value instanceof String) { if (value instanceof String) {
return VTYPE_STRING; return VTYPE_STRING;
} else if (value instanceof Connector) {
} else if (value instanceof ServerConnector) {
return VTYPE_PAINTABLE; return VTYPE_PAINTABLE;
} else if (value instanceof Boolean) { } else if (value instanceof Boolean) {
return VTYPE_BOOLEAN; return VTYPE_BOOLEAN;

+ 2
- 2
src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java View File

import java.util.Map; import java.util.Map;


import com.vaadin.terminal.gwt.client.ApplicationConnection; 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; import com.vaadin.terminal.gwt.client.communication.ClientRpc;


/** /**
* @since 7.0.0 * @since 7.0.0
* *
*/ */
public abstract class AbstractConnector implements Connector {
public abstract class AbstractConnector implements ServerConnector {


private ApplicationConnection connection; private ApplicationConnection connection;
private String id; private String id;

+ 2
- 2
src/com/vaadin/terminal/gwt/client/ui/VDragAndDropWrapper.java View File

import com.google.gwt.xhr.client.XMLHttpRequest; import com.google.gwt.xhr.client.XMLHttpRequest;
import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.ComponentConnector; 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.ConnectorMap;
import com.vaadin.terminal.gwt.client.MouseEventDetailsBuilder; import com.vaadin.terminal.gwt.client.MouseEventDetailsBuilder;
import com.vaadin.terminal.gwt.client.RenderInformation; import com.vaadin.terminal.gwt.client.RenderInformation;
} }


private String getPid() { private String getPid() {
return ConnectorMap.get(client).getConnectorId((Connector) this);
return ConnectorMap.get(client).getConnectorId((ServerConnector) this);
} }


public VDropHandler getDropHandler() { public VDropHandler getDropHandler() {

+ 2
- 2
src/com/vaadin/terminal/gwt/widgetsetutils/RpcManagerGenerator.java View File

import com.google.gwt.core.ext.typeinfo.TypeOracle; import com.google.gwt.core.ext.typeinfo.TypeOracle;
import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; import com.google.gwt.user.rebind.ClassSourceFileComposerFactory;
import com.google.gwt.user.rebind.SourceWriter; 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.ConnectorMap;
import com.vaadin.terminal.gwt.client.communication.ClientRpc; import com.vaadin.terminal.gwt.client.communication.ClientRpc;
import com.vaadin.terminal.gwt.client.communication.MethodInvocation; import com.vaadin.terminal.gwt.client.communication.MethodInvocation;
} }
} }
sourceWriter sourceWriter
.println(Connector.class.getName()
.println(ServerConnector.class.getName()
+ " connector = connectorMap.getConnector(invocation.getConnectorId());"); + " connector = connectorMap.getConnector(invocation.getConnectorId());");
sourceWriter sourceWriter
.println("for (" .println("for ("

Loading…
Cancel
Save