Class FilterNatCombo
- 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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.nebula.widgets.nattable.widget.NatCombo
NatCombo.FocusListenerWrapper
-
-
Field Summary
Fields Modifier and Type Field Description protected org.eclipse.jface.viewers.CheckboxTableViewer
selectAllItemViewer
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, maxVisibleItems, multiselect, multiselectTextPrefix, multiselectTextSuffix, multiselectValueSeparator, selectionStateMap, showDropdownFilter, text, useCheckbox, widgetStyle
-
-
Constructor Summary
Constructors Constructor Description 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.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, 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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCheckStateListener(org.eclipse.jface.viewers.ICheckStateListener listener)
Add an ICheckStateListener to the viewer of the dropdown that contains the select all item.protected void
calculateBounds()
Calculates the size and location of the Shell that represents the dropdown control of this NatCombo.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.protected void
createDropdownControl(int style)
Create the dropdown control of this NatCombo, adding styles, look&feel and needed listeners for the control only.String[]
getSelection()
Returns an array ofString
s that are currently selected in the receiver.int
getSelectionIndex()
Returns the zero-relative index of the item which is currently selected in the receiver, or -1 if no item is selected.protected String[]
getTextAsArray()
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.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
setSelection(String[] items)
Selects the items at the given zero-relative indices in the receiver.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, setItems, setMultiselectTextBracket, setMultiselectValueSeparator, 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
-
-
-
-
Constructor Detail
-
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 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, 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
-
-
Method Detail
-
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
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 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
public String[] 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
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 classNatCombo
- Parameters:
items
- the items to select
-
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
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 classNatCombo
- 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 classNatCombo
- Returns:
- The text for the Text control of this NatCombo converted to an array of Strings.
-
-