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
org.eclipse.nebula.widgets.nattable.filterrow.combobox.FilterNatCombo
All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable

public class FilterNatCombo extends NatCombo
Specialisation of NatCombo which doesn't populate the selected values to the Text control. Instead the String representation of the selected values are stored in a local member. Doing this the selection is only visible in the dropdown via selection/check state of the contained items.

Usually this combo will be created with the SWT.CHECK style bit. This way the selected items are visualized by showing checked checkboxes. Also adds a Select All item for convenience that de-/selects all items on click.

  • Field Details

    • selectAllItemViewer

      protected org.eclipse.jface.viewers.CheckboxTableViewer selectAllItemViewer
      The viewer that contains the 'select all' item in the dropdown control.
      Since:
      1.4
    • addToFilterItemViewer

      protected org.eclipse.jface.viewers.CheckboxTableViewer addToFilterItemViewer
      The viewer that contains the 'add to filter' item in the dropdown control.
      Since:
      2.2
    • initialSelection

      protected String[] initialSelection
      The initial selection that was set when the FilterNatCombo was opened. Needed to restore the state on deactivating the 'add to filter' checkbox.
      Since:
      2.2
  • Constructor Details

    • FilterNatCombo

      public FilterNatCombo(org.eclipse.swt.widgets.Composite parent, IStyle cellStyle, int style)
      Creates a new FilterNatCombo using the given IStyle for rendering, showing the default number 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.
      style - The style for the Text Control to construct. Uses this style adding internal styles via ConfigRegistry.
    • FilterNatCombo

      public FilterNatCombo(org.eclipse.swt.widgets.Composite parent, IStyle cellStyle, int maxVisibleItems, int style)
      Creates a new FilterNatCombo 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.
    • FilterNatCombo

      public FilterNatCombo(org.eclipse.swt.widgets.Composite parent, IStyle cellStyle, int maxVisibleItems, int style, boolean showDropdownFilter)
      Creates a new FilterNatCombo 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.
      showDropdownFilter - Flag indicating whether the filter of the dropdown control should be displayed
      Since:
      1.4
    • FilterNatCombo

      public FilterNatCombo(org.eclipse.swt.widgets.Composite parent, IStyle cellStyle, int maxVisibleItems, int style, boolean showDropdownFilter, boolean linkItemAndCheckbox)
      Creates a new FilterNatCombo 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.
      showDropdownFilter - Flag indicating whether the filter of the dropdown control should be displayed
      linkItemAndCheckbox - Flag indicating if a click on the item in the dropdown should update the checkbox.
      Since:
      2.3
    • FilterNatCombo

      public FilterNatCombo(org.eclipse.swt.widgets.Composite parent, IStyle cellStyle, int maxVisibleItems, int style, org.eclipse.swt.graphics.Image iconImage)
      Creates a new FilterNatCombo 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.
    • FilterNatCombo

      public FilterNatCombo(org.eclipse.swt.widgets.Composite parent, IStyle cellStyle, int maxVisibleItems, int style, org.eclipse.swt.graphics.Image iconImage, boolean showDropdownFilter)
      Creates a new FilterNatCombo 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 filter of the dropdown control should be displayed
      Since:
      1.4
    • FilterNatCombo

      public FilterNatCombo(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 FilterNatCombo 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 filter of the dropdown control should be displayed
      linkItemAndCheckbox - Flag indicating if a click on the item in the dropdown should update the checkbox.
      Since:
      2.3
  • Method Details

    • calculateBounds

      protected void calculateBounds()
      Description copied from class: NatCombo
      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.
      Overrides:
      calculateBounds in class NatCombo
    • calculateColumnWidth

      protected void calculateColumnWidth()
      Description copied from class: NatCombo
      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.
      Overrides:
      calculateColumnWidth in class NatCombo
    • createDropdownControl

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

      protected void setDropdownSelection(String[] selection)
      Description copied from class: NatCombo
      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.
      Overrides:
      setDropdownSelection in class NatCombo
      Parameters:
      selection - The Strings that represent the selected items
    • addCheckStateListener

      public void addCheckStateListener(org.eclipse.jface.viewers.ICheckStateListener listener)
      Add an ICheckStateListener to the viewer of the dropdown that contains the select all item. Needed so the editor is able to commit after the click on the select all checkbox is performed.
      Parameters:
      listener - The listener to add to the select all item
    • updateTextControl

      protected void updateTextControl(boolean hideDropdown)
      Description copied from class: NatCombo
      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.
      Overrides:
      updateTextControl in class NatCombo
      Parameters:
      hideDropdown - true if the dropdown should be hidden after updating the text control
    • getSelectionIndex

      public int getSelectionIndex()
      Description copied from class: NatCombo
      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.

      Overrides:
      getSelectionIndex in class NatCombo
      Returns:
      the index of the selected item or -1
    • getSelection

      public String[] getSelection()
      Description copied from class: NatCombo
      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.

      Overrides:
      getSelection in class NatCombo
      Returns:
      an array representing the selection
    • setSelection

      public void setSelection(String[] items)
      Description copied from class: NatCombo
      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.

      Overrides:
      setSelection in class NatCombo
      Parameters:
      items - the items to select
    • createAddToFilterItemViewer

      protected void createAddToFilterItemViewer()
      Creates and adds the "add to filter" entry to the dropdown. Initially hidden and becomes visible once a dropdown filter is entered if an initial selection is set.
      Since:
      2.2
    • updateAddToFilterVisibility

      protected void updateAddToFilterVisibility(org.eclipse.swt.widgets.TableItem clickedItem)
      Updates the visibility of the "add to filter" item. Hides it if all now visible items are already selected, shows it if the shown selection state differs from the current applied selection.
      Parameters:
      clickedItem - The item that was clicked in the dropdown or null if the "add to filter" item should be reset by another cause (e.g. changing the dropdown filter.
      Since:
      2.2
    • resetAddToFilter

      protected void resetAddToFilter(org.eclipse.swt.widgets.TableItem clickedItem)
      Unchecks the "add to filter" item and applies the current state as initial selection, so further operations in the open dropdown are consistent.
      Parameters:
      clickedItem - The item that was clicked in the dropdown or null if the "add to filter" item should be reset by another cause (e.g. changing the dropdown filter.
      Since:
      2.2
    • select

      public void select(int index)
      Description copied from class: NatCombo
      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.
      Overrides:
      select in class NatCombo
      Parameters:
      index - the index of the item to select
    • select

      public void select(int[] indeces)
      Description copied from class: NatCombo
      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.

      Overrides:
      select in class NatCombo
      Parameters:
      indeces - the array of indices for the items to select
    • getTransformedText

      protected String getTransformedText(String[] values)
      Description copied from class: NatCombo
      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.

      Overrides:
      getTransformedText in class NatCombo
      Parameters:
      values - The values to build the text representation from.
      Returns:
      String representation for the selection within the combo.
    • getTextAsArray

      protected String[] getTextAsArray()
      Description copied from class: NatCombo
      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.

      Overrides:
      getTextAsArray in class NatCombo
      Returns:
      The text for the Text control of this NatCombo converted to an array of Strings.
    • setFilterModifyAction

      public void setFilterModifyAction(Runnable action)
      Activate the FilterNatCombo.FilterDropDownFilterModifyListener to perform an update on the selection on the dropdown based on the current visible items. Adds the given Runnable as action that should be executed after the dropdown content filter was applied, e.g. applying the filter on the content based on the current visible items in the dropdown.

      Note: Only has an effect if showDropdownFilter is set to true.

      Parameters:
      action - The action that should be executed after the dropdown content filter was applied, e.g. applying the filter on the content based on the current visible items in the dropdown.
      Since:
      2.1
    • isFilterActive

      public boolean isFilterActive()
      Returns:
      true if the content of the dropdown is currently filtered and an initial selection is set.
      Since:
      2.2
    • getSelectAllLabel

      protected String getSelectAllLabel()
      Returns:
      The label that is used for the "select all" item.
      Since:
      2.2
    • getAddToFilterLabel

      protected String getAddToFilterLabel()
      Returns:
      The label that is used for the "add to filter" item.
      Since:
      2.2