blob: 62f7f2dc93baeaf2044acc41b38f3ebb990e1fd7 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="copyright" content="Copyright (c) 2012, 2020 EclipseSource. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page."/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Differences between RWT and SWT</title>
<link rel="stylesheet" href="../../../PRODUCT_PLUGIN/book.css" type="text/css"/>
</head>
<body>
<h1>Differences between RWT and SWT</h1>
<h2>Introduction to the RAP Widget Toolkit</h2>
<p>
At the core of RAP operates the RAP Widget Toolkit (RWT), which largely implements the same
API as the Standard Widget Toolkit (SWT). That is why many projects that build upon SWT
(like <a href="http://wiki.eclipse.org/index.php/JFace">JFace</a>)
can run on RWT with little or no modifications. It can
also be used <a href="application-setup.html#workbench">with or without the Eclipse 3.x
workbench layer</a>.
</p>
<p>
Note that <q>RWT</q> refers only to this widget toolkit, while <q>RAP</q> refers to the
project in its entirety, including its ports of JFace, Workbench and Forms, OSGI
integration, add-ons, Branding and Interaction Design API, tooling, demos and custom themes.
</p>
<p>
RWT implements most (40+) <a href="http://www.eclipse.org/swt/widgets/">
SWT Widgets</a>, including their events and layout manager. It also supports SWT-like
key and mouse event handling, drag and drop and painting (on <em>Canvas</em>).
If you are not already familiar with SWT, we recommend to first learn the SWT basics
(almost all valid for RWT) by reading the official documentation
and <a href="http://www.eclipse.org/swt/snippets/">snippets</a> provided by the
<a href="http://www.eclipse.org/swt/">SWT project homepage</a>.
A full reference specific to RWT can be found
<a href="../reference/api/overview-summary.html">here</a>.
</p>
<h2>Compatibility to SWT</h2>
<p>
RAP generally follows the rule <q>If it compiles, it works</q>. That means that all SWT API
implemented in RWT is working <i>within the requirements set by SWT</i>.
If an SWT feature is not implemented, the corresponding API is also missing.
If this is the case, it is likely because it's hard or impossible to implement in RWT.
In some cases, SWT classes and methods are implemented as empty stubs to enable single-sourcing,
but only where this is a valid according of the SWT documentation of the API.
Examples are the accessibility API and some SWT constants that are marked as <em>HINT</em>.
</p>
<p id="setdata">
SWT was developed for desktop applications, but RWT is used to build web applications.
For this reason, there are some features that SWT supports that RWT does not,
while RWT adds some features that are tailored to the specific requirements of web
application development.
However, RWT does not add any new API to the classes adopted from SWT.
All RWT-specific features are accessible by API in the namespace
<em><a href="../reference/api/index.html">org.eclipse.rap.rwt</a></em>.
Many are activated using a
widget's
<em><a href="../reference/api/org/eclipse/swt/widgets/Widget.html#setData-java.lang.String-java.lang.Object-">setData</a></em>
method with a constant from the
<em><a href="../reference/api/org/eclipse/rap/rwt/RWT.html">RWT</a></em>
class as the
key. Example:
</p>
<pre class="lang-java">table.setData( RWT.MARKUP_ENABLED, Boolean.TRUE )</pre>
<p>
Other additional features may be accessed via <a href="client.html#service">client services</a>.
</p>
<h2>Notable Additional Features</h2>
<ul>
<li id="client" style="margin-bottom:10px">
<b>Client Class and Client Services</b>
<br/>
All features specific to the <a href="client.html">RAP client</a> (which is exchangeable)
are handled by the client class and the client services.
This includes support for browser history, JavaScript execution and retrieving the clients
time zone offset.
The <code>Client</code> interface and client services are documented in more detail
<a href="client.html">here</a>.
</li>
<li style="margin-bottom:10px">
<b>HTTP File Upload</b>
<br/>
Unlike SWT, RWT can not simply access the user's file system and read data from it.
Therefore RAP provides several ways to upload files within the RAP application. Read more
about it <a href="file-upload.html">here</a>.
</li>
<li style="margin-bottom:10px">
<b>Markup in Widgets</b>
<br/>
Several widgets in RWT support a subset of HTML in their text property.
Detailed information can be found <a href="markup.html">here</a>.
</li>
<li style="margin-bottom:10px">
<b>Tree and Table Enhancements</b>
<br/>
The RWT Tree and Table widgets provide a number of features not found in SWT.
This includes the possibility to exclude some columns from scrolling,
pre-caching of items, as well as support for templates, markup and advanced theming.
Find out more about it <a href="tree-table.html">here</a>.
</li>
<li style="margin-bottom:10px">
<b>DropDown Widget</b>
<br/>
The
<em><a href="../reference/api/org/eclipse/rap/rwt/widgets/DropDown.html">DropDown</a></em>
widget enables simple and efficient input assist for text fields.
It is basically a pop-up list that can be attached to any <em>Text</em> widget.
It behaves very similar to <em>Combo</em>, but does not automatically change the content of
the widget it is attached to.
Instead it fires selection events that may be used to modify the value of the Text widget
programatically. <br/>
<i>A ready-to-use, enhanced auto-complete solution for text fields can be found in the
<a href="https://eclipse.org/rap/incubator/">RAP Incubator</a>.
The component is called
<em><a href="http://wiki.eclipse.org/RAP/Incubator/DropDown#AutoSuggest">AutoSuggest</a></em>
and uses the DropDown widget internally.</i>
</li>
<li style="margin-bottom:10px">
<b>Theming</b>
<br/>
In SWT, the default visual representation of an widget is determined by the operating
system. In RAP this is done by the
<a href="theming.html">theming</a>
which can be adjusted by the developer using CSS.
</li>
<li style="margin-bottom:10px">
<b>Multi-User Environment</b><br/>
RAP operates in a multi-user environment and provides some additional API that helps
dealing with the consequences.
An detailed introduction can be found <a href="scopes.html">here</a>.
</li>
<li style="margin-bottom:10px">
<b>Scripting</b><br/>
Since the RAP WebClient is JavaScript based you can also write event listeners in JavaScript
instead of Java. This may be used to implement features that require instantaneous user
feedback or rely heavily on key events. Read more about it in the
<a href="scripting.html">Scripting</a> section.
</li>
</ul>
<h2>Notable Limitations</h2>
<ul>
<li style="margin-bottom:10px">
<b>Unimplemented Features</b>
<br/>
While the API for touch event handling and accessibility configuration is present in RWT,
it does not natively support either. This is a valid implementation according to the SWT
documentation. Accessibility in RAP may be achieved by
<a href="scripting.html#html">adding ARIA attributes</a> though.
</li>
<li style="margin-bottom:10px">
<b>Unimplemented Widgets:</b>
<em>StyledText</em>, <em>Tracker</em>, <em>TaskBar</em>, <em>Tray</em>
<br/>
These widgets are currently not available in RWT. If you require a rich text editor in RAP,
take a look in the RAP Incubator and Wiki.
</li>
<li style="margin-bottom:10px">
<b>Painting Limitations</b><br/>
SWT can paint on any widget or image using a
<em><a href="../reference/api/org/eclipse/swt/graphics/GC.html">GC</a></em>,
while RAP only allows painting on the
<em><a href="../reference/api/org/eclipse/swt/widgets/Canvas.html">Canvas</a></em>
widget.
In some cases the
<em><a href="../reference/api/org/eclipse/swt/graphics/GC.html#drawText-java.lang.String-int-int-">drawText</a></em>,
<em><a href="../reference/api/org/eclipse/swt/graphics/GC.html#drawString-java.lang.String-int-int-">drawString</a></em>
and
<em><a href="../reference/api/org/eclipse/swt/graphics/GC.html#drawImage-org.eclipse.swt.graphics.Image-int-int-">drawImage</a></em>
methods may disregard the drawing order and overlap elements that are drawn later.
Some methods are unimplemented, including <em>copyArea</em>,
<em>setClipping</em>, <em>setTransform</em>, <em>setInterpolation</em>,
<em>setLineDash</em> and <em>setXORMode</em>.
Performance and results of a drawing operations can differ depending on the browser.
It is possible to use the native HTML5 Canvas directly instead of the SWT GC using RWT
Scripting.
See also <q><a href="custom-widget.html#selfdrawing">Self-Drawing custom widgets</a></q>.
</li>
<li id="dialog" style="margin-bottom:10px">
<b>Limitations in Dialogs:</b>
<em><a href="../reference/api/org/eclipse/swt/widgets/Dialog.html">Dialog</a></em>,
<em><a href="../reference/api/org/eclipse/swt/widgets/ColorDialog.html">ColorDialog</a></em>,
<em><a href="../reference/api/org/eclipse/swt/widgets/FontDialog.html">FontDialog</a></em>,
<em><a href="../reference/api/org/eclipse/swt/widgets/MessageBox.html">MessageBox</a></em>
<br/>
When using the
<a href="application-setup.html#compat">JEE compatibility mode</a>,
opening a dialog does not block program execution.
To obtain their return value, a callback must be registered using the RWT-only
<a href="../reference/api/org/eclipse/swt/widgets/Dialog.html#open-org.eclipse.rap.rwt.widgets.DialogCallback-"><em>open(DialogCallback)</em></a> method.
</li>
<li id="browser" style="margin-bottom:10px">
<b>Limitations of the Browser widget</b>
<br/>
Since the
<em><a href="../reference/api/org/eclipse/swt/browser/Browser.html">Browser</a></em>
widget is based on the HTML <em>iframe</em> element, there are some restrictions.
Detailed information can be found <a href="web-embedding.html">here</a>.
Also, when using the
<a href="application-setup.html#compat">JEE compatibility mode</a>,
evaluating a script does not block program execution.
To obtain its return value, a callback must be registered using the RWT-only
<a href="../reference/api/org/eclipse/swt/browser/Browser.html#evaluate-java.lang.String-org.eclipse.rap.rwt.widgets.BrowserCallback-"><em>evaluate(String, BrowserCallback)</em></a> method.
</li>
<li style="margin-bottom:10px">
<b>Limitations in Mouse and Key Events</b>
<br/>
See <q><a href="key-and-mouse-events.html">Mouse and Key Event Handling in RAP</a></q>.
</li>
<li style="margin-bottom:10px">
<b id="verify">Limitations in Verify and Modify Events:</b>
<br/>
<em><a href="../reference/api/org/eclipse/swt/SWT.html#Modify">Modify</a></em>
and
<em><a href="../reference/api/org/eclipse/swt/SWT.html#Verify">Verify</a></em>
events are not fired instantaneously, but with a small delay, possibly
combining a number of changes into one event. Also, the values of the
<em><a href="../reference/api/org/eclipse/swt/events/VerifyEvent.html">VerifyEvent</a></em>
fields
<em><a href="../reference/api/org/eclipse/swt/events/VerifyEvent.html#text">text</a></em>,
<em><a href="../reference/api/org/eclipse/swt/events/VerifyEvent.html#start">start</a></em>
and
<em><a href="../reference/api/org/eclipse/swt/events/VerifyEvent.html#end">end</a></em>
currently always report the entire text to have changed.
However, when using a <a href="scripting.html">ClientListener</a> (written in JavaScript),
these limitations do not exist.
</li>
<li style="margin-bottom:10px">
<b>Limitations in Drag and Drop</b>
<br/>
In
<em><a href="../reference/api/org/eclipse/swt/dnd/DragSourceEvent.html">DragSourceEvent</a></em>,
the fields
<em><a href="../reference/api/org/eclipse/swt/dnd/DragSourceEvent.html#image">image</a></em>,
<em><a href="../reference/api/org/eclipse/swt/dnd/DragSourceEvent.html#offsetX">offsetX</a></em>
and
<em><a href="../reference/api/org/eclipse/swt/dnd/DragSourceEvent.html#offsetY">offsetY</a></em>
have no effect.
<em><a href="../reference/api/org/eclipse/swt/dnd/DropTargetEvent.html">DropTargetEvent</a></em>s
may be omitted while the mouse cursor is still in motion. When dragging files from the
clients OS (to drop on a drop target with <em>ClientFileTransfer</em>), feedback effects
are not renderd, operation types (move/copy/link) are ignored, and no <em>DragEnter</em> /
<em>DragOver</em> / <em>DragLeave</em> events are fired.
</li>
<li style="margin-bottom:10px">
<b>Limitations when using background threads</b>
<br/>
See articles <a href="threads.html">Session access from a background thread</a>
and <a href="server-push.html">Server Push</a>.
</li>
</ul>
</body>
</html>