com.vaadin.terminal.gwt.client.ui
Class AbstractConnector

java.lang.Object
  extended by com.vaadin.terminal.gwt.client.ui.AbstractConnector
All Implemented Interfaces:
com.google.gwt.event.shared.EventHandler, StateChangeEvent.StateChangeHandler, Connector, ServerConnector, Serializable
Direct Known Subclasses:
AbstractComponentConnector, AbstractExtensionConnector

public abstract class AbstractConnector
extends Object
implements ServerConnector, StateChangeEvent.StateChangeHandler

An abstract implementation of Connector.

Since:
7.0.0
Version:
7.0.0.alpha3
Author:
Vaadin Ltd
See Also:
Serialized Form

Constructor Summary
AbstractConnector()
           
 
Method Summary
 com.google.web.bindery.event.shared.HandlerRegistration addStateChangeHandler(StateChangeEvent.StateChangeHandler handler)
          Adds a handler that is called whenever some part of the state has been updated by the server.
protected  SharedState createState()
          Creates a state object with default values for this connector.
 void doInit(String connectorId, ApplicationConnection connection)
          Called once by the framework to initialize the connector.
protected  com.google.gwt.event.shared.HandlerManager ensureHandlerManager()
           
 void fireEvent(com.google.gwt.event.shared.GwtEvent<?> event)
          Sends the given event to all registered handlers.
 List<ServerConnector> getChildren()
           
 ApplicationConnection getConnection()
          Gets ApplicationConnection instance that created this connector.
 String getConnectorId()
          Returns the id for this connector.
 ServerConnector getParent()
          Returns the parent of this connector.
<T extends ClientRpc>
Collection<T>
getRpcImplementations(String rpcInterfaceId)
          For internal use by the framework: returns the registered RPC implementations for an RPC interface identifier.
 SharedState getState()
          Returns the shared state object for this connector.
protected  void init()
          Called when the connector has been initialized.
 boolean isEnabled()
          Tests whether the connector is enabled or not.
 void onStateChanged(StateChangeEvent stateChangeEvent)
           
 void onUnregister()
          Event called when connector has been unregistered.
protected
<T extends ClientRpc>
void
registerRpc(Class<T> rpcInterface, T implementation)
          Registers an implementation for a server to client RPC interface.
 void setChildren(List<ServerConnector> children)
           
 void setParent(ServerConnector parent)
          Sets the parent for this connector.
protected
<T extends ClientRpc>
void
unregisterRpc(Class<T> rpcInterface, T implementation)
          Unregisters an implementation for a server to client RPC interface.
 void updateEnabledState(boolean enabledState)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractConnector

public AbstractConnector()
Method Detail

getConnection

public final ApplicationConnection getConnection()
Description copied from interface: ServerConnector
Gets ApplicationConnection instance that created this connector.

Specified by:
getConnection in interface ServerConnector
Returns:
The ApplicationConnection as set by ServerConnector.doInit(String, ApplicationConnection)

getConnectorId

public String getConnectorId()
Description copied from interface: Connector
Returns the id for this connector. This is set by the framework and does not change during the lifetime of a connector.

Specified by:
getConnectorId in interface Connector
Returns:
The id for the connector.

doInit

public final void doInit(String connectorId,
                         ApplicationConnection connection)
Called once by the framework to initialize the connector.

Note that the shared state is not yet available when this method is called.

Connector classes should override init() instead of this method.

Specified by:
doInit in interface ServerConnector

init

protected void init()
Called when the connector has been initialized. Override this method to perform initialization of the connector.


registerRpc

protected <T extends ClientRpc> void registerRpc(Class<T> rpcInterface,
                                                 T implementation)
Registers an implementation for a server to client RPC interface. Multiple registrations can be made for a single interface, in which case all of them receive corresponding RPC calls.

Type Parameters:
T - The type of the RPC interface that is being registered
Parameters:
rpcInterface - RPC interface
implementation - implementation that should receive RPC calls

unregisterRpc

protected <T extends ClientRpc> void unregisterRpc(Class<T> rpcInterface,
                                                   T implementation)
Unregisters an implementation for a server to client RPC interface.

Parameters:
rpcInterface - RPC interface
implementation - implementation to unregister

getRpcImplementations

public <T extends ClientRpc> Collection<T> getRpcImplementations(String rpcInterfaceId)
Description copied from interface: ServerConnector
For internal use by the framework: returns the registered RPC implementations for an RPC interface identifier. TODO interface identifier type or format may change

Specified by:
getRpcImplementations in interface ServerConnector
Parameters:
rpcInterfaceId - RPC interface identifier: fully qualified interface type name
Returns:
RPC interface implementations registered for an RPC interface, not null

fireEvent

public void fireEvent(com.google.gwt.event.shared.GwtEvent<?> event)
Description copied from interface: ServerConnector
Sends the given event to all registered handlers.

Specified by:
fireEvent in interface ServerConnector
Parameters:
event - The event to send.

ensureHandlerManager

protected com.google.gwt.event.shared.HandlerManager ensureHandlerManager()

addStateChangeHandler

public com.google.web.bindery.event.shared.HandlerRegistration addStateChangeHandler(StateChangeEvent.StateChangeHandler handler)
Description copied from interface: ServerConnector
Adds a handler that is called whenever some part of the state has been updated by the server.

Specified by:
addStateChangeHandler in interface ServerConnector
Parameters:
handler - The handler that should be added.
Returns:
A handler registration reference that can be used to unregister the handler

onStateChanged

public void onStateChanged(StateChangeEvent stateChangeEvent)
Specified by:
onStateChanged in interface StateChangeEvent.StateChangeHandler

onUnregister

public void onUnregister()
Description copied from interface: ServerConnector
Event called when connector has been unregistered.

Specified by:
onUnregister in interface ServerConnector

getState

public SharedState getState()
Returns the shared state object for this connector. Override this method to define the shared state type for your connector.

Specified by:
getState in interface Connector
Returns:
the current shared state (never null)

createState

protected SharedState createState()
Creates a state object with default values for this connector. The created state object must be compatible with the return type of getState(). The default implementation creates a state object using GWT.create() using the defined return type of getState().

Returns:
A new state object

getParent

public ServerConnector getParent()
Description copied from interface: ServerConnector
Returns the parent of this connector. Can be null for only the root connector.

Specified by:
getParent in interface Connector
Specified by:
getParent in interface ServerConnector
Returns:
The parent of this connector, as set by ServerConnector.setParent(ServerConnector).

setParent

public void setParent(ServerConnector parent)
Description copied from interface: ServerConnector
Sets the parent for this connector. This method should only be called by the framework to ensure that the connector hierarchy on the client side and the server side are in sync.

Note that calling this method does not fire a ConnectorHierarchyChangeEvent. The event is fired only when the whole hierarchy has been updated.

Specified by:
setParent in interface ServerConnector
Parameters:
parent - The new parent of the connector

getChildren

public List<ServerConnector> getChildren()
Specified by:
getChildren in interface ServerConnector

setChildren

public void setChildren(List<ServerConnector> children)
Specified by:
setChildren in interface ServerConnector

isEnabled

public boolean isEnabled()
Description copied from interface: ServerConnector
Tests whether the connector is enabled or not. This method checks that the connector is enabled in context, i.e. if the parent connector is disabled, this method must return false.

Specified by:
isEnabled in interface ServerConnector
Returns:
true if the connector is enabled, false otherwise

updateEnabledState

public void updateEnabledState(boolean enabledState)
Specified by:
updateEnabledState in interface ServerConnector


Copyright © 2000-2011 Vaadin Ltd. All Rights Reserved.