Eclipse Rich Ajax Platform Release 1.3

## org.eclipse.rwt.lifecycle
Class WidgetUtil

    java.lang.Object
      org.eclipse.rwt.lifecycle.WidgetUtil

public final class WidgetUtil
extends Object

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

Since:
  1.0

Field Summary
`static String` `CUSTOM_VARIANT` Used to mark a widget as belonging to a custom variant using `Widget.setData`.
`static String` `CUSTOM_WIDGET_ID` Note: This constant is provisional and subject to change without further notice.
`static String` `ENABLE_UI_TESTS` Note: This constant is provisional and subject to change without further notice.

Method Summary
`static Widget` `find(Composite root, String id)` This method searches for a widget with the given `id` within the widget hierachy starting at `root`.
`static IWidgetAdapter` `getAdapter(Widget widget)` Returns the according `IWidgetAdapter` for a specified widget.
`static 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 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

    public static final String CUSTOM_VARIANT

  Used to mark a widget as belonging to a custom variant using `Widget.setData`. For more information on custom widget variants, see the RAP help on theming.

  Since:
    1.1
  See Also:
    `Widget.setData(String,Object)`, Constant Field Values

### CUSTOM_WIDGET_ID

    public static final String CUSTOM_WIDGET_ID

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

  By default, the widget-id returned by `IWidgetAdapter.getId()` is an automatically generated value that is session-wide unique. A custom id can be assigned by using the `Widget#setData(String, Object)` method and using this constant for the `key` argument and a string that denotes the new id as the `data` argument. In addition the system property denoted by `ENABLE_UI_TESTS` must be set to `true`.

  The `id` must only contain characters that are valid according to the W3C recommendation for id and name attributes.

  It is the clients' responsibility to choose a unique id. Assigning an id that is used by another widget will lead to indeterministic behavior.

  The following code would assign the id 'myId' to the widget:

         Widget widget = new ...
         widget.setData( WidgetUtil.CUSTOM_WIDGET_ID, "myId" );

  Since:
    1.1
  See Also:
    `Widget.setData(String,Object)`, `getId(Widget)`, `ENABLE_UI_TESTS`, Constant Field Values

### ENABLE_UI_TESTS

    public static final String ENABLE_UI_TESTS

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

  If a system property with this name is set to `true`, the UI testing support is activated. For all widgets that are rendered to the client, the HTML id attribute is set.

  In conjunction with `CUSTOM_WIDGET_ID`, each widget can be assigned a custom, more human-readable, identifier that is independant if the order in which widgets are created.

  Since:
    1.1
  See Also:
    `CUSTOM_WIDGET_ID`, Constant Field Values

Method Detail

### getAdapter

    public static IWidgetAdapter getAdapter(Widget widget)

  Returns the according `IWidgetAdapter` for a specified widget.

  Parameters:
    `widget` - the widget
  Returns:
    the `IWidgetAdapter` instance

### getId

    public static 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 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,
                              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 Rich Ajax Platform Release 1.3

Copyright (c) Innoopract Informationssysteme GmbH and others 2002, 2011. All rights reserved.