Class FilterNatCombo
- All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
Specialization of theNatCombo.DropDownFilterModifyListener
that updates the selection of the dropdown content to what is currently visible.protected class
MouseListener
that is used to link clicks on an item of the givenCheckboxTableViewer
with the checkbox.Nested classes/interfaces inherited from class org.eclipse.nebula.widgets.nattable.widget.NatCombo
NatCombo.DropDownFilterModifyListener, NatCombo.FocusListenerWrapper
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.eclipse.jface.viewers.CheckboxTableViewer
The viewer that contains the 'add to filter' item in the dropdown control.protected String[]
The initial selection that was set when the FilterNatCombo was opened.protected org.eclipse.jface.viewers.CheckboxTableViewer
The viewer that contains the 'select all' item in the dropdown control.Fields inherited from class org.eclipse.nebula.widgets.nattable.widget.NatCombo
cellStyle, DEFAULT_MULTI_SELECT_PREFIX, DEFAULT_MULTI_SELECT_SUFFIX, DEFAULT_MULTI_SELECT_VALUE_SEPARATOR, DEFAULT_NUM_OF_VISIBLE_ITEMS, dropdownShell, dropdownTable, dropdownTableViewer, filterBox, freeEdit, iconImage, itemList, linkItemAndCheckbox, maxVisibleItems, multiselect, multiselectTextPrefix, multiselectTextSuffix, multiselectValueSeparator, selectionStateMap, showDropdownFilter, text, useCheckbox, widgetStyle
Fields inherited from class org.eclipse.swt.widgets.Control
handle
-
Constructor Summary
ConstructorsConstructorDescriptionFilterNatCombo
(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.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.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.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.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.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.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. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCheckStateListener
(org.eclipse.jface.viewers.ICheckStateListener listener) Add an ICheckStateListener to the viewer of the dropdown that contains the select all item.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
Creates and adds the "add to filter" entry to the dropdown.protected void
createDropdownControl
(int style) Create the dropdown control of this NatCombo, adding styles, look&feel and needed listeners for the control only.protected String
protected String
String[]
Returns an array ofString
s that are currently selected 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.protected String[]
Will transform the text for the Text control of this NatCombo to an array of Strings.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.boolean
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.void
select
(int index) Selects the item at the given zero-relative index in the receiver's list.void
select
(int[] indeces) Selects the items at the given zero-relative indices in the receiver.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.void
setFilterModifyAction
(Runnable action) Activate theFilterNatCombo.FilterDropDownFilterModifyListener
to perform an update on the selection on the dropdown based on the current visible items.void
setSelection
(String[] items) Selects the items at the given zero-relative indices in the receiver.protected void
updateAddToFilterVisibility
(org.eclipse.swt.widgets.TableItem clickedItem) Updates the visibility of the "add to filter" item.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.nebula.widgets.nattable.widget.NatCombo
addFocusListener, addKeyListener, addMouseListener, addSelectionListener, addShellListener, addTextControlListener, addTraverseListener, applyDropdownListener, createTextControl, forceFocus, getDropdownTable, getSelectionCount, getSelectionIndices, getTransformedSelection, getTransformedTextForSelection, getVisibleItemCount, hideDropdownControl, isFocusControl, notifyListeners, removeFocusListener, removeKeyListener, removeMouseListener, removeSelectionListener, removeShellListener, removeTextControlListener, removeTraverseListener, setDropdownFilterKeyListener, setDropdownFilterModifyListener, setItems, setMultiselectTextBracket, setMultiselectValueSeparator, showDropdownControl, showDropdownControl, showDropdownControl
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
-
selectAllItemViewer
protected org.eclipse.jface.viewers.CheckboxTableViewer selectAllItemViewerThe viewer that contains the 'select all' item in the dropdown control.- Since:
- 1.4
-
addToFilterItemViewer
protected org.eclipse.jface.viewers.CheckboxTableViewer addToFilterItemViewerThe viewer that contains the 'add to filter' item in the dropdown control.- Since:
- 2.2
-
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
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 NatCombocellStyle
- 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 NatCombocellStyle
- 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 NatCombocellStyle
- 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 NatCombocellStyle
- 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 displayedlinkItemAndCheckbox
- 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 NatCombocellStyle
- 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 theText
Control to construct. Uses this style adding internal styles via ConfigRegistry.iconImage
- The image to use as overlay to theText
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 NatCombocellStyle
- 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 theText
Control to construct. Uses this style adding internal styles via ConfigRegistry.iconImage
- The image to use as overlay to theText
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 NatCombocellStyle
- 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 theText
Control to construct. Uses this style adding internal styles via ConfigRegistry.iconImage
- The image to use as overlay to theText
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 displayedlinkItemAndCheckbox
- 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 classNatCombo
-
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 classNatCombo
-
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 classNatCombo
- Parameters:
style
- The style for the Table Control to construct. Uses this style adding internal styles via ConfigRegistry.
-
setDropdownSelection
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 classNatCombo
- 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 classNatCombo
- 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 classNatCombo
- Returns:
- the index of the selected item or -1
-
getSelection
Description copied from class:NatCombo
Returns an array ofString
s 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 classNatCombo
- Returns:
- an array representing the selection
-
setSelection
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 classNatCombo
- 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 ornull
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 ornull
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. -
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.
-
getTransformedText
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 classNatCombo
- Parameters:
values
- The values to build the text representation from.- Returns:
- String representation for the selection within the combo.
-
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 classNatCombo
- Returns:
- The text for the Text control of this NatCombo converted to an array of Strings.
-
setFilterModifyAction
Activate theFilterNatCombo.FilterDropDownFilterModifyListener
to perform an update on the selection on the dropdown based on the current visible items. Adds the givenRunnable
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 totrue
.- 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
- Returns:
- The label that is used for the "select all" item.
- Since:
- 2.2
-
getAddToFilterLabel
- Returns:
- The label that is used for the "add to filter" item.
- Since:
- 2.2
-