Class MultipleSelectionCombo<T>

All Implemented Interfaces:
Drawable

public class MultipleSelectionCombo<T> extends Composite
Combo-type widget that allows selecting multiple items.

Takes a list of Objects as input.

The toString() of each Object is displayed in a drop-down list. Overriding the stringRepresention() method, the user can define an alternative way to convert T to String.

One or more items can be selected, they're also displayed in the text field.

Items can be entered in the text field, comma-separated. If entered text does not match a valid item, text is highlighted and tool-tip indicates error.

Keyboard support: 'Down' key in text field opens drop-down. Inside drop-down, single item can be selected via cursor key and 'RETURN' closes the drop-down. TODO Auto-completion while typing?

  • Constructor Details

    • MultipleSelectionCombo

      public MultipleSelectionCombo(Composite parent, int style)
  • Method Details

    • setForeground

      public void setForeground(Color color)
      Overrides:
      setForeground in class Control
    • setToolTipText

      public void setToolTipText(String tooltip)
      Overrides:
      setToolTipText in class Control
    • setItems

      public void setItems(List<T> items)
      Define items to be displayed in the list, and returned as the current selection when selected.
    • getItems

      public List<T> getItems()
      Get the list of items
      Returns:
      list of selectable items
    • setSelection

      public void setSelection(List<T> selection)
      Set items that should be selected.

      Selected items must be on the list of items provided via setItems

    • setSelection

      public void setSelection(String selection)
      set the items to be selected, the selection is specified as a string with values separated by MultipleSelectionCombo.SEPARATOR
      Parameters:
      selection - Items to select in the list as comma-separated string
    • setSelection

      public void setSelection(String[] selections)
      Set the items to be selected
    • getSelection

      public List<T> getSelection()
      get the list of items currently selected. Note: this does not return the list in the order of selection.
      Returns:
      the list of selected items
    • addPropertyChangeListener

      public void addPropertyChangeListener(PropertyChangeListener listener)
      Register a PropertyChangeListener on this widget. the listener will be notified when the items or the selection is changed.
      Parameters:
      listener -
    • removePropertyChangeListener

      public void removePropertyChangeListener(PropertyChangeListener listener)
      remove the PropertyChangeListner
      Parameters:
      listener -
    • stringRepresention

      public String stringRepresention(T object)
      Override this method to define the how the object should be represented as a string.
      Parameters:
      object -
      Returns:
      the string representation of the object