ServerConnector is always enabled.tags/7.0.0.alpha2
@@ -50,6 +50,7 @@ import com.vaadin.terminal.gwt.client.ApplicationConnection; | |||
import com.vaadin.terminal.gwt.client.Connector; | |||
import com.vaadin.terminal.gwt.server.AbstractApplicationServlet; | |||
import com.vaadin.terminal.gwt.server.ChangeVariablesErrorEvent; | |||
import com.vaadin.terminal.gwt.server.ClientConnector; | |||
import com.vaadin.terminal.gwt.server.WebApplicationContext; | |||
import com.vaadin.ui.AbstractComponent; | |||
import com.vaadin.ui.AbstractField; | |||
@@ -2388,7 +2389,7 @@ public class Application implements Terminal.ErrorListener, Serializable { | |||
return Collections.unmodifiableCollection(roots.values()); | |||
} | |||
private final HashMap<String, Connector> connectorIdToConnector = new HashMap<String, Connector>(); | |||
private final HashMap<String, ClientConnector> connectorIdToConnector = new HashMap<String, ClientConnector>(); | |||
private int connectorIdSequence = 0; | |||
@@ -2400,7 +2401,7 @@ public class Application implements Terminal.ErrorListener, Serializable { | |||
* A connector that has not yet been assigned an id. | |||
* @return A new id for the connector | |||
*/ | |||
public String createConnectorId(Connector connector) { | |||
public String createConnectorId(ClientConnector connector) { | |||
String connectorId = String.valueOf(connectorIdSequence++); | |||
Connector oldReference = connectorIdToConnector.put(connectorId, | |||
connector); | |||
@@ -2420,7 +2421,7 @@ public class Application implements Terminal.ErrorListener, Serializable { | |||
* @return The connector with the given id or null if no connector has the | |||
* given id | |||
*/ | |||
public Connector getConnector(String connectorId) { | |||
public ClientConnector getConnector(String connectorId) { | |||
return connectorIdToConnector.get(connectorId); | |||
} | |||
@@ -6,36 +6,44 @@ package com.vaadin.terminal.gwt.client; | |||
import java.io.Serializable; | |||
import com.vaadin.terminal.gwt.client.communication.SharedState; | |||
import com.vaadin.terminal.gwt.server.ClientConnector; | |||
/** | |||
* TODO Add javadoc | |||
* Interface implemented by all classes that are capable of communicating with | |||
* the server or the client side. | |||
* <p> | |||
* A connector consists of a shared state (server sets the state and | |||
* automatically communicates changes to the client) and the possibility to do | |||
* RPC calls either from the server to the client or from the client to the | |||
* server. | |||
* </p> | |||
* <p> | |||
* No classes should implement this interface directly, client side classes | |||
* wanting to communicate with server side should implement | |||
* {@link ServerConnector} and server side classes should implement | |||
* {@link ClientConnector}. | |||
* </p> | |||
* | |||
* @author Vaadin Ltd | |||
* @version @VERSION@ | |||
* @since 7.0.0 | |||
* | |||
*/ | |||
public interface Connector extends Serializable { | |||
/** | |||
* Gets the current shared state of the connector. | |||
* | |||
* @return state | |||
* @since 7.0. | |||
* @return state The shared state object. Can be any sub type of | |||
* {@link SharedState}. Never null. | |||
*/ | |||
public SharedState getState(); | |||
/** | |||
* Returns the id for this connector. This must always be what has been set | |||
* in {@link #doInit(String, ApplicationConnection)} and must never change. | |||
* Returns the id for this connector. This is set by the framework and does | |||
* not change during the lifetime of a connector. | |||
* | |||
* @return The id for the connector. | |||
*/ | |||
public String getConnectorId(); | |||
/** | |||
* Checks if the communicator is enabled. An enabled communicator is allowed | |||
* to receive messages from its counter-part. | |||
* | |||
* @return true if the connector can receive messages, false otherwise | |||
*/ | |||
public boolean isConnectorEnabled(); | |||
} |
@@ -1433,7 +1433,7 @@ public abstract class AbstractCommunicationManager implements Serializable { | |||
applyInvocation(app, invocation); | |||
continue; | |||
} | |||
final Connector connector = getConnector(app, | |||
final ClientConnector connector = getConnector(app, | |||
invocation.getConnectorId()); | |||
final VariableOwner owner = (VariableOwner) connector; | |||
@@ -1579,8 +1579,8 @@ public abstract class AbstractCommunicationManager implements Serializable { | |||
owner.changeVariables(source, m); | |||
} | |||
protected Connector getConnector(Application app, String connectorId) { | |||
Connector c = app.getConnector(connectorId); | |||
protected ClientConnector getConnector(Application app, String connectorId) { | |||
ClientConnector c = app.getConnector(connectorId); | |||
if (c == null | |||
&& connectorId.equals(getDragAndDropService().getConnectorId())) { | |||
return getDragAndDropService(); |
@@ -28,4 +28,11 @@ public interface ClientConnector extends Connector { | |||
*/ | |||
public List<ClientMethodInvocation> retrievePendingRpcCalls(); | |||
/** | |||
* Checks if the communicator is enabled. An enabled communicator is allowed | |||
* to receive messages from its counter-part. | |||
* | |||
* @return true if the connector can receive messages, false otherwise | |||
*/ | |||
public boolean isConnectorEnabled(); | |||
} |
@@ -4,6 +4,7 @@ | |||
package com.vaadin.terminal.gwt.server; | |||
import java.io.PrintWriter; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.logging.Logger; | |||
@@ -18,13 +19,12 @@ import com.vaadin.event.dd.TargetDetailsImpl; | |||
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; | |||
import com.vaadin.terminal.PaintException; | |||
import com.vaadin.terminal.VariableOwner; | |||
import com.vaadin.terminal.gwt.client.Connector; | |||
import com.vaadin.terminal.gwt.client.communication.SharedState; | |||
import com.vaadin.terminal.gwt.client.ui.dd.VDragAndDropManager; | |||
import com.vaadin.terminal.gwt.client.ui.dd.VDragAndDropManager.DragEventType; | |||
import com.vaadin.ui.Component; | |||
public class DragAndDropService implements VariableOwner, Connector { | |||
public class DragAndDropService implements VariableOwner, ClientConnector { | |||
private static final Logger logger = Logger | |||
.getLogger(DragAndDropService.class.getName()); | |||
@@ -229,4 +229,8 @@ public class DragAndDropService implements VariableOwner, Connector { | |||
// Drag'n'drop can't be disabled | |||
return true; | |||
} | |||
public List<ClientMethodInvocation> retrievePendingRpcCalls() { | |||
return null; | |||
} | |||
} |