com.vaadin.terminal.gwt.client.


Class ApplicationConnection

java.lang.Object
  com.vaadin.terminal.gwt.client.ApplicationConnection

public class ApplicationConnection
extends Object

This is the client side communication "engine", managing client-server communication with its server side counterpart AbstractCommunicationManager. Client-side widgets receive updates from the corresponding server-side components as calls to Paintable.updateFromUIDL(UIDL, ApplicationConnection) (not to be confused with the server side interface Paintable ). Any client-side changes (typically resulting from user actions) are sent back to the server as variable changes (see #updateVariable()). TODO document better Entry point classes (widgetsets) define onModuleLoad().

Field Summary
protected  boolean applicationRunning
           
static String ATTRIBUTE_DESCRIPTION
           
static String ATTRIBUTE_ERROR
           
static String DISABLED_CLASSNAME
           
static String GENERATED_BODY_CLASSNAME
           
protected  int lastProcessingTime
          Holds the time spent rendering the last request
static String PARAM_UNLOADBURST
           
protected  int totalProcessingTime
          Holds the total time spent rendering requests during the lifetime of the session.
static String UIDL_REFRESH_TOKEN
          A string that, if found in a non-JSON response to a UIDL request, will cause the browser to refresh the page.
static String UIDL_SECURITY_HEADER
          Deprecated. use UIDL_SECURITY_TOKEN_ID instead
static String UIDL_SECURITY_TOKEN_ID
           
static char VAR_ARRAYITEM_SEPARATOR
           
static char VAR_BURST_SEPARATOR
           
static char VAR_ESCAPE_CHARACTER
           
static char VAR_FIELD_SEPARATOR
           
static char VAR_RECORD_SEPARATOR
           
 
Constructor Summary
ApplicationConnection()
           
 
Method Summary
static String addGetParameters(String uri, String extraParams)
          Adds the get parameters to the uri and returns the new uri that contains the parameters.
 void addPngFix(com.google.gwt.user.client.Element el)
          Adds PNG-fix conditionally (only for IE6) to the specified IMG -element.
 void analyzeLayouts()
          Requests an analyze of layouts, to find inconsistencies.
 void captionSizeUpdated(Paintable component)
          Use to notify that the given component's caption has changed; layouts may have to be recalculated.
protected  void doAsyncUIDLRequest(String uri, String payload, com.google.gwt.http.client.RequestCallback requestCallback)
          Sends an asynchronous UIDL request to the server using the given URI.
protected  void doUidlRequest(String uri, String payload, boolean synchronous)
          Sends an asynchronous or synchronous UIDL request to the server using the given URI.
protected  void endRequest()
           
protected  String escapeVariableValue(String value)
          Encode burst, record, field and array item separator characters in a String for transport over the network.
protected  void extendLiferaySession()
          If on Liferay and logged in, ask the client side session management JavaScript to extend the session duration.
 void forceLayout()
          This will cause re-layouting of all components.
 String getAppUri()
          Gets the application base URI.
 ApplicationConfiguration getConfiguration()
          Gets the ApplicationConfiguration for the current application.
static Console getConsole()
          Deprecated. Developers should use VConsole since 6.4.5
 VContextMenu getContextMenu()
          Singleton method to get instance of app's context menu.
 com.google.gwt.user.client.Element getElementByPid(String pid)
          Gets the main element for the paintable with the given id.
 Paintable getPaintable(com.google.gwt.user.client.Element element)
          Returns a Paintable element by its root element
 Paintable getPaintable(String id)
          Returns Paintable element by its id
 Paintable getPaintable(UIDL uidl)
          Get either existing or new Paintable for given UIDL.
 String getPid(com.google.gwt.user.client.Element el)
          Gets the paintableId using a DOM element - the element should be the main element for a paintable otherwise no id will be found.
 String getPid(Paintable paintable)
          Gets the paintableId for a specific paintable (a.k.a Vaadin Widget).
 RenderInformation.FloatSize getRelativeSize(com.google.gwt.user.client.ui.Widget widget)
          Gets the specified Paintables relative size (percent).
 String getResource(String name)
          Gets a recource that has been pre-loaded via UIDL, such as custom layouts.
static String getStyleName(String primaryStyleName, UIDL uidl, boolean field)
          Generates the style name for the widget based on the given primary style name (typically returned by Widget.getPrimaryStyleName()) and the UIDL.
 String getThemeUri()
          Gets the URI for the current theme.
 TooltipInfo getTooltipTitleInfo(Paintable titleOwner, Object key)
          Data showed in tooltips are stored centrilized as it may be needed in varios place: caption, layouts, and in owner components themselves.
protected  String getUidlSecurityKey()
           
 VView getView()
          Gets the main view, a.k.a top-level window.
protected  String getWindowName()
           
 boolean handleComponentRelativeSize(com.google.gwt.user.client.ui.Widget child)
          Converts relative sizes into pixel sizes.
 void handleTooltipEvent(com.google.gwt.user.client.Event event, Paintable owner)
          Component may want to delegate Tooltip handling to client.
 void handleTooltipEvent(com.google.gwt.user.client.Event event, Paintable owner, Object key)
          Component may want to delegate Tooltip handling to client.
protected  void handleUIDLMessage(Date start, String jsonText, ValueMap json)
           
protected  void handleWhenCSSLoaded(String jsonText, ValueMap json)
           
 boolean hasActiveRequest()
          Indicates whether or not there are currently active UIDL requests.
 boolean hasEventListeners(Paintable paintable, String eventIdentifier)
          Checks if there is a registered server side listener for the event.
 void init(WidgetSet widgetSet, ApplicationConfiguration cnf)
           
static boolean isDebugMode()
          Deprecated. use ApplicationConfiguration isDebugMode instead.
 boolean isLoadingIndicatorVisible()
          Determines whether or not the loading indicator is showing.
protected  void makeUidlRequest(String requestData, String extraParams, boolean forceSync)
          Makes an UIDL request to the server.
 void registerPaintable(String pid, Paintable paintable)
           
 void registerTooltip(Paintable paintable, Object key, TooltipInfo tooltip)
          If component has several tooltips in addition to the one provided by AbstractComponent, component can register them with this method.
protected  void repaintAll()
           
 void requestLayoutPhase()
          Components can call this function to run all layout functions.
 void resetCachedSize(Paintable p)
          Removes the cached size info for the paintable.
 void runDescendentsLayout(com.google.gwt.user.client.ui.HasWidgets container)
          Causes a re-calculation/re-layout of all paintables in a container.
 void sendPendingVariableChanges()
          This method sends currently queued variable changes to server.
 void sendPendingVariableChangesSync()
          This method assures that all pending variable changes are sent to server.
 void setWindowName(String newName)
          Reset the name of the current browser-window.
protected  void showAuthenticationError(String details)
          Shows the authentication error notification.
protected  void showCommunicationError(String details)
          Deprecated. Use the method with errorCode instead
protected  void showCommunicationError(String details, int statusCode)
          Shows the communication error notification.
 void start()
          Starts this application.
protected  void startRequest()
           
 String translateVaadinUri(String uidlUri)
          Translates custom protocols in UIDL URI's to be recognizable by browser.
 void unregisterChildPaintables(com.google.gwt.user.client.ui.HasWidgets container)
          Unregisters a paintable and all it's child paintables recursively.
 void unregisterPaintable(Paintable p)
          Unregisters the given paintable; always use after removing a paintable.
 boolean updateComponent(com.google.gwt.user.client.ui.Widget component, UIDL uidl, boolean manageCaption)
          Update generic component features.
 void updateVariable(String paintableId, String variableName, boolean newValue, boolean immediate)
          Sends a new value for the given paintables given variable to the server.
 void updateVariable(String paintableId, String variableName, double newValue, boolean immediate)
          Sends a new value for the given paintables given variable to the server.
 void updateVariable(String paintableId, String variableName, float newValue, boolean immediate)
          Sends a new value for the given paintables given variable to the server.
 void updateVariable(String paintableId, String variableName, int newValue, boolean immediate)
          Sends a new value for the given paintables given variable to the server.
 void updateVariable(String paintableId, String variableName, long newValue, boolean immediate)
          Sends a new value for the given paintables given variable to the server.
 void updateVariable(String paintableId, String variableName, Map<String,Object> map, boolean immediate)
          Sends a new value for the given paintables given variable to the server.
 void updateVariable(String paintableId, String variableName, Object[] values, boolean immediate)
          Sends a new value for the given paintables given variable to the server.
 void updateVariable(String paintableId, String variableName, Paintable newValue, boolean immediate)
          Sends a new value for the given paintables given variable to the server.
 void updateVariable(String paintableId, String variableName, String[] values, boolean immediate)
          Sends a new value for the given paintables given variable to the server.
 void updateVariable(String paintableId, String variableName, String newValue, boolean immediate)
          Sends a new value for the given paintables given variable to the server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GENERATED_BODY_CLASSNAME

public static final String GENERATED_BODY_CLASSNAME

See Also:

Constant Field Values

DISABLED_CLASSNAME

public static final String DISABLED_CLASSNAME

See Also:

Constant Field Values

VAR_RECORD_SEPARATOR

public static final char VAR_RECORD_SEPARATOR

See Also:

Constant Field Values

VAR_FIELD_SEPARATOR

public static final char VAR_FIELD_SEPARATOR

See Also:

Constant Field Values

VAR_BURST_SEPARATOR

public static final char VAR_BURST_SEPARATOR

See Also:

Constant Field Values

VAR_ARRAYITEM_SEPARATOR

public static final char VAR_ARRAYITEM_SEPARATOR

See Also:

Constant Field Values

VAR_ESCAPE_CHARACTER

public static final char VAR_ESCAPE_CHARACTER

See Also:

Constant Field Values

UIDL_SECURITY_TOKEN_ID

public static final String UIDL_SECURITY_TOKEN_ID

See Also:

Constant Field Values

UIDL_SECURITY_HEADER

@Deprecated
public static final String UIDL_SECURITY_HEADER

Deprecated. use UIDL_SECURITY_TOKEN_ID instead

See Also:
Constant Field Values

PARAM_UNLOADBURST

public static final String PARAM_UNLOADBURST

See Also:

Constant Field Values

ATTRIBUTE_DESCRIPTION

public static final String ATTRIBUTE_DESCRIPTION

See Also:

Constant Field Values

ATTRIBUTE_ERROR

public static final String ATTRIBUTE_ERROR

See Also:

Constant Field Values

UIDL_REFRESH_TOKEN

public static final String UIDL_REFRESH_TOKEN

A string that, if found in a non-JSON response to a UIDL request, will cause the browser to refresh the page. If followed by a colon, optional whitespace, and a URI, causes the browser to synchronously load the URI.

This allows, for instance, a servlet filter to redirect the application to a custom login page when the session expires. For example:

 if (sessionExpired) {
     response.setHeader("Content-Type", "text/html");
     response.getWriter().write(
             myLoginPageHtml + "<!-- Vaadin-Refresh: "
                     + request.getContextPath() + " -->");
 }
 

See Also:
Constant Field Values

applicationRunning

protected boolean applicationRunning

lastProcessingTime

protected int lastProcessingTime

Holds the time spent rendering the last request

totalProcessingTime

protected int totalProcessingTime

Holds the total time spent rendering requests during the lifetime of the session.

Constructor Detail

ApplicationConnection

public ApplicationConnection()
Method Detail

init

public void init(WidgetSet widgetSet,
                 ApplicationConfiguration cnf)

start

public void start()

Starts this application. Don't call this method directly - it's called by ApplicationConfiguration.startNextApplication(), which should be called once this application has started (first response received) or failed to start. This ensures that the applications are started in order, to avoid session-id problems.

extendLiferaySession

protected void extendLiferaySession()

If on Liferay and logged in, ask the client side session management JavaScript to extend the session duration. Otherwise, Liferay client side JavaScript will explicitly expire the session even though the server side considers the session to be active. See ticket #8305 for more information.

getConsole

@Deprecated
public static Console getConsole()

Deprecated. Developers should use VConsole since 6.4.5

Get the active Console for writing debug messages. May return an actual logging console, or the NullConsole if debugging is not turned on.

Returns:
the active Console

isDebugMode

@Deprecated
public static boolean isDebugMode()

Deprecated. use ApplicationConfiguration isDebugMode instead.

Checks if client side is in debug mode. Practically this is invoked by adding ?debug parameter to URI.

Returns:
true if client side is currently been debugged

getAppUri

public String getAppUri()

Gets the application base URI. Using this other than as the download action URI can cause problems in Portlet 2.0 deployments.

Returns:
application base URI

hasActiveRequest

public boolean hasActiveRequest()

Indicates whether or not there are currently active UIDL requests. Used internally to sequence requests properly, seldom needed in Widgets.

Returns:
true if there are active requests

repaintAll

protected void repaintAll()

analyzeLayouts

public void analyzeLayouts()

Requests an analyze of layouts, to find inconsistencies. Exclusively used for debugging during development.

makeUidlRequest

protected void makeUidlRequest(String requestData,
                               String extraParams,
                               boolean forceSync)

Makes an UIDL request to the server.

Parameters:
requestData - Data that is passed to the server.
extraParams - Parameters that are added as GET parameters to the url. Contains key=value pairs joined by & characters or is empty if no parameters should be added. Should not start with any special character.
forceSync - true if the request should be synchronous, false otherwise

doUidlRequest

protected void doUidlRequest(String uri,
                             String payload,
                             boolean synchronous)

Sends an asynchronous or synchronous UIDL request to the server using the given URI.

Parameters:
uri - The URI to use for the request. May includes GET parameters
payload - The contents of the request to send
synchronous - true if the request should be synchronous, false otherwise

doAsyncUIDLRequest

protected void doAsyncUIDLRequest(String uri,
                                  String payload,
                                  com.google.gwt.http.client.RequestCallback requestCallback)
                           throws com.google.gwt.http.client.RequestException

Sends an asynchronous UIDL request to the server using the given URI.

Parameters:
uri - The URI to use for the request. May includes GET parameters
payload - The contents of the request to send
requestCallback - The handler for the response
Throws:
com.google.gwt.http.client.RequestException - if the request could not be sent

handleWhenCSSLoaded

protected void handleWhenCSSLoaded(String jsonText,
                                   ValueMap json)

showCommunicationError

@Deprecated
protected void showCommunicationError(String details)

Deprecated. Use the method with errorCode instead

Shows the communication error notification.

Parameters:
details - Optional details for debugging.

showCommunicationError

protected void showCommunicationError(String details,
                                      int statusCode)

Shows the communication error notification.

Parameters:
details - Optional details for debugging.
statusCode - The http error code during the problematic request or -1 if error happened before response was received.

showAuthenticationError

protected void showAuthenticationError(String details)

Shows the authentication error notification.

Parameters:
details - Optional details for debugging.

startRequest

protected void startRequest()

endRequest

protected void endRequest()

isLoadingIndicatorVisible

public boolean isLoadingIndicatorVisible()

Determines whether or not the loading indicator is showing.

Returns:
true if the loading indicator is visible

handleUIDLMessage

protected void handleUIDLMessage(Date start,
                                 String jsonText,
                                 ValueMap json)

sendPendingVariableChangesSync

public void sendPendingVariableChangesSync()

This method assures that all pending variable changes are sent to server. Method uses synchronized xmlhttprequest and does not return before the changes are sent. No UIDL updates are processed and thus UI is left in inconsistent state. This method should be called only when closing windows - normally sendPendingVariableChanges() should be used.

registerPaintable

public void registerPaintable(String pid,
                              Paintable paintable)

getPid

public String getPid(Paintable paintable)

Gets the paintableId for a specific paintable (a.k.a Vaadin Widget).

The paintableId is used in the UIDL to identify a specific widget instance, effectively linking the widget with it's server side Component.

Parameters:
paintable - the paintable who's id is needed
Returns:
the id for the given paintable

getPid

public String getPid(com.google.gwt.user.client.Element el)

Gets the paintableId using a DOM element - the element should be the main element for a paintable otherwise no id will be found. Use getPid(Paintable) instead whenever possible.

Parameters:
el - element of the paintable whose pid is desired
Returns:
the pid of the element's paintable, if it's a paintable
See Also:
getPid(Paintable)

getElementByPid

public com.google.gwt.user.client.Element getElementByPid(String pid)

Gets the main element for the paintable with the given id. The revers of getPid(Element).

Parameters:
pid - the pid of the widget whose element is desired
Returns:
the element for the paintable corresponding to the pid

unregisterPaintable

public void unregisterPaintable(Paintable p)

Unregisters the given paintable; always use after removing a paintable. This method does not remove the paintable from the DOM, but marks the paintable so that ApplicationConnection may clean up its references to it. Removing the widget from DOM is component containers responsibility.

Parameters:
p - the paintable to remove

unregisterChildPaintables

public void unregisterChildPaintables(com.google.gwt.user.client.ui.HasWidgets container)

Unregisters a paintable and all it's child paintables recursively. Use when after removing a paintable that contains other paintables. Does not unregister the given container itself. Does not actually remove the paintable from the DOM.

Parameters:
container -
See Also:
unregisterPaintable(Paintable)

getPaintable

public Paintable getPaintable(String id)

Returns Paintable element by its id

Parameters:
id - Paintable ID

sendPendingVariableChanges

public void sendPendingVariableChanges()

This method sends currently queued variable changes to server. It is called when immediate variable update must happen. To ensure correct order for variable changes (due servers multithreading or network), we always wait for active request to be handler before sending a new one. If there is an active request, we will put varible "burst" to queue that will be purged after current request is handled.

updateVariable

public void updateVariable(String paintableId,
                           String variableName,
                           Paintable newValue,
                           boolean immediate)

Sends a new value for the given paintables given variable to the server.

The update is actually queued to be sent at a suitable time. If immediate is true, the update is sent as soon as possible. If immediate is false, the update will be sent along with the next immediate update.

Parameters:
paintableId - the id of the paintable that owns the variable
variableName - the name of the variable
newValue - the new value to be sent
immediate - true if the update is to be sent as soon as possible

updateVariable

public void updateVariable(String paintableId,
                           String variableName,
                           String newValue,
                           boolean immediate)

Sends a new value for the given paintables given variable to the server.

The update is actually queued to be sent at a suitable time. If immediate is true, the update is sent as soon as possible. If immediate is false, the update will be sent along with the next immediate update.

Parameters:
paintableId - the id of the paintable that owns the variable
variableName - the name of the variable
newValue - the new value to be sent
immediate - true if the update is to be sent as soon as possible

updateVariable

public void updateVariable(String paintableId,
                           String variableName,
                           int newValue,
                           boolean immediate)

Sends a new value for the given paintables given variable to the server.

The update is actually queued to be sent at a suitable time. If immediate is true, the update is sent as soon as possible. If immediate is false, the update will be sent along with the next immediate update.

Parameters:
paintableId - the id of the paintable that owns the variable
variableName - the name of the variable
newValue - the new value to be sent
immediate - true if the update is to be sent as soon as possible

updateVariable

public void updateVariable(String paintableId,
                           String variableName,
                           long newValue,
                           boolean immediate)

Sends a new value for the given paintables given variable to the server.

The update is actually queued to be sent at a suitable time. If immediate is true, the update is sent as soon as possible. If immediate is false, the update will be sent along with the next immediate update.

Parameters:
paintableId - the id of the paintable that owns the variable
variableName - the name of the variable
newValue - the new value to be sent
immediate - true if the update is to be sent as soon as possible

updateVariable

public void updateVariable(String paintableId,
                           String variableName,
                           float newValue,
                           boolean immediate)

Sends a new value for the given paintables given variable to the server.

The update is actually queued to be sent at a suitable time. If immediate is true, the update is sent as soon as possible. If immediate is false, the update will be sent along with the next immediate update.

Parameters:
paintableId - the id of the paintable that owns the variable
variableName - the name of the variable
newValue - the new value to be sent
immediate - true if the update is to be sent as soon as possible

updateVariable

public void updateVariable(String paintableId,
                           String variableName,
                           double newValue,
                           boolean immediate)

Sends a new value for the given paintables given variable to the server.

The update is actually queued to be sent at a suitable time. If immediate is true, the update is sent as soon as possible. If immediate is false, the update will be sent along with the next immediate update.

Parameters:
paintableId - the id of the paintable that owns the variable
variableName - the name of the variable
newValue - the new value to be sent
immediate - true if the update is to be sent as soon as possible

updateVariable

public void updateVariable(String paintableId,
                           String variableName,
                           boolean newValue,
                           boolean immediate)

Sends a new value for the given paintables given variable to the server.

The update is actually queued to be sent at a suitable time. If immediate is true, the update is sent as soon as possible. If immediate is false, the update will be sent along with the next immediate update.

Parameters:
paintableId - the id of the paintable that owns the variable
variableName - the name of the variable
newValue - the new value to be sent
immediate - true if the update is to be sent as soon as possible

updateVariable

public void updateVariable(String paintableId,
                           String variableName,
                           Map<String,Object> map,
                           boolean immediate)

Sends a new value for the given paintables given variable to the server.

The update is actually queued to be sent at a suitable time. If immediate is true, the update is sent as soon as possible. If immediate is false, the update will be sent along with the next immediate update.

Parameters:
paintableId - the id of the paintable that owns the variable
variableName - the name of the variable
newValue - the new value to be sent
immediate - true if the update is to be sent as soon as possible

updateVariable

public void updateVariable(String paintableId,
                           String variableName,
                           String[] values,
                           boolean immediate)

Sends a new value for the given paintables given variable to the server. The update is actually queued to be sent at a suitable time. If immediate is true, the update is sent as soon as possible. If immediate is false, the update will be sent along with the next immediate update. A null array is sent as an empty array.

Parameters:
paintableId - the id of the paintable that owns the variable
variableName - the name of the variable
newValue - the new value to be sent
immediate - true if the update is to be sent as soon as possible

updateVariable

public void updateVariable(String paintableId,
                           String variableName,
                           Object[] values,
                           boolean immediate)

Sends a new value for the given paintables given variable to the server. The update is actually queued to be sent at a suitable time. If immediate is true, the update is sent as soon as possible. If immediate is false, the update will be sent along with the next immediate update.

A null array is sent as an empty array.

Parameters:
paintableId - the id of the paintable that owns the variable
variableName - the name of the variable
newValue - the new value to be sent
immediate - true if the update is to be sent as soon as possible

escapeVariableValue

protected String escapeVariableValue(String value)

Encode burst, record, field and array item separator characters in a String for transport over the network. This protects from separator injection attacks.

Parameters:
value - to encode
Returns:
encoded value

updateComponent

public boolean updateComponent(com.google.gwt.user.client.ui.Widget component,
                               UIDL uidl,
                               boolean manageCaption)

Update generic component features.

Selecting correct implementation

The implementation of a component depends on many properties, including styles, component features, etc. Sometimes the user changes those properties after the component has been created. Calling this method in the beginning of your updateFromUIDL -method automatically replaces your component with more appropriate if the requested implementation changes.

Caption, icon, error messages and description

Component can delegate management of caption, icon, error messages and description to parent layout. This is optional an should be decided by component author

Component visibility and disabling

This method will manage component visibility automatically and if component is an instanceof FocusWidget, also handle component disabling when needed.

Parameters:
component - Widget to be updated, expected to implement an instance of Paintable
uidl - UIDL to be painted
manageCaption - True if you want to delegate caption, icon, description and error message management to parent.
Returns:
Returns true iff no further painting is needed by caller

getStyleName

public static String getStyleName(String primaryStyleName,
                                  UIDL uidl,
                                  boolean field)

Generates the style name for the widget based on the given primary style name (typically returned by Widget.getPrimaryStyleName()) and the UIDL. An additional "modified" style name can be added if the field parameter is set to true.

Parameters:
primaryStyleName -
uidl -
isField -
Returns:

runDescendentsLayout

public void runDescendentsLayout(com.google.gwt.user.client.ui.HasWidgets container)

Causes a re-calculation/re-layout of all paintables in a container.

Parameters:
container -

forceLayout

public void forceLayout()

This will cause re-layouting of all components. Mainly used for development. Published to JavaScript.

handleComponentRelativeSize

public boolean handleComponentRelativeSize(com.google.gwt.user.client.ui.Widget child)

Converts relative sizes into pixel sizes.

Parameters:
child -
Returns:
true if the child has a relative size

getRelativeSize

public RenderInformation.FloatSize getRelativeSize(com.google.gwt.user.client.ui.Widget widget)

Gets the specified Paintables relative size (percent).

Parameters:
widget - the paintable whose size is needed
Returns:
the the size if the paintable is relatively sized, -1 otherwise

getPaintable

public Paintable getPaintable(UIDL uidl)

Get either existing or new Paintable for given UIDL. If corresponding Paintable has been previously painted, return it. Otherwise create and register a new Paintable from UIDL. Caller must update the returned Paintable from UIDL after it has been connected to parent.

Parameters:
uidl - UIDL to create Paintable from.
Returns:
Either existing or new Paintable corresponding to UIDL.

getPaintable

public Paintable getPaintable(com.google.gwt.user.client.Element element)

Returns a Paintable element by its root element

Parameters:
element - Root element of the paintable

getResource

public String getResource(String name)

Gets a recource that has been pre-loaded via UIDL, such as custom layouts.

Parameters:
name - identifier of the resource to get
Returns:
the resource

getContextMenu

public VContextMenu getContextMenu()

Singleton method to get instance of app's context menu.

Returns:
VContextMenu object

translateVaadinUri

public String translateVaadinUri(String uidlUri)

Translates custom protocols in UIDL URI's to be recognizable by browser. All uri's from UIDL should be routed via this method before giving them to browser due URI's in UIDL may contain custom protocols like theme://.

Parameters:
uidlUri - Vaadin URI from uidl
Returns:
translated URI ready for browser

getThemeUri

public String getThemeUri()

Gets the URI for the current theme. Can be used to reference theme resources.

Returns:
URI to the current theme

getTooltipTitleInfo

public TooltipInfo getTooltipTitleInfo(Paintable titleOwner,
                                       Object key)

Data showed in tooltips are stored centrilized as it may be needed in varios place: caption, layouts, and in owner components themselves. Updating TooltipInfo is done in updateComponent method.

handleTooltipEvent

public void handleTooltipEvent(com.google.gwt.user.client.Event event,
                               Paintable owner)

Component may want to delegate Tooltip handling to client. Layouts add Tooltip (description, errors) to caption, but some components may want them to appear one other elements too. Events wanted by this handler are same as in Tooltip.TOOLTIP_EVENTS

Parameters:
event -
owner -

handleTooltipEvent

public void handleTooltipEvent(com.google.gwt.user.client.Event event,
                               Paintable owner,
                               Object key)

Component may want to delegate Tooltip handling to client. Layouts add Tooltip (description, errors) to caption, but some components may want them to appear one other elements too. Events wanted by this handler are same as in Tooltip.TOOLTIP_EVENTS

Parameters:
event -
owner -
key - the key for tooltip if this is "additional" tooltip, null for components "main tooltip"

addPngFix

public void addPngFix(com.google.gwt.user.client.Element el)

Adds PNG-fix conditionally (only for IE6) to the specified IMG -element.

Parameters:
el - the IMG element to fix

requestLayoutPhase

public void requestLayoutPhase()

Components can call this function to run all layout functions. This is usually done, when component knows that its size has changed.

setWindowName

public void setWindowName(String newName)

Reset the name of the current browser-window. This should reflect the window-name used in the server, but might be different from the window-object target-name on client.

Parameters:
stringAttribute - New name for the window.

getWindowName

protected String getWindowName()

getUidlSecurityKey

protected String getUidlSecurityKey()

captionSizeUpdated

public void captionSizeUpdated(Paintable component)

Use to notify that the given component's caption has changed; layouts may have to be recalculated.

Parameters:
component - the Paintable whose caption has changed

getView

public VView getView()

Gets the main view, a.k.a top-level window.

Returns:
the main view

registerTooltip

public void registerTooltip(Paintable paintable,
                            Object key,
                            TooltipInfo tooltip)

If component has several tooltips in addition to the one provided by AbstractComponent, component can register them with this method.

Component must also pipe events to handleTooltipEvent(Event, Paintable, Object) method.

This method can also be used to deregister tooltips by using null as tooltip

Parameters:
paintable - Paintable "owning" this tooltip
key - key assosiated with given tooltip. Can be any object. For example a related dom element. Same key must be given for handleTooltipEvent(Event, Paintable, Object) method.
tooltip - the TooltipInfo object containing details shown in tooltip, null if deregistering tooltip

getConfiguration

public ApplicationConfiguration getConfiguration()

Gets the ApplicationConfiguration for the current application.

Returns:
the configuration for this application
See Also:
ApplicationConfiguration

hasEventListeners

public boolean hasEventListeners(Paintable paintable,
                                 String eventIdentifier)

Checks if there is a registered server side listener for the event. The list of events which has server side listeners is updated automatically before the component is updated so the value is correct if called from updatedFromUIDL.

Parameters:
eventIdentifier - The identifier for the event
Returns:
true if at least one listener has been registered on server side for the event identified by eventIdentifier.

addGetParameters

public static String addGetParameters(String uri,
                                      String extraParams)

Adds the get parameters to the uri and returns the new uri that contains the parameters.

Parameters:
uri - The uri to which the parameters should be added.
extraParams - One or more parameters in the format "a=b" or "c=d&e=f". An empty string is allowed but will not modify the url.
Returns:
The modified URI with the get parameters in extraParams added.

resetCachedSize

public void resetCachedSize(Paintable p)

Removes the cached size info for the paintable. This is for really edge cases only and should normally not be called by anyone.

Parameters:
p - The paintable whose cached size info should be discarded