com.vaadin.terminal.gwt.client.
Class ApplicationConnection
java.lang.Object
com.vaadin.terminal.gwt.client.ApplicationConnection
- extends Object
public class ApplicationConnection
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:
DISABLED_CLASSNAME
public static final String DISABLED_CLASSNAME
See Also:
VAR_RECORD_SEPARATOR
public static final char VAR_RECORD_SEPARATOR
See Also:
VAR_FIELD_SEPARATOR
public static final char VAR_FIELD_SEPARATOR
See Also:
VAR_BURST_SEPARATOR
public static final char VAR_BURST_SEPARATOR
See Also:
VAR_ARRAYITEM_SEPARATOR
public static final char VAR_ARRAYITEM_SEPARATOR
See Also:
VAR_ESCAPE_CHARACTER
public static final char VAR_ESCAPE_CHARACTER
See Also:
UIDL_SECURITY_TOKEN_ID
public static final String UIDL_SECURITY_TOKEN_ID
See Also:
UIDL_SECURITY_HEADER
@Deprecated
public static final String UIDL_SECURITY_HEADER
- See Also:
- Constant Field Values
Deprecated. use UIDL_SECURITY_TOKEN_ID instead
PARAM_UNLOADBURST
public static final String PARAM_UNLOADBURST
See Also:
ATTRIBUTE_DESCRIPTION
public static final String ATTRIBUTE_DESCRIPTION
See Also:
ATTRIBUTE_ERROR
public static final String ATTRIBUTE_ERROR
See Also:
UIDL_REFRESH_TOKEN
public static final String UIDL_REFRESH_TOKEN
- See Also:
- Constant Field Values
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() + " -->");
}
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()
- Returns:
- the active Console
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.
isDebugMode
@Deprecated
public static boolean isDebugMode()
- Returns:
- true if client side is currently been debugged
Deprecated. use ApplicationConfiguration isDebugMode instead.
Checks if client side is in debug mode. Practically this is invoked by adding ?debug parameter to URI.
getAppUri
public String getAppUri()
- Returns:
- application base URI
Gets the application base URI. Using this other than as the download action URI can cause problems in Portlet 2.0 deployments.
hasActiveRequest
public boolean hasActiveRequest()
- Returns:
- true if there are active requests
Indicates whether or not there are currently active UIDL requests. Used internally to sequence requests properly, seldom needed in Widgets.
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)
- 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
Makes an UIDL request to the server.
doUidlRequest
protected void doUidlRequest(String uri,
String payload,
boolean synchronous)
- Parameters:
uri
- The URI to use for the request. May includes GET parameterspayload
- The contents of the request to sendsynchronous
- true if the request should be synchronous, false otherwise
Sends an asynchronous or synchronous UIDL request to the server using the given URI.
doAsyncUIDLRequest
protected void doAsyncUIDLRequest(String uri,
String payload,
com.google.gwt.http.client.RequestCallback requestCallback)
throws com.google.gwt.http.client.RequestException
- Parameters:
uri
- The URI to use for the request. May includes GET parameterspayload
- The contents of the request to sendrequestCallback
- The handler for the response- Throws:
com.google.gwt.http.client.RequestException
- if the request could not be sent
Sends an asynchronous UIDL request to the server using the given URI.
handleWhenCSSLoaded
protected void handleWhenCSSLoaded(String jsonText,
ValueMap json)
showCommunicationError
@Deprecated
protected void showCommunicationError(String details)
- Parameters:
details
- Optional details for debugging.
Deprecated. Use the method with errorCode instead
Shows the communication error notification.
showCommunicationError
protected void showCommunicationError(String details,
int statusCode)
- Parameters:
details
- Optional details for debugging.statusCode
- The http error code during the problematic request or -1 if error happened before response was received.
Shows the communication error notification.
showAuthenticationError
protected void showAuthenticationError(String details)
- Parameters:
details
- Optional details for debugging.
Shows the authentication error notification.
startRequest
protected void startRequest()
endRequest
protected void endRequest()
isLoadingIndicatorVisible
public boolean isLoadingIndicatorVisible()
- Returns:
- true if the loading indicator is visible
Determines whether or not the loading indicator is showing.
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)
- Parameters:
paintable
- the paintable who's id is needed- Returns:
- the id for the given 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.
getPid
public String getPid(com.google.gwt.user.client.Element el)
- 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)
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.
getElementByPid
public com.google.gwt.user.client.Element getElementByPid(String pid)
- Parameters:
pid
- the pid of the widget whose element is desired- Returns:
- the element for the paintable corresponding to the pid
Gets the main element for the paintable with the given id. The revers of
getPid(Element)
.
unregisterPaintable
public void unregisterPaintable(Paintable p)
- Parameters:
p
- the paintable to remove
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.
unregisterChildPaintables
public void unregisterChildPaintables(com.google.gwt.user.client.ui.HasWidgets container)
- Parameters:
container
-- See Also:
unregisterPaintable(Paintable)
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.
getPaintable
public Paintable getPaintable(String id)
- Parameters:
id
- Paintable ID
Returns Paintable element by its 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)
- Parameters:
paintableId
- the id of the paintable that owns the variablevariableName
- the name of the variablenewValue
- the new value to be sentimmediate
- true if the update is to be sent as soon as possible
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.
updateVariable
public void updateVariable(String paintableId,
String variableName,
String newValue,
boolean immediate)
- Parameters:
paintableId
- the id of the paintable that owns the variablevariableName
- the name of the variablenewValue
- the new value to be sentimmediate
- true if the update is to be sent as soon as possible
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.
updateVariable
public void updateVariable(String paintableId,
String variableName,
int newValue,
boolean immediate)
- Parameters:
paintableId
- the id of the paintable that owns the variablevariableName
- the name of the variablenewValue
- the new value to be sentimmediate
- true if the update is to be sent as soon as possible
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.
updateVariable
public void updateVariable(String paintableId,
String variableName,
long newValue,
boolean immediate)
- Parameters:
paintableId
- the id of the paintable that owns the variablevariableName
- the name of the variablenewValue
- the new value to be sentimmediate
- true if the update is to be sent as soon as possible
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.
updateVariable
public void updateVariable(String paintableId,
String variableName,
float newValue,
boolean immediate)
- Parameters:
paintableId
- the id of the paintable that owns the variablevariableName
- the name of the variablenewValue
- the new value to be sentimmediate
- true if the update is to be sent as soon as possible
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.
updateVariable
public void updateVariable(String paintableId,
String variableName,
double newValue,
boolean immediate)
- Parameters:
paintableId
- the id of the paintable that owns the variablevariableName
- the name of the variablenewValue
- the new value to be sentimmediate
- true if the update is to be sent as soon as possible
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.
updateVariable
public void updateVariable(String paintableId,
String variableName,
boolean newValue,
boolean immediate)
- Parameters:
paintableId
- the id of the paintable that owns the variablevariableName
- the name of the variablenewValue
- the new value to be sentimmediate
- true if the update is to be sent as soon as possible
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.
updateVariable
public void updateVariable(String paintableId,
String variableName,
Map<String,Object> map,
boolean immediate)
- Parameters:
paintableId
- the id of the paintable that owns the variablevariableName
- the name of the variablenewValue
- the new value to be sentimmediate
- true if the update is to be sent as soon as possible
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.
updateVariable
public void updateVariable(String paintableId,
String variableName,
String[] values,
boolean immediate)
- Parameters:
paintableId
- the id of the paintable that owns the variablevariableName
- the name of the variablenewValue
- the new value to be sentimmediate
- true if the update is to be sent as soon as possible
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.
updateVariable
public void updateVariable(String paintableId,
String variableName,
Object[] values,
boolean immediate)
- Parameters:
paintableId
- the id of the paintable that owns the variablevariableName
- the name of the variablenewValue
- the new value to be sentimmediate
- true if the update is to be sent as soon as possible
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.
escapeVariableValue
protected String escapeVariableValue(String value)
- Parameters:
value
- to encode- Returns:
- encoded value
Encode burst, record, field and array item separator characters in a String for transport over the network. This protects from separator injection attacks.
updateComponent
public boolean updateComponent(com.google.gwt.user.client.ui.Widget component,
UIDL uidl,
boolean manageCaption)
- Parameters:
component
- Widget to be updated, expected to implement an instance of Paintableuidl
- UIDL to be paintedmanageCaption
- 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
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.
getStyleName
public static String getStyleName(String primaryStyleName,
UIDL uidl,
boolean field)
- Parameters:
primaryStyleName
-uidl
-isField
-- Returns:
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.
runDescendentsLayout
public void runDescendentsLayout(com.google.gwt.user.client.ui.HasWidgets container)
- Parameters:
container
-
Causes a re-calculation/re-layout of all paintables in a 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)
- Parameters:
child
-- Returns:
- true if the child has a relative size
Converts relative sizes into pixel sizes.
getRelativeSize
public RenderInformation.FloatSize getRelativeSize(com.google.gwt.user.client.ui.Widget widget)
- Parameters:
widget
- the paintable whose size is needed- Returns:
- the the size if the paintable is relatively sized, -1 otherwise
Gets the specified Paintables relative size (percent).
getPaintable
public Paintable getPaintable(UIDL uidl)
- Parameters:
uidl
- UIDL to create Paintable from.- Returns:
- Either existing or new Paintable corresponding to 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.
getPaintable
public Paintable getPaintable(com.google.gwt.user.client.Element element)
- Parameters:
element
- Root element of the paintable
Returns a Paintable element by its root element
getResource
public String getResource(String name)
- Parameters:
name
- identifier of the resource to get- Returns:
- the resource
Gets a recource that has been pre-loaded via UIDL, such as custom layouts.
getContextMenu
public VContextMenu getContextMenu()
- Returns:
- VContextMenu object
Singleton method to get instance of app's context menu.
translateVaadinUri
public String translateVaadinUri(String uidlUri)
- Parameters:
uidlUri
- Vaadin URI from uidl- Returns:
- translated URI ready for browser
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://.
getThemeUri
public String getThemeUri()
- Returns:
- URI to the current theme
Gets the URI for the current theme. Can be used to reference theme resources.
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)
- Parameters:
event
-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
handleTooltipEvent
public void handleTooltipEvent(com.google.gwt.user.client.Event event,
Paintable owner,
Object key)
- Parameters:
event
-owner
-key
- the key for tooltip if this is "additional" tooltip, null for components "main tooltip"
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
addPngFix
public void addPngFix(com.google.gwt.user.client.Element el)
- Parameters:
el
- the IMG element to fix
Adds PNG-fix conditionally (only for IE6) to the specified IMG -element.
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)
- Parameters:
stringAttribute
- New name for the window.
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.
getWindowName
protected String getWindowName()
getUidlSecurityKey
protected String getUidlSecurityKey()
captionSizeUpdated
public void captionSizeUpdated(Paintable component)
- Parameters:
component
- the Paintable whose caption has changed
Use to notify that the given component's caption has changed; layouts may have to be recalculated.
getView
public VView getView()
- Returns:
- the main view
Gets the main view, a.k.a top-level window.
registerTooltip
public void registerTooltip(Paintable paintable,
Object key,
TooltipInfo tooltip)
- Parameters:
paintable
- Paintable "owning" this tooltipkey
- key assosiated with given tooltip. Can be any object. For example a related dom element. Same key must be given forhandleTooltipEvent(Event, Paintable, Object)
method.tooltip
- the TooltipInfo object containing details shown in tooltip, null if deregistering 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
getConfiguration
public ApplicationConfiguration getConfiguration()
- Returns:
- the configuration for this application
- See Also:
ApplicationConfiguration
Gets the ApplicationConfiguration
for the current application.
hasEventListeners
public boolean hasEventListeners(Paintable paintable,
String eventIdentifier)
- 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.
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.
addGetParameters
public static String addGetParameters(String uri,
String extraParams)
- 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.
Adds the get parameters to the uri and returns the new uri that contains the parameters.
resetCachedSize
public void resetCachedSize(Paintable p)
- Parameters:
p
- The paintable whose cached size info should be discarded
Removes the cached size info for the paintable. This is for really edge cases only and should normally not be called by anyone.