Eclipse 4.5 (Mars) - New and Noteworthy in SWT

Milestone M3

The DateTime widget now uses GtkSpinButton on UNIX/Linux platforms The DateTime widget has been re-implemented to use the GtkSpinButton widget for SWT.DATE and SWT.TIME styles. The new look and feel is as illustrated below:

GTK+ 2:

GTK+ 3:

New monitoring events added in place of SWT.Sleep and SWT.Wakeup The SWT.Sleep and SWT.Wakeup events have been deprecated in favor of the more generic events SWT.PreExternalEventDispatch and SWT.PostExternalEventDispatch, respectively. Clients that were written using the old event names should be updated to refer to the new events.
Dropped support for GTK+ 2 versions older than 2.18 GTK+ 2.18.0 or later (and its dependencies) will be the pre-requisites necessary to run Eclipse successfully on all Linux/UNIX platforms as opposed to GTK+ 2.10.0 earlier. Support for all versions older than 2.18 has been dropped effective Mars M3 milestone release.

Note: As of now, Eclipse logs a warning and continues to run when a GTK+ version older than 2.18.0 is detected, but that behavior will soon be changed to not run Eclipse with unsupported versions.

Milestone M4

Milestone M5

Transparent background for Control

SWT has added support to set a Control's background as transparent. The Color class now supports specifying a alpha value (integer: 0 to 255) for transparency. Calling Control#setBackground(Color color) with a transparent color (color with alpha value '0'), sets the control's background as transparent.

List of New Classes and APIs:

  • Class: org.eclipse.swt.graphics.RGBA
  • Constant: SWT.COLOR_TRANSPARENT - This is a default transparent color
  • Methods added in org.eclipse.swt.graphics.Color
    • public Color (Device device, int red, int green, int blue, int alpha)
    • public Color (Device device, RGB rgb, int alpha)
    • public Color (Device device, RGBA rgba)
    • public RGBA getRGBA ()
    • public int getAlpha ()

Note:

  • Currently, SWT honors only extreme values for alpha i.e, '0'(transparent) or '255'(opaque).
  • Setting transparent background color fails for some controls on all platforms, they show the default background color instead. For e.g. Text, Combo.
  • Setting transparent background color for some controls works on GTK3 only, it fails on other platforms. For e.g. Table, Tree.
For an example on using the new APIs, see Snippet365.

Snippet365 in action (Controls with SWT.COLOR_TRANSPARENT background and Shell with gradient background image)

Transparent Background on Control widgets

SWT Tools SWT Tools are now available in the Eclipse Platform P2 repository. SWT Tools provides tools for developing SWT itself (JNIGen) but also general purpose tools Sleak (monitors the creation and disposal of SWT graphics resources) and SWT Spy (prints out information like style, layout and parent about the widget under the cursor).

Milestone M6

APIs for high-DPI monitor support New APIs have been added to provide support for rendering high-resolution images on high-DPI monitors.

Two constructors have been added to the Image class. They accept image-provider callbacks that allow clients to supply resolution-dependent versions of images:

public interface ImageDataProvider {
			public ImageData getImageData (int zoom);
		}
		public interface ImageFileNameProvider {
			public String getImagePath (int zoom);
		}

Depending on the user's monitor configuration, SWT will request images with the corresponding zoom level. Here's an example that displays 3 original images, followed by variants whose resolution changes depending your monitor's resolution: Snippet367.java.

Note that this is just the first step to support high-resolution images in SWT and Eclipse-based applications. Work is underway to adopt the new APIs in the platform. Futhermore, more work in SWT is required to properly support drawing into high-resolution images via GC.

API to choose security context in Browser#evaluate() A new API Browser#evaluate(String script, boolean trusted) has been added that allows the client to run Javascript code in the Chrome security context or in the normal security context for SWT.MOZILLA style browsers.

Milestone M7

SWT Browser now supports XULRunner 31.x An SWT Browser created with style SWT.MOZILLA can now be used with the XULRunner 31.x runtime on Windows and Mac OSX.

Note: XULRunner 31 support is not available on Linux for Mars release. For details, please see Bug 467646.

Release Candidate 1

BIDI: SWT Controls now support AUTO text direction The auto (a.k.a. "contextual") text direction implies that the base text direction is derived from the direction of the first strong (either LTR or RTL) bidi character. Auto text direction is the most appropriate choice when the text content is not known in advance and, hence, it is not yet possible to decide which base direction value, LTR or RTL, would be most suitable at run time.
Support for auto text direction has been introduced at the SWT Control level. Auto text direction can be applied through the existing Control#setTextDirection API. The new value for auto direction is expressed as the bitwise disjunction of (SWT#LEFT_TO_RIGHT | SWT#RIGHT_TO_LEFT) bit fields. When applied onto a Composite control, the auto base direction (similarly to LTR and RTL ones) is inherited by the child components.
For example:
  • org.eclipse.swt.widgets.Table.setTextDirection(SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT);
Result:

Note: Auto text direction is not yet supported:
  • in StyledText
  • upon Control creation (but only through Control#setTextDirection call once the Control has been created)