java.lang.Object
org.eclipse.swt.widgets.Widget
org.eclipse.swt.widgets.Control
org.eclipse.swt.widgets.Scrollable
org.eclipse.swt.widgets.Composite
org.eclipse.nebula.widgets.nattable.widget.NatCombo
All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable
Direct Known Subclasses:
FilterNatCombo

public class NatCombo extends org.eclipse.swt.widgets.Composite
Customized combobox control that supports editing directly in the text field and selecting items from the dropdown.

This control supports the ability for multi select in the dropdown of the combo which is not available for the SWT Combo control. This feature was added with Nebula NatTable 1.0.0

The following style bits are supported by this control.

See Also:
  • (if a border should be added to the Text control)
  • (default for Text control, if this is missing, the Text control can be edited)
  • (if the items in the combo should be showed with checkboxes)
  • (if multi selection is allowed)
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    class 
    ModifyListener that is added to the dropdown filter to trigger actions on filtering the dropdown content.
    class 
    FocusListener that is used to ensure that the Text control and the dropdown table control are sharing the same focus.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final IStyle
    The IStyle that is used for rendering the Text and the combo control.
    static final String
    Default String that is used to prefix the generated String representation showed in the text control if multiselect is supported.
    static final String
    String that is used to suffix the generated String representation showed in the text control if multiselect is supported.
    static final String
    Default String that is used to separate values in the String representation showed in the text control if multiselect is supported.
    static final int
    The default number of visible items on open the combo.
    protected org.eclipse.swt.widgets.Shell
    The Shell containing the dropdown of this NatCombo
    protected org.eclipse.swt.widgets.Table
    The Table control used for the combo component of this NatCombo
    protected org.eclipse.jface.viewers.TableViewer
    The Table control used for the combo component of this NatCombo
    protected org.eclipse.swt.widgets.Text
    The text control allowing filtering of options
    protected boolean
    Flag that indicates whether this ComboBoxCellEditor supports free editing in the text control of the NatCombo or not.
    protected org.eclipse.swt.graphics.Image
    The image that is shown at the right edge of the text control if the NatCombo is opened.
    protected List<String>
    The items that are showed within the combo transformed to a java.util.List.
    protected boolean
    Flag to configure if a click on the item should update the checkbox state.
    protected int
    The maximum number of visible items of the combo.
    protected boolean
    Flag that indicates whether this NatCombo supports multiselect or not.
    protected String
    String that is used to prefix the generated String representation showed in the text control if multiselect is supported.
    protected String
    String that is used to suffix the generated String representation showed in the text control if multiselect is supported.
    protected String
    String that is used to separate values in the String representation showed in the text control if multiselect is supported.
    protected Map<String,Boolean>
    Map used to hold the selection state of items in the drop.
    protected boolean
    Flag that indicated whether this NatCombo supports filtering of the values in the dropdown control
    protected org.eclipse.swt.widgets.Text
    The text control of this NatCombo, allowing to enter values directly.
    protected boolean
    Flag that indicates whether checkboxes should be shown for the items in the dropdown.
    protected final int
    The style bits that where set on creation time.

    Fields inherited from class org.eclipse.swt.widgets.Control

    handle
  • Constructor Summary

    Constructors
    Constructor
    Description
    NatCombo(org.eclipse.swt.widgets.Composite parent, IStyle cellStyle, int style)
    Creates a new NatCombo using the given IStyle for rendering, showing the default number of items at once in the dropdown.
    NatCombo(org.eclipse.swt.widgets.Composite parent, IStyle cellStyle, int maxVisibleItems, int style)
    Creates a new NatCombo using the given IStyle for rendering, showing the given amount of items at once in the dropdown.
    NatCombo(org.eclipse.swt.widgets.Composite parent, IStyle cellStyle, int maxVisibleItems, int style, boolean showDropdownFilter)
    Creates a new NatCombo using the given IStyle for rendering, showing the given amount of items at once in the dropdown.
    NatCombo(org.eclipse.swt.widgets.Composite parent, IStyle cellStyle, int maxVisibleItems, int style, boolean showDropdownFilter, boolean linkItemAndCheckbox)
    Creates a new NatCombo using the given IStyle for rendering, showing the given amount of items at once in the dropdown.
    NatCombo(org.eclipse.swt.widgets.Composite parent, IStyle cellStyle, int maxVisibleItems, int style, org.eclipse.swt.graphics.Image iconImage)
    Creates a new NatCombo using the given IStyle for rendering, showing the given amount of items at once in the dropdown.
    NatCombo(org.eclipse.swt.widgets.Composite parent, IStyle cellStyle, int maxVisibleItems, int style, org.eclipse.swt.graphics.Image iconImage, boolean showDropdownFilter)
    Creates a new NatCombo using the given IStyle for rendering, showing the given amount of items at once in the dropdown.
    NatCombo(org.eclipse.swt.widgets.Composite parent, IStyle cellStyle, int maxVisibleItems, int style, org.eclipse.swt.graphics.Image iconImage, boolean showDropdownFilter, boolean linkItemAndCheckbox)
    Creates a new NatCombo using the given IStyle for rendering, showing the given amount of items at once in the dropdown.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addFocusListener(org.eclipse.swt.events.FocusListener listener)
     
    void
    addKeyListener(org.eclipse.swt.events.KeyListener listener)
     
    void
    addMouseListener(org.eclipse.swt.events.MouseListener listener)
     
    void
    addSelectionListener(org.eclipse.swt.events.SelectionListener listener)
     
    void
    addShellListener(org.eclipse.swt.events.ShellListener listener)
     
    void
    addTextControlListener(org.eclipse.swt.events.ControlListener listener)
     
    void
    addTraverseListener(org.eclipse.swt.events.TraverseListener listener)
     
    protected void
     
    protected void
    Calculates the size and location of the Shell that represents the dropdown control of this NatCombo.
    protected void
    Calculates and applies the column width to ensure that the column has the same width as the table itself, so selection is possible for the whole row.
    protected void
    Create the dropdown control of this NatCombo, adding styles, look&feel and needed listeners for the control only.
    protected void
    createTextControl(int style)
    Creates the Text control of this NatCombo, adding styles, look&feel and needed listeners for the control only.
    boolean
     
    protected org.eclipse.swt.widgets.Table
     
    Returns an array of Strings that are currently selected in the receiver.
    int
    Returns the number of selected items contained in the receiver.
    int
    Returns the zero-relative index of the item which is currently selected in the receiver, or -1 if no item is selected.
    int[]
    Returns the zero-relative indices of the items which are currently selected in the receiver.
    protected String[]
    Will transform the text for the Text control of this NatCombo to an array of Strings.
    protected String[]
    Transforms the selection in the Table control dropdown into a String[].
    protected String
    Transforms the given array of Strings to a text representation that can be added to the text control of this combo.
    protected String
    Transforms the selection of the dropdown to a text representation that can be added to the text control of this combo.
    protected int
    Calculates the number of items that should be showed in the dropdown at once.
    void
    Hide the dropdown of this NatCombo.
    boolean
     
    void
    notifyListeners(int eventType, org.eclipse.swt.widgets.Event event)
     
    void
    removeFocusListener(org.eclipse.swt.events.FocusListener listener)
     
    void
    removeKeyListener(org.eclipse.swt.events.KeyListener listener)
     
    void
    removeMouseListener(org.eclipse.swt.events.MouseListener listener)
     
    void
    removeSelectionListener(org.eclipse.swt.events.SelectionListener listener)
     
    void
    removeShellListener(org.eclipse.swt.events.ShellListener listener)
     
    void
    removeTextControlListener(org.eclipse.swt.events.ControlListener listener)
     
    void
    removeTraverseListener(org.eclipse.swt.events.TraverseListener listener)
     
    void
    select(int index)
    Selects the item at the given zero-relative index in the receiver's list.
    void
    select(int[] indices)
    Selects the items at the given zero-relative indices in the receiver.
    void
    setDropdownFilterKeyListener(org.eclipse.swt.events.KeyListener listener)
    Sets a KeyListener that should be added to the dropdown filter control.
    void
    setDropdownFilterModifyListener(org.eclipse.swt.events.ModifyListener listener)
    Sets a ModifyListener that should be added to the dropdown filter control.
    protected void
    Transforms the given String array whose contents represents selected items to a selection that can be handled by the underlying Table control in the dropdown.
    void
    setItems(String[] items)
    Sets the given items to be the items shown in the dropdown of this NatCombo.
    void
    setMultiselectTextBracket(String multiselectTextPrefix, String multiselectTextSuffix)
    Set the prefix and suffix that will parenthesize the text that is created out of the selected values if this NatCombo supports multiselection.
    void
    setMultiselectValueSeparator(String multiselectValueSeparator)
     
    void
    Selects the items at the given zero-relative indices in the receiver.
    void
    Shows the dropdown of this NatCombo.
    void
    showDropdownControl(boolean focusOnText)
    Shows the dropdown of this NatCombo.
    void
    showDropdownControl(boolean focusOnText, boolean focusOnFilterBox)
    Shows the dropdown of this NatCombo.
    protected void
    updateTextControl(boolean hideDropdown)
    This method will be called if an item of the dropdown control is selected via mouse click or pressing enter.

    Methods inherited from class org.eclipse.swt.widgets.Composite

    changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList

    Methods inherited from class org.eclipse.swt.widgets.Scrollable

    computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar

    Methods inherited from class org.eclipse.swt.widgets.Control

    addControlListener, addDragDetectListener, addGestureListener, addHelpListener, addMenuDetectListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, computeSize, computeSize, dragDetect, dragDetect, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeGestureListener, removeHelpListener, removeMenuDetectListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, requestLayout, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setToolTipText, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, update

    Methods inherited from class org.eclipse.swt.widgets.Widget

    addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, isAutoDirection, isDisposed, isListening, removeDisposeListener, removeListener, removeListener, reskin, setData, setData, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.eclipse.swt.graphics.Drawable

    isAutoScalable
  • Field Details

    • DEFAULT_MULTI_SELECT_VALUE_SEPARATOR

      public static final String DEFAULT_MULTI_SELECT_VALUE_SEPARATOR
      Default String that is used to separate values in the String representation showed in the text control if multiselect is supported.
      See Also:
    • DEFAULT_MULTI_SELECT_PREFIX

      public static final String DEFAULT_MULTI_SELECT_PREFIX
      Default String that is used to prefix the generated String representation showed in the text control if multiselect is supported.
      See Also:
    • DEFAULT_MULTI_SELECT_SUFFIX

      public static final String DEFAULT_MULTI_SELECT_SUFFIX
      String that is used to suffix the generated String representation showed in the text control if multiselect is supported.
      See Also:
    • DEFAULT_NUM_OF_VISIBLE_ITEMS

      public static final int DEFAULT_NUM_OF_VISIBLE_ITEMS
      The default number of visible items on open the combo.
      See Also:
    • cellStyle

      protected final IStyle cellStyle
      The IStyle that is used for rendering the Text and the combo control. The important configurations used are horizontal alignment, background and foreground color and font.
    • maxVisibleItems

      protected int maxVisibleItems
      The maximum number of visible items of the combo. Setting this value to -1 will result in always showing all items at once.
    • itemList

      protected List<String> itemList
      The items that are showed within the combo transformed to a java.util.List. Needed for indexed operations in the dropdown
    • selectionStateMap

      protected Map<String,Boolean> selectionStateMap
      Map used to hold the selection state of items in the drop. Needed to maintain state when filtering
      Since:
      1.4
    • filterBox

      protected org.eclipse.swt.widgets.Text filterBox
      The text control allowing filtering of options
      Since:
      1.4
    • text

      protected org.eclipse.swt.widgets.Text text
      The text control of this NatCombo, allowing to enter values directly.
    • iconImage

      protected org.eclipse.swt.graphics.Image iconImage
      The image that is shown at the right edge of the text control if the NatCombo is opened.
    • widgetStyle

      protected final int widgetStyle
      The style bits that where set on creation time. Needed in case the dropdown shell was disposed and needs to be created again.
      Since:
      2.0 - Renamed from style to widgetStyle to avoid possible confusions with Widget#style.
    • showDropdownFilter

      protected boolean showDropdownFilter
      Flag that indicated whether this NatCombo supports filtering of the values in the dropdown control
      Since:
      1.4
    • freeEdit

      protected boolean freeEdit
      Flag that indicates whether this ComboBoxCellEditor supports free editing in the text control of the NatCombo or not. By default free editing is disabled.
    • multiselect

      protected boolean multiselect
      Flag that indicates whether this NatCombo supports multiselect or not. By default multiselect is disabled.
    • useCheckbox

      protected boolean useCheckbox
      Flag that indicates whether checkboxes should be shown for the items in the dropdown.
    • linkItemAndCheckbox

      protected boolean linkItemAndCheckbox
      Flag to configure if a click on the item should update the checkbox state. By default set to false to separate item selection via mouse click and checkbox handling.
      Since:
      2.3
    • multiselectValueSeparator

      protected String multiselectValueSeparator
      String that is used to separate values in the String representation showed in the text control if multiselect is supported.
    • multiselectTextPrefix

      protected String multiselectTextPrefix
      String that is used to prefix the generated String representation showed in the text control if multiselect is supported. Needed to visualize the multiselection to the user.
    • multiselectTextSuffix

      protected String multiselectTextSuffix
      String that is used to suffix the generated String representation showed in the text control if multiselect is supported. Needed to visualize the multiselection to the user.
  • Constructor Details

    • NatCombo

      public NatCombo(org.eclipse.swt.widgets.Composite parent, IStyle cellStyle, int style)
      Creates a new NatCombo using the given IStyle for rendering, showing the default number of items at once in the dropdown. Creating the NatCombo with this constructor, there is no free edit and no multiple selection enabled.
      Parameters:
      parent - A widget that will be the parent of this NatCombo
      cellStyle - Style configuration containing horizontal alignment, font, foreground and background color information.
      style - The style for the Text Control to construct. Uses this style adding internal styles via ConfigRegistry.
    • NatCombo

      public NatCombo(org.eclipse.swt.widgets.Composite parent, IStyle cellStyle, int maxVisibleItems, int style)
      Creates a new NatCombo using the given IStyle for rendering, showing the given amount of items at once in the dropdown. Creating the NatCombo with this constructor, there is no free edit and no multiple selection enabled.
      Parameters:
      parent - A widget that will be the parent of this NatCombo
      cellStyle - Style configuration containing horizontal alignment, font, foreground and background color information.
      maxVisibleItems - the max number of items the drop down will show before introducing a scroll bar.
      style - The style for the Text Control to construct. Uses this style adding internal styles via ConfigRegistry.
    • NatCombo

      public NatCombo(org.eclipse.swt.widgets.Composite parent, IStyle cellStyle, int maxVisibleItems, int style, boolean showDropdownFilter)
      Creates a new NatCombo using the given IStyle for rendering, showing the given amount of items at once in the dropdown. Creating the NatCombo with this constructor, there is no free edit and no multiple selection enabled.
      Parameters:
      parent - A widget that will be the parent of this NatCombo
      cellStyle - Style configuration containing horizontal alignment, font, foreground and background color information.
      maxVisibleItems - the max number of items the drop down will show before introducing a scroll bar.
      style - The style for the Text Control to construct. Uses this style adding internal styles via ConfigRegistry.
      showDropdownFilter - Flag indicating whether the dropdown filter is displayed
      Since:
      1.4
    • NatCombo

      public NatCombo(org.eclipse.swt.widgets.Composite parent, IStyle cellStyle, int maxVisibleItems, int style, boolean showDropdownFilter, boolean linkItemAndCheckbox)
      Creates a new NatCombo using the given IStyle for rendering, showing the given amount of items at once in the dropdown. Creating the NatCombo with this constructor, there is no free edit and no multiple selection enabled.
      Parameters:
      parent - A widget that will be the parent of this NatCombo
      cellStyle - Style configuration containing horizontal alignment, font, foreground and background color information.
      maxVisibleItems - the max number of items the drop down will show before introducing a scroll bar.
      style - The style for the Text Control to construct. Uses this style adding internal styles via ConfigRegistry.
      showDropdownFilter - Flag indicating whether the dropdown filter is displayed
      linkItemAndCheckbox - Flag indicating if a click on the item in the dropdown should update the checkbox.
      Since:
      2.3
    • NatCombo

      public NatCombo(org.eclipse.swt.widgets.Composite parent, IStyle cellStyle, int maxVisibleItems, int style, org.eclipse.swt.graphics.Image iconImage)
      Creates a new NatCombo using the given IStyle for rendering, showing the given amount of items at once in the dropdown.
      Parameters:
      parent - A widget that will be the parent of this NatCombo
      cellStyle - Style configuration containing horizontal alignment, font, foreground and background color information.
      maxVisibleItems - the max number of items the drop down will show before introducing a scroll bar.
      style - The style for the Text Control to construct. Uses this style adding internal styles via ConfigRegistry.
      iconImage - The image to use as overlay to the Text Control if the dropdown is visible. Using this image will indicate that the control is an open combo to the user.
    • NatCombo

      public NatCombo(org.eclipse.swt.widgets.Composite parent, IStyle cellStyle, int maxVisibleItems, int style, org.eclipse.swt.graphics.Image iconImage, boolean showDropdownFilter)
      Creates a new NatCombo using the given IStyle for rendering, showing the given amount of items at once in the dropdown.
      Parameters:
      parent - A widget that will be the parent of this NatCombo
      cellStyle - Style configuration containing horizontal alignment, font, foreground and background color information.
      maxVisibleItems - the max number of items the drop down will show before introducing a scroll bar.
      style - The style for the Text Control to construct. Uses this style adding internal styles via ConfigRegistry.
      iconImage - The image to use as overlay to the Text Control if the dropdown is visible. Using this image will indicate that the control is an open combo to the user.
      showDropdownFilter - Flag indicating whether the dropdown filter is displayed.
      Since:
      1.4
    • NatCombo

      public NatCombo(org.eclipse.swt.widgets.Composite parent, IStyle cellStyle, int maxVisibleItems, int style, org.eclipse.swt.graphics.Image iconImage, boolean showDropdownFilter, boolean linkItemAndCheckbox)
      Creates a new NatCombo using the given IStyle for rendering, showing the given amount of items at once in the dropdown.
      Parameters:
      parent - A widget that will be the parent of this NatCombo
      cellStyle - Style configuration containing horizontal alignment, font, foreground and background color information.
      maxVisibleItems - the max number of items the drop down will show before introducing a scroll bar.
      style - The style for the Text Control to construct. Uses this style adding internal styles via ConfigRegistry.
      iconImage - The image to use as overlay to the Text Control if the dropdown is visible. Using this image will indicate that the control is an open combo to the user.
      showDropdownFilter - Flag indicating whether the dropdown filter is displayed.
      linkItemAndCheckbox - Flag indicating if a click on the item in the dropdown should update the checkbox.
      Since:
      2.3
  • Method Details

    • setItems

      public void setItems(String[] items)
      Sets the given items to be the items shown in the dropdown of this NatCombo.
      Parameters:
      items - The array of items to set.
    • createTextControl

      protected void createTextControl(int style)
      Creates the Text control of this NatCombo, adding styles, look&feel and needed listeners for the control only.
      Parameters:
      style - The style for the Text Control to construct. Uses this style adding internal styles via ConfigRegistry.
    • createDropdownControl

      protected void createDropdownControl(int style)
      Create the dropdown control of this NatCombo, adding styles, look&feel and needed listeners for the control only.
      Parameters:
      style - The style for the Table Control to construct. Uses this style adding internal styles via ConfigRegistry.
    • updateTextControl

      protected void updateTextControl(boolean hideDropdown)
      This method will be called if an item of the dropdown control is selected via mouse click or pressing enter. It will populate the text control with the information gathered out of the selection in the dropdown control and hide the dropdown if necessary.
      Parameters:
      hideDropdown - true if the dropdown should be hidden after updating the text control
    • showDropdownControl

      public void showDropdownControl()
      Shows the dropdown of this NatCombo. Will always calculate the size of the dropdown regarding the current size of the Text control.
    • showDropdownControl

      public void showDropdownControl(boolean focusOnText)
      Shows the dropdown of this NatCombo. Will always calculate the size of the dropdown regarding the current size of the Text control.
      Parameters:
      focusOnText - true if the focus should be set to the text control instead of the dropdown after opening the dropdown.
    • showDropdownControl

      public void showDropdownControl(boolean focusOnText, boolean focusOnFilterBox)
      Shows the dropdown of this NatCombo. Will always calculate the size of the dropdown regarding the current size of the Text control.
      Parameters:
      focusOnText - true if the focus should be set to the text control instead of the dropdown after opening the dropdown.
      focusOnFilterBox - true if the focus should be set to the filterbox control instead of the dropdown after opening the dropdown. Has only an effect if showDropdownFilter is true and the focusOnText parameter is set to false.
      Since:
      2.3
    • getDropdownTable

      protected org.eclipse.swt.widgets.Table getDropdownTable()
      Returns:
      The Table control that is used in the dropdown. Will be created if it does not exist yet.
      Since:
      1.5
    • hideDropdownControl

      public void hideDropdownControl()
      Hide the dropdown of this NatCombo.
    • getVisibleItemCount

      protected int getVisibleItemCount()
      Calculates the number of items that should be showed in the dropdown at once. It is needed to calculate the height of the dropdown. If maxVisibleItems is configured -1, this method always returns the number of items in the list. Otherwise if will return the configured maximum number of items to be visible at once or less if there are less than the configured maximum.
      Returns:
      the number of items that should be showed in the dropdown at once.
    • calculateBounds

      protected void calculateBounds()
      Calculates the size and location of the Shell that represents the dropdown control of this NatCombo. Size and location will be calculated dependent the position and size of the corresponding Text control and the information showed in the dropdown.
    • calculateColumnWidth

      protected void calculateColumnWidth()
      Calculates and applies the column width to ensure that the column has the same width as the table itself, so selection is possible for the whole row.
    • getSelectionIndex

      public int getSelectionIndex()
      Returns the zero-relative index of the item which is currently selected in the receiver, or -1 if no item is selected.

      Note that this only returns useful results if this NatCombo supports single selection or only one item is selected.

      Returns:
      the index of the selected item or -1
    • getSelectionIndices

      public int[] getSelectionIndices()
      Returns the zero-relative indices of the items which are currently selected in the receiver. The order of the indices is unspecified. The array is empty if no items are selected.

      Note: This is not the actual structure used by the receiver to maintain its selection, so modifying the array will not affect the receiver.

      Returns:
      the array of indices of the selected items
    • getSelectionCount

      public int getSelectionCount()
      Returns the number of selected items contained in the receiver.
      Returns:
      the number of selected items
    • getSelection

      public String[] getSelection()
      Returns an array of Strings that are currently selected in the receiver. The order of the items is unspecified. An empty array indicates that no items are selected.

      Note: This is not the actual structure used by the receiver to maintain its selection, so modifying the array will not affect the receiver.

      Returns:
      an array representing the selection
    • setSelection

      public void setSelection(String[] items)
      Selects the items at the given zero-relative indices in the receiver. The current selection is cleared before the new items are selected.

      Indices that are out of range and duplicate indices are ignored. If the receiver is single-select and multiple indices are specified, then all indices are ignored.

      The text control of this NatCombo will also be updated with the new selected values.

      Parameters:
      items - the items to select
    • select

      public void select(int index)
      Selects the item at the given zero-relative index in the receiver's list. If the item at the index was already selected, it remains selected. Indices that are out of range are ignored.
      Parameters:
      index - the index of the item to select
    • select

      public void select(int[] indices)
      Selects the items at the given zero-relative indices in the receiver. The current selection is not cleared before the new items are selected.

      If the item at a given index is not selected, it is selected. If the item at a given index was already selected, it remains selected. Indices that are out of range and duplicate indices are ignored. If the receiver is single-select and multiple indices are specified, then all indices are ignored.

      Parameters:
      indices - the array of indices for the items to select
    • applyDropdownListener

      protected void applyDropdownListener()
      Since:
      1.5
    • addKeyListener

      public void addKeyListener(org.eclipse.swt.events.KeyListener listener)
      Overrides:
      addKeyListener in class org.eclipse.swt.widgets.Control
    • removeKeyListener

      public void removeKeyListener(org.eclipse.swt.events.KeyListener listener)
      Overrides:
      removeKeyListener in class org.eclipse.swt.widgets.Control
    • addTraverseListener

      public void addTraverseListener(org.eclipse.swt.events.TraverseListener listener)
      Overrides:
      addTraverseListener in class org.eclipse.swt.widgets.Control
    • removeTraverseListener

      public void removeTraverseListener(org.eclipse.swt.events.TraverseListener listener)
      Overrides:
      removeTraverseListener in class org.eclipse.swt.widgets.Control
    • addMouseListener

      public void addMouseListener(org.eclipse.swt.events.MouseListener listener)
      Overrides:
      addMouseListener in class org.eclipse.swt.widgets.Control
    • removeMouseListener

      public void removeMouseListener(org.eclipse.swt.events.MouseListener listener)
      Overrides:
      removeMouseListener in class org.eclipse.swt.widgets.Control
    • notifyListeners

      public void notifyListeners(int eventType, org.eclipse.swt.widgets.Event event)
      Overrides:
      notifyListeners in class org.eclipse.swt.widgets.Widget
    • addSelectionListener

      public void addSelectionListener(org.eclipse.swt.events.SelectionListener listener)
    • removeSelectionListener

      public void removeSelectionListener(org.eclipse.swt.events.SelectionListener listener)
    • addShellListener

      public void addShellListener(org.eclipse.swt.events.ShellListener listener)
    • removeShellListener

      public void removeShellListener(org.eclipse.swt.events.ShellListener listener)
    • addTextControlListener

      public void addTextControlListener(org.eclipse.swt.events.ControlListener listener)
    • removeTextControlListener

      public void removeTextControlListener(org.eclipse.swt.events.ControlListener listener)
    • isFocusControl

      public boolean isFocusControl()
      Overrides:
      isFocusControl in class org.eclipse.swt.widgets.Control
    • forceFocus

      public boolean forceFocus()
      Overrides:
      forceFocus in class org.eclipse.swt.widgets.Control
    • addFocusListener

      public void addFocusListener(org.eclipse.swt.events.FocusListener listener)
      Overrides:
      addFocusListener in class org.eclipse.swt.widgets.Control
    • removeFocusListener

      public void removeFocusListener(org.eclipse.swt.events.FocusListener listener)
      Overrides:
      removeFocusListener in class org.eclipse.swt.widgets.Control
    • getTransformedSelection

      protected String[] getTransformedSelection()
      Transforms the selection in the Table control dropdown into a String[]. Doing this is necessary to provide a SWT List like interface regarding selections for the NatCombo.
      Returns:
      Array containing all selected TableItem text attributes
    • setDropdownSelection

      protected void setDropdownSelection(String[] selection)
      Transforms the given String array whose contents represents selected items to a selection that can be handled by the underlying Table control in the dropdown.
      Parameters:
      selection - The Strings that represent the selected items
    • getTextAsArray

      protected String[] getTextAsArray()
      Will transform the text for the Text control of this NatCombo to an array of Strings. This is necessary for the multiselect feature.

      Note that by default the multiselect String is specified to show with enclosing [] brackets and values separated by ", ". If you need to change this you need to set the corresponding values in this NatCombo.

      Returns:
      The text for the Text control of this NatCombo converted to an array of Strings.
    • getTransformedTextForSelection

      protected String getTransformedTextForSelection()
      Transforms the selection of the dropdown to a text representation that can be added to the text control of this combo.

      Note that by default the multiselect String is specified to show with enclosing [] brackets and values separated by ", ". If you need to change this you need to set the corresponding values in this NatCombo.

      Returns:
      String representation for the selection within the combo.
    • getTransformedText

      protected String getTransformedText(String[] values)
      Transforms the given array of Strings to a text representation that can be added to the text control of this combo.

      If this NatCombo is only configured to support single selection, than only the first value in the array will be processed. Otherwise the result will be processed by concatenating the values.

      Note that by default the multiselect String is specified to show with enclosing [] brackets and values separated by ", ". If you need to change this you need to set the corresponding values in this NatCombo.

      Parameters:
      values - The values to build the text representation from.
      Returns:
      String representation for the selection within the combo.
    • setMultiselectValueSeparator

      public void setMultiselectValueSeparator(String multiselectValueSeparator)
      Parameters:
      multiselectValueSeparator - String that should be used to separate values in the String representation showed in the text control if multiselect is supported. null to use the default value separator.
      See Also:
    • setMultiselectTextBracket

      public void setMultiselectTextBracket(String multiselectTextPrefix, String multiselectTextSuffix)
      Set the prefix and suffix that will parenthesize the text that is created out of the selected values if this NatCombo supports multiselection.
      Parameters:
      multiselectTextPrefix - String that should be used to prefix the generated String representation showed in the text control if multiselect is supported. null to use the default prefix.
      multiselectTextSuffix - String that should be used to suffix the generated String representation showed in the text control if multiselect is supported. null to use the default suffix.
      See Also:
    • setDropdownFilterModifyListener

      public void setDropdownFilterModifyListener(org.eclipse.swt.events.ModifyListener listener)
      Sets a ModifyListener that should be added to the dropdown filter control. Should extend NatCombo.DropDownFilterModifyListener so the necessary actions for updating the dropdown on filtering is executed.
      Parameters:
      listener - ModifyListener that should be added to the dropdown filter to trigger actions on filtering the dropdown content.
      Since:
      2.1
      See Also:
    • setDropdownFilterKeyListener

      public void setDropdownFilterKeyListener(org.eclipse.swt.events.KeyListener listener)
      Sets a KeyListener that should be added to the dropdown filter control.
      Parameters:
      listener - KeyListener that should be added to the dropdown filter control.
      Since:
      2.1
      See Also: