public class FilterNatCombo extends NatCombo
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.
cellStyle, DEFAULT_MULTI_SELECT_PREFIX, DEFAULT_MULTI_SELECT_SUFFIX, DEFAULT_MULTI_SELECT_VALUE_SEPARATOR, DEFAULT_NUM_OF_VISIBLE_ITEMS, dropdownShell, dropdownTable, freeEdit, iconImage, itemList, maxVisibleItems, multiselect, multiselectTextPrefix, multiselectTextSuffix, multiselectValueSeparator, style, text, useCheckbox
Constructor and 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,
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.
|
Modifier and Type | Method and 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 |
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 of
String 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.
|
addKeyListener, addMouseListener, addSelectionListener, addShellListener, addTraverseListener, createTextControl, dispose, getSelectionCount, getSelectionIndices, getTransformedSelection, getTransformedTextForSelection, getVisibleItemCount, hideDropdownControl, notifyListeners, setItems, setMultiselectTextBracket, setMultiselectValueSeparator, showDropdownControl, showDropdownControl
changed, checkSubclass, computeSize, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList
computeTrim, getClientArea, getHorizontalBar, getVerticalBar
addControlListener, addDragDetectListener, addFocusListener, addHelpListener, addMenuDetectListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getParent, getRegion, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTraverseListener, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setRegion, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, update
public FilterNatCombo(org.eclipse.swt.widgets.Composite parent, IStyle cellStyle, int style)
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.public FilterNatCombo(org.eclipse.swt.widgets.Composite parent, IStyle cellStyle, int maxVisibleItems, int style)
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.public FilterNatCombo(org.eclipse.swt.widgets.Composite parent, IStyle cellStyle, int maxVisibleItems, int style, org.eclipse.swt.graphics.Image iconImage)
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.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.protected void calculateBounds()
NatCombo
calculateBounds
in class NatCombo
protected void createDropdownControl(int style)
NatCombo
createDropdownControl
in class NatCombo
style
- The style for the Table Control to construct. Uses this style
adding internal styles via ConfigRegistry.protected void setDropdownSelection(String[] selection)
NatCombo
setDropdownSelection
in class NatCombo
selection
- The Strings that represent the selected itemspublic void addCheckStateListener(org.eclipse.jface.viewers.ICheckStateListener listener)
listener
- The listener to add to the select all itemprotected void updateTextControl(boolean hideDropdown)
NatCombo
updateTextControl
in class NatCombo
hideDropdown
- true
if the dropdown should be hidden
after updating the text controlpublic int getSelectionIndex()
NatCombo
Note that this only returns useful results if this NatCombo supports single selection or only one item is selected.
getSelectionIndex
in class NatCombo
public String[] getSelection()
NatCombo
String
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.
getSelection
in class NatCombo
public void setSelection(String[] items)
NatCombo
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.
setSelection
in class NatCombo
items
- the items to selectpublic void select(int index)
NatCombo
public void select(int[] indeces)
NatCombo
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.
protected String getTransformedText(String[] values)
NatCombo
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.
getTransformedText
in class NatCombo
values
- The values to build the text representation from.protected String[] getTextAsArray()
NatCombo
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.
getTextAsArray
in class NatCombo
Copyright © 2013. All Rights Reserved.