Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: for the plan.

Jump to: navigation, search

Nebula TextAssist

< Back to Nebula Main Page



This widget is very similar to the Text widget. It has the same look, the same methods, the same behaviour. The difference appears when one types something: some proposals are displayed under the widget (like the code assist function in Eclipse).


There is a big difference with other SWT widget : there is no constructor TextAssist(Composite parent, int style).

The only constructor available is public TextAssist(final Composite parent, final int style, final TextAssistContentProvider contentProvider) where

  • parent is the composite control which will be the parent of the new instance (cannot be null)
  • style is the style of the control (see the style availables for Text widget)
  • contentProvider is your content provider (see below)

Number of proposal

You can change the maximum number of displayed proposals (default value is 10) with the method public void setNumberOfLines(final int numberOfLines).

Single Click to select en entry

By default, the use can select an entry by pressing ENTER or by double-click on the entry.

If you want to select an entry with a single click, use the method setUseSingleClick(true);.

Content provider

A content provider is an object that returns a list of proposals depending of what the user typed. It has to extend the class org.eclipse.nebula.widgets.opal.textassist.TextAssistContentProvider and extends the method public abstract List<String> getContent(final String entry).

The entry is a string that contains what the user typed. This string is never null. The result is a list of strings that match the entry. This list can be empty or null. In this case, no choice is proposed to the user.

If the size is bigger than the maximum number of proposals (set in the widget, default value:10), the list is truncated. To get the max number of proposals, you can use the method getMaxNumberOfLines().

final TextAssistContentProvider contentProvider = new TextAssistContentProvider() {
    private final String[] EUROZONE = new String[] { "Austria", "Belgium", "Cyprus", 
         "Estonia", "Finland", "France", "Germany", "Greece", "Ireland", "Italy", 
         "Luxembourg", "Malta", "Netherlands", "Portugal", "Slovakia", "Slovenia", "Spain" };

    public List<String> getContent(final String entry) {
         final List<String> returnedList = new ArrayList<String>();
         for (final String country : this.EUROZONE) {
              if (country.toLowerCase().startsWith(entry.toLowerCase())) {
         return returnedList;


An example called is available in the plug-in org.eclipse.nebula.widgets.opal.textassist.snippets.

This example is also available here :

Back to the top