What's New in Eclipse 4.14

Here are descriptions of some of the changes of interest to plug-in developers made to the Eclipse Platform and SWT for the 4.14 release of Eclipse.

New features oriented towards end-users of the platform can be viewed in the What's New section of the Workbench User Guide.

Platform Changes

Get TextViewer selection out of UI thread A new extension interface ITextViewerExtension9 was added to ITextViewer. This extension interface adds a new method getLastKnownSelection to get the text selection for the viewer, with constraint (by API contract) that this method can be called outside of the UI thread.

This method allows to build extensions (like completion proposal computers, hovers and others) that can work outside of the UI thread, as a separate job, without blocking the UI but that still require access to the text selection.

The TextViewer concrete implementation (used by most textual editors) has been enriched to implement this interface and provide associated method.

NOTE: Since selection can change in the UI thread while this method may be running in the non-UI thread, it can happen that the getLastKnownSelection method returns a selection that's no more up-to-date. Special care should be taken if having the very current selection is important in your code; but experience with adoption of this method in typical cases has shown that this is rarely the case, and that if your code needs to react to selection changes, using an ISelectionListener should be preferred.

Quick assist extension point for Generic Editor A new extension point org.eclipse.ui.genericeditor.quickAssistProcessors has been added to allow contributing to the quick assist in the generic editor.

The following example shows how to contribute to the Generic Editor's quick assist:

<extension point="org.eclipse.ui.genericeditor.quickAssistProcessors">
    <quickAssistProcessor
        class="org.eclipse.ui.genericeditor.tests.contributions.MockQuickAssistProcessor"
        contentType="org.eclipse.ui.genericeditor.tests.content-type">
    </quickAssistProcessor>
</extension>
The contributing extension must provide a class which implements org.eclipse.jface.text.quickassist.IQuickAssistProcessor.
Easier usage of DisplayHelper The org.eclipse.ui.tests.harness.util.DisplayHelper that's often conveniently used in tests to automate wait on asynchronous UI results now offers a more concise syntax, relying on the new static waitForCondition(display, timeout, condition) method.

Former constructs like:

assertTrue(new DisplayHelper() {
    @Override
    public void condition() {
        return some.boolean() && expression;
    }
}.waitForCondition(display, 1000));
can now be replaced by:
assertTrue(DisplayHelper.waitForCondition(display, 1000, () -> some.boolean() && expression))
Selection Listener Factory A new API was introduced to make participants of the Selection framework more efficient.

Selection listeners are notified of all selections in the Workbench. This means that the listener is always required to filter unwanted selections. In addition, the listener has to make sure not to waste cycles in the UI thread, for instance, not update the UI while it is invisible.

This filtering generally requires a lot of boilerplate code while, ideally, you only want to receive selections that are of interest.

This factory takes care of many practical filtering scenarios by allowing the creation of an intermediate selection service that only calls you back with selections you can work with.

See usage examples in the SelectionListenerFactory documentation.

Update the Icon of a Part at Runtime You can now update the icon of a Part in a Part Stack by setting its icon URI at any time. There is no need to modify the part's transient data anymore.

SWT Changes

Disabled Toolbar items on GTK ToolItem.setDisabledImage() is now fully implemented for ToolItems on Linux/GTK, and greatly improves the ability to distinguish a disabled ToolItem from an enabled one.

Below is a screenshot with disabled toolbar buttons; the left toolbar shows the current implementation, the right one the shows the old implementation.

ToolBar comparison

This API is already works on Windows and macOS.

SVG Image API added, implemented on GTK SWT now has an API to support SVG images, SWT.IMAGE_SVG, which allows ImageLoader to load them.

Currently this functionality is only implemented on Linux/GTK, on all other platforms the API is a HINT.

Set alignment for CCombo The CCombo widget can now align the text field content, the alignment is not applied to the drop-down list.

The alignment for CCombo can be specified as a style bit in the constructor or using the CCombo.setAlignment() method. You can also get the value of the CCombo's alignment using getAlignment() method.

The below screen-shot shows possible CCombo alignments:

Aligned CCombo widgets