Eclipse Remote Application Platform

org.eclipse.rap.rwt.lifecycle
Class WidgetUtil

java.lang.Object
  extended by org.eclipse.rap.rwt.lifecycle.WidgetUtil

public final class WidgetUtil
extends java.lang.Object

This is a helper class to obtain different aspects for a widget related to the handling of widgets in RAP.

Since:
2.0

Field Summary
static java.lang.String CUSTOM_VARIANT
          Deprecated. Use RWT.CUSTOM_VARIANT instead
static java.lang.String CUSTOM_WIDGET_ID
           Note: This constant is provisional and subject to change without further notice.
static java.lang.String ENABLE_UI_TESTS
          Deprecated. The system property has been moved to the internal class RWTProperties. Please look up the name in the documentation of CUSTOM_WIDGET_ID.
 
Method Summary
static Widget find(Composite root, java.lang.String id)
          This method searches for a widget with the given id within the widget hierachy starting at root.
static WidgetAdapter getAdapter(Widget widget)
          Returns the according WidgetAdapter for a specified widget.
static java.lang.String getId(Widget widget)
          Returns the id of the given widget that is used to identify the widget on the client.
static AbstractWidgetLCA getLCA(Widget widget)
          Returns the AbstractWidgetLCA instance for this widget.
static java.lang.String getVariant(Widget widget)
          Returns the widget variant defined for the given widget using Widget.setData().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CUSTOM_VARIANT

@Deprecated
public static final java.lang.String CUSTOM_VARIANT
Deprecated. Use RWT.CUSTOM_VARIANT instead
See Also:
Constant Field Values

CUSTOM_WIDGET_ID

public static final java.lang.String CUSTOM_WIDGET_ID

Note: This constant is provisional and subject to change without further notice.

This constant can be used to apply a custom widget id to a widget. By default, the framework applies a unique widget id to every widget. This id is used to identify the widget in the client/server protocol. For UI tests, it can be helpful to replace these generated ids with custom ids in order to make the ids more human-readable and more stable against changes in the UI. The following snippet applies a custom widget id to a widget:

 widget.setData( WidgetUtil.CUSTOM_WIDGET_ID, "myCustomId" )
 

The support for custom widget ids must be explicitly enabled by setting the system property org.eclipse.rap.rwt.enableUITests to true. If activated, the default web client will also set the HTML id attribute for every widget that are rendered to the client to the widget id.

A custom widget id must be unique within the user session. It is the clients' responsibility to choose a unique id. Assigning an id that is used by another widget will lead to indeterministic behavior.

A custom widget id must only contain characters that are valid according to the W3C recommendation for id and name attributes.

See Also:
Widget.setData(String,Object), getId(Widget), Constant Field Values

ENABLE_UI_TESTS

@Deprecated
public static final java.lang.String ENABLE_UI_TESTS
Deprecated. The system property has been moved to the internal class RWTProperties. Please look up the name in the documentation of CUSTOM_WIDGET_ID.
See Also:
CUSTOM_WIDGET_ID
Method Detail

getAdapter

public static WidgetAdapter getAdapter(Widget widget)
Returns the according WidgetAdapter for a specified widget.

Parameters:
widget - the widget
Returns:
the WidgetAdapter instance

getId

public static java.lang.String getId(Widget widget)
Returns the id of the given widget that is used to identify the widget on the client.

Parameters:
widget - the widget to obtain the id for, must not be null
Returns:
the id for the given widget

getVariant

public static java.lang.String getVariant(Widget widget)
Returns the widget variant defined for the given widget using Widget.setData().

Parameters:
widget - the widget whose variant is requested
Returns:
the variant or null if no variant has been specified for the given widget

getLCA

public static AbstractWidgetLCA getLCA(Widget widget)
Returns the AbstractWidgetLCA instance for this widget.

Parameters:
widget - the widget to obtain the life cycle adapter from
Returns:
the life cycle adapter for the given widget

find

public static Widget find(Composite root,
                          java.lang.String id)
This method searches for a widget with the given id within the widget hierachy starting at root.

Parameters:
root - the root widget where to start the search
id - the id of the widget to search for
Returns:
the widget or null if there was no widget found with the given id within the widget hierarchy

Eclipse Remote Application Platform

Copyright (c) EclipseSource and others 2002, 2012. All rights reserved.