Class RWT
- java.lang.Object
-
- org.eclipse.rap.rwt.RWT
-
public final class RWT extends java.lang.Object
This class provides access to those parts of RWT which are not covered by the SWT API. For example, it provides access to the current UI session and the request.- Since:
- 2.0
- See Also:
UISession
,ApplicationContext
,ResourceManager
,HttpServletRequest
,HttpServletResponse
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RWT.NLS
This utility class helps to provide a similar approach for compile safe native language support thanNLS
does.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ACTIVE_KEYS
The property to use inDisplay.setData()
in order to activate global key events for certain key sequences.static java.lang.String
BADGE
Controls the text shown as a badge.static java.lang.String
CANCEL_KEYS
The property to use inDisplay.setData()
in order to always cancel the client's default operation associated with certain key sequences.static int
CELL
Used as as detail information on a selection event to indicate that a selectable template cell was selected instead of the widget that contains the cell.static java.lang.String
CUSTOM_ITEM_HEIGHT
The property to use inControl.setData()
in order to set a custom item height.static java.lang.String
CUSTOM_VARIANT
Used to mark a widget as belonging to a custom variant in order to apply a different theming to it.static java.lang.String
DEFAULT_THEME_ID
The ID of the default theme.static java.lang.String
FIXED_COLUMNS
Controls the number of fixed columns.static int
HYPERLINK
Used as detail information on a selection event to indicate that a hyperlink (anchor tag) in a markup text was selected instead of the widget that contains the markup.static java.lang.String
MARKUP_ENABLED
Controls whether the use of markup in text is enabled.static java.lang.String
MNEMONIC_ACTIVATOR
The property to use inDisplay.setData()
in order to set the key combination for mnemonics activation.static java.lang.String
PRELOADED_ITEMS
Controls the number of preloaded items outside (above and below) visible area of virtualTree
orTable
.static java.lang.String
ROW_TEMPLATE
Used to apply a row template to a control.static java.lang.String
TOOLTIP_MARKUP_ENABLED
Controls whether the use of markup in tooltip text is enabled.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ApplicationContext
getApplicationContext()
Returns theApplicationContext
instance that represents the web context's global data storage area.static Client
getClient()
Returns a representation of the client that is connected with the server in the current UI session.static java.util.Locale
getLocale()
Returns the preferredLocale
for the current UI session.static HttpServletRequest
getRequest()
Returns theHttpServletRequest
that is currently processed.static ResourceManager
getResourceManager()
Returns the instance of the resource manager for the current application context.static HttpServletResponse
getResponse()
Returns theHttpServletResponse
that will be sent to the client after processing the current request.static ServiceManager
getServiceManager()
Returns the instance of the service manager for the current application context.static SettingStore
getSettingStore()
Returns the setting store instance for the current UI session.static UISession
getUISession()
Returns the current UI session.static UISession
getUISession(Display display)
Returns the UI session that is associated with the given display.static void
requestThreadExec(java.lang.Runnable runnable)
Executes the run method of the givenrunnable
on the request thread.static void
setLocale(java.util.Locale locale)
Sets the preferredLocale
for the current UI session.
-
-
-
Field Detail
-
ACTIVE_KEYS
public static final java.lang.String ACTIVE_KEYS
The property to use inDisplay.setData()
in order to activate global key events for certain key sequences. The value for this property has to be an array of Strings, each representing a key sequence. When this property is set on the display, the client will be instructed to issue events for the given key sequences. These key events can be captured usingDisplay.addFilter()
.The property can also be used in
Control.setData()
. In this case, a key listener that is attached to that control will only receive events for the specified key sequences. Control without active keys set will issue events for all key strokes.Valid strings for key sequences consist of one key and any number of modifier keys, separated by
+
. Keys can be identified by their upper case character or by any of the keywords below. Special characters (not a letter or digit) should not be combined with any modifiers, and will issue events regardless of pressed modifiers.The following keywords can be used to refer to special keys:
Examples:BACKSPACE
,TAB
,RETURN
,ENTER
,ESCAPE
,SPACE
,PAGE_UP
,PAGE_DOWN
,END
,HOME
,ARROW_LEFT
,ARROW_UP
,ARROW_RIGHT
,ARROW_DOWN
,INSERT
,DELETE
,F1
,F2
,F3
,F4
,F5
,F6
,F7
,F8
,F9
,F10
,F11
,F12
, Valid modifier keys areSHIFT
,ALT
, andCTRL
."A"
,"#"
,"F12"
,"CTRL+1"
,"ALT+ARROW_DOWN"
,"ALT+SHIFT+X"
.Example code for implementing a key binding:
display.setData( RWT.ACTIVE_KEYS, new String[] { "CTRL+1", "CTRL+2" } ); display.addFilter( SWT.KeyDown, new Listener() { public void handleEvent( Event event ) { boolean ctrlPressed = ( event.stateMask & SWT.Ctrl ) != 0; if( ctrlPressed && event.character == '1' ) { // handle Ctrl+1 } } } );
-
CANCEL_KEYS
public static final java.lang.String CANCEL_KEYS
The property to use inDisplay.setData()
in order to always cancel the client's default operation associated with certain key sequences. It allows the same values asACTIVE_KEYS
. If a key sequences is given inCANCEL_KEYS
as well as inACTIVE_KEYS
, it will cancel its default operation, but still issue the event.The property can also be used in
Control.setData()
. In this case, the associated default operation will only be cancelled if the control is focused.Depending on the client, there may be certain keys that cannot be cancelled.
-
MNEMONIC_ACTIVATOR
public static final java.lang.String MNEMONIC_ACTIVATOR
The property to use inDisplay.setData()
in order to set the key combination for mnemonics activation. The value for this property has to be a String.Valid string for key sequence consist of any number of modifier keys, separated by
+
.Mnemonics are currently supported by
MenuItem
,Button
,Label
,CLabel
,Group
,ToolItem
,TabItem
andCTabItem
. Mnemonics are not supported on a widgets with enabled markup.Example code:
display.setData( RWT.MNEMONIC_ACTIVATOR, "ALT+CTRL" );
- Since:
- 2.1
- See Also:
Display.setData(String,Object)
, Constant Field Values
-
CUSTOM_ITEM_HEIGHT
public static final java.lang.String CUSTOM_ITEM_HEIGHT
The property to use inControl.setData()
in order to set a custom item height. The custom item height must be specified as anInteger
and passed tosetData()
with this constant as the key.For example:
table.setData( RWT.CUSTOM_ITEM_HEIGHT, Integer.valueOf( 45 ) );
Used By:
Table
Tree
List
-
PRELOADED_ITEMS
public static final java.lang.String PRELOADED_ITEMS
Controls the number of preloaded items outside (above and below) visible area of virtualTree
orTable
. The preloaded items must be specified as anInteger
and passed tosetData()
with this constant as the key.For example:
table.setData( RWT.PRELOADED_ITEMS, Integer.valueOf( 10 ) );
Used By:
Table
Tree
- Since:
- 2.2
- See Also:
Control.setData(String,Object)
, Constant Field Values
-
MARKUP_ENABLED
public static final java.lang.String MARKUP_ENABLED
Controls whether the use of markup in text is enabled. To enable markup in text, this constant must be passed tosetData()
with a value ofBoolean.TRUE
. The call tosetData()
must be placed directly after the control is created. Once the markup in text is enabled it's not possible to disable it.For example:
Table table = new Table( parent, SWT.NONE ); table.setData( RWT.MARKUP_ENABLED, Boolean.TRUE );
When markup is enabled, certain XHTML tags can be used in the text property of the respective widget. Specifying an unsupported element will lead to an
IllegalArgumentException
when setting the text. The following table lists the currently supported tags:- <b>text</b>
- renders its content in bold font style
- <i>text</i>
- renders its content in italic font style
- <br/>
- inserts a line break
- <sub>
- renders its content as subscript
- <sup>
- renders its content as superscript
- <big>
- renders its content with bigger font size
- <small>
- renders its content with smaller font size
- <del>
- renders its content as deleted text
- <ins>
- renders its content as inserted text
- <em>
- renders its content as emphasized text
- <strong>
- renders its content as strong emphasized text
- <dfn>
- renders its content as instance definition
- <code>
- renders its content as computer code fragment
- <samp>
- renders its content as sample program output
- <kbd>
- renders its content as text to be entered by the user
- <var>
- renders its content as instance of a variable or program argument
- <cite>
- renders its content as citation
- <q>
- renders its content as short inline quotation
- <abbr>
- renders its content as abbreviation
- <span>
- generic style container
- <img>
- renders an image
- <a>
- renders a hyperlink
style
attribute.Used By:
Table
Tree
Grid
List
Label
CLabel
ToolTip
Button
-
TOOLTIP_MARKUP_ENABLED
public static final java.lang.String TOOLTIP_MARKUP_ENABLED
Controls whether the use of markup in tooltip text is enabled. To enable markup in tooltip text, this constant must be passed tosetData()
with a value ofBoolean.TRUE
. The call tosetData()
must be placed directly after the control is created. Once, the markup in tooltip text is enabled it's not possible to disable it.- Since:
- 2.2
- See Also:
Control.setData(String,Object)
,MARKUP_ENABLED
, Constant Field Values
-
FIXED_COLUMNS
public static final java.lang.String FIXED_COLUMNS
Controls the number of fixed columns. This constant must be passed tosetData()
together with anInteger
object. The given number of columns, starting with the current leftmost one, will not scroll horizontally. The call tosetData()
must be placed directly after the control is created.For example:
Used By:Table table = new Table( parent, SWT.NONE ); table.setData( RWT.FIXED_COLUMNS, Integer.valueOf( 2 ) );
Table
Tree
-
BADGE
public static final java.lang.String BADGE
Controls the text shown as a badge. This constant must be passed tosetData()
together with anString
object.For example:
Used By:TabItem item = new TabItem( folder, SWT.NONE ); item.setData( RWT.BADGE, "23" );
TabItem
- Since:
- 3.0
- See Also:
Control.setData(String,Object)
, Constant Field Values
-
DEFAULT_THEME_ID
public static final java.lang.String DEFAULT_THEME_ID
The ID of the default theme. The default theme is the active theme if no custom theme has been specified. This ID can be used to register theme contributions to the default theme.
-
CUSTOM_VARIANT
public static final java.lang.String CUSTOM_VARIANT
Used to mark a widget as belonging to a custom variant in order to apply a different theming to it. A custom variant can be applied to any widget like this:button.setData( RWT.CUSTOM_VARIANT, "mybutton" );
For more information on custom variants, see the RAP help on theming.- Since:
- 2.0
- See Also:
Widget.setData(String,Object)
, Constant Field Values
-
ROW_TEMPLATE
public static final java.lang.String ROW_TEMPLATE
Used to apply a row template to a control. Row templates replace the column layout model of a Tree or a Table with a custom presentation defined by an instance ofTemplate
. A template cell will display the content of an item's column when its bindingIndex is set to the corresponding column index.To apply a row template on a control, use the control's
setData()
method with this constant as key:Template template = new Template(); // add cells to this template new TextCell(template).setBindingIndex(0).setTop(10).setLeft(20) ...; ... Table table = new Table(parent, SWT.FULL_SELECTION); // Add as many columns as needed to add multiple texts/images to items new TableColumn(); ... table.setData(RWT.ROW_TEMPLATE, template);
The call to
setData()
must be placed directly after the control's creation. Once a template is applied to a control, the control will not be affected by changes to the template.Note that TableColumn/TreeColumn instances must be created in order to support multiple item texts/images. If the
SWT.FULL_SELECTION
style flag is not set, no selection will be displayed.Supported by:
Table
Tree
Grid
- Since:
- 2.2
- See Also:
Control.setData(String,Object)
,Template
, Constant Field Values
-
HYPERLINK
public static final int HYPERLINK
Used as detail information on a selection event to indicate that a hyperlink (anchor tag) in a markup text was selected instead of the widget that contains the markup. To enable selection events on markup hyperlinks, thea
element must have it'starget
property set to “_rwt
”.Supported by:
Table
Tree
Grid
List
- Since:
- 2.1
- See Also:
MARKUP_ENABLED
,SelectionEvent.detail
, Constant Field Values
-
CELL
public static final int CELL
Used as as detail information on a selection event to indicate that a selectable template cell was selected instead of the widget that contains the cell.- Since:
- 2.2
- See Also:
Cell.setSelectable(boolean)
,SelectionEvent.detail
, Constant Field Values
-
-
Method Detail
-
getResourceManager
public static ResourceManager getResourceManager()
Returns the instance of the resource manager for the current application context. This is a shortcut forRWT.getApplicationContext().getResourceManager()
.- Returns:
- the resource manager for the current application context
- See Also:
ApplicationContext.getResourceManager()
-
getServiceManager
public static ServiceManager getServiceManager()
Returns the instance of the service manager for the current application context. This is a shortcut forRWT.getApplicationContext().getServiceManager()
.- Returns:
- the service manager instance for the current application context
- See Also:
ApplicationContext.getServiceManager()
-
getSettingStore
public static SettingStore getSettingStore()
Returns the setting store instance for the current UI session. The setting store is a persistent store for user-specific data.- Returns:
- the setting store for the current session, never
null
-
getUISession
public static UISession getUISession()
Returns the current UI session. This method must be executed from the UI thread.- Returns:
- the current UI session instance, never
null
- Throws:
java.lang.IllegalStateException
- when called outside of the UI thread
-
getUISession
public static UISession getUISession(Display display)
Returns the UI session that is associated with the given display.- Returns:
- the UI session instance for the given display, never
null
-
getApplicationContext
public static ApplicationContext getApplicationContext()
Returns theApplicationContext
instance that represents the web context's global data storage area.- Returns:
- instance of
ApplicationContext
-
getRequest
public static HttpServletRequest getRequest()
Returns theHttpServletRequest
that is currently processed.Note: This method is not recommended. Typical application code should not need to call this method. Processing requests from the client is up to the framework. In rare cases, an application may be wish to access request details such as certain HTTP headers.
- Returns:
- the currently processed request
-
getResponse
public static HttpServletResponse getResponse()
Returns theHttpServletResponse
that will be sent to the client after processing the current request.Note: This method is not recommended. Typical application code should not need to call this method. The response should only be written and modified by the framework. In rare cases, an application may wish to access the response, e.g. to add a Cookie.
- Returns:
- the response object that will be sent to the client
-
getLocale
public static java.util.Locale getLocale()
Returns the preferredLocale
for the current UI session. This method is a shortcut forRWT.getUISession().getLocale()
.- Returns:
- the preferred
Locale
for the current UI session. - See Also:
UISession.getLocale()
-
setLocale
public static void setLocale(java.util.Locale locale)
Sets the preferredLocale
for the current UI session. This method is a shortcut forRWT.getUISession().setLocale( locale )
.- Parameters:
locale
- the locale to set, ornull
to reset- See Also:
UISession.setLocale(Locale)
-
requestThreadExec
public static void requestThreadExec(java.lang.Runnable runnable)
Executes the run method of the givenrunnable
on the request thread. This method may only be called from the UI thread.NOTE: This API is provisional and may change without further notice.
- Parameters:
runnable
- the code to be executed on the request thread- Throws:
java.lang.IllegalStateException
- when called from a non-UI thread
-
getClient
public static Client getClient()
Returns a representation of the client that is connected with the server in the current UI session. This is a shortcut forRWT.getUISession().getClient()
.- Returns:
- The client for the current UI session
- Throws:
java.lang.IllegalStateException
- when called outside of the request context
-
-