Class MultiChoice<T>

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.opal.multichoice.MultiChoice<T>
Type Parameters:
T - Class of objects represented by this widget
All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable

public class MultiChoice<T>
extends org.eclipse.swt.widgets.Composite
The MultiChoice class represents a selectable user interface object that combines a read-only text-field and a set of checkboxes.

Note that although this class is a subclass of Composite, it does not make sense to add children to it, or set a layout on it.

Styles:
NONE
Events:
Selection
  • Field Summary

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

    handle
  • Constructor Summary

    Constructors 
    Constructor Description
    MultiChoice​(org.eclipse.swt.widgets.Composite parent, int style)
    Constructs a new instance of this class given its parent.
    MultiChoice​(org.eclipse.swt.widgets.Composite parent, int style, java.util.List<T> elements)
    Constructs a new instance of this class given its parent.
  • Method Summary

    Modifier and Type Method Description
    void add​(T value)
    Adds the argument to the end of the receiver's list.
    void add​(T value, int index)
    Adds the argument to the receiver's list at the given zero-relative index.
    void addAll​(java.util.List<T> values)
    Adds the argument to the end of the receiver's list.
    void addAll​(T[] values)
    Adds the argument to the end of the receiver's list.
    org.eclipse.swt.graphics.Point computeSize​(int wHint, int hHint, boolean changed)  
    void deselect​(T value)
    Deselects the item in the receiver's list.
    void deselectAll()
    Deselects all items in the receiver's list.
    void deselectAt​(int index)
    Deselects the item at the given zero-relative index in the receiver's list.
    org.eclipse.swt.widgets.Button getArrowButton()  
    org.eclipse.swt.graphics.Color getBackground()  
    boolean getEditable()
    Returns the editable state.
    org.eclipse.swt.graphics.Font getFont()  
    org.eclipse.swt.graphics.Color getForeground()  
    T getItem​(int index)
    Returns the item at the given, zero-relative index in the receiver's list.
    int getItemCount()
    Returns the number of items contained in the receiver's list.
    java.util.List<T> getItems()
    Returns the list of items in the receiver's list.
    (package private) T getLastModified()  
    int getNumberOfColumns()  
    (package private) org.eclipse.swt.widgets.Shell getPopup()  
    java.util.Set<T> getSelected()  
    int[] getSelectedIndex()
    Returns the zero-relative indices of the items which are currently selected in the receiver.
    java.util.List<T> getSelection()
    Returns an array of Objects that are currently selected in the receiver.
    org.eclipse.swt.events.SelectionListener getSelectionListener()  
    java.lang.String getSeparator()  
    java.lang.String getText()  
    org.eclipse.swt.widgets.Text getTextControl()  
    boolean isShowSelectUnselectAll()  
    void refresh()
    Refresh the widget (after the add of a new element for example)
    void remove​(T object)
    Searches the receiver's list starting at the first item until an item is found that is equal to the argument, and removes that item from the list.
    void removeAll()
    Remove all items of the receiver
    void removeAt​(int index)
    Removes the item from the receiver's list at the given zero-relative index.
    void select​(T value)
    Selects an item the receiver's list.
    void selectAll()
    Selects all selected items in the receiver's list.
    void selectAt​(int index)
    Selects the item at the given zero-relative index in the receiver's list.
    void setBackground​(org.eclipse.swt.graphics.Color background)  
    void setEditable​(boolean editable)
    Sets the editable state.
    void setEnabled​(boolean enabled)  
    void setFont​(org.eclipse.swt.graphics.Font font)  
    void setForeground​(org.eclipse.swt.graphics.Color foreground)  
    void setLabelProvider​(MultiChoiceLabelProvider labelProvider)  
    void setNumberOfColumns​(int numberOfColumns)  
    void setSelected​(java.util.Set<T> selection)  
    void setSelectedIndex​(int[] index)
    Selects items in the receiver.
    void setSelection​(java.util.Set<T> selection)
    Sets the selection of the receiver.
    void setSelectionListener​(MultiChoiceSelectionListener<T> selectionListener)  
    void setSeparator​(java.lang.String separator)  
    void setShowSelectUnselectAll​(boolean showSelectUnselectAll)  
    void setText​(java.lang.String textValue)
    Fill the text box.
    void setToolTipText​(java.lang.String txt)  
    void updateSelection()
    Update the selection
    protected void validateEntry()  

    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, toString

    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, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, 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, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData

    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
  • Constructor Details

    • MultiChoice

      public MultiChoice​(org.eclipse.swt.widgets.Composite parent, int style)
      Constructs a new instance of this class given its parent.
      Parameters:
      parent - a widget which will be the parent of the new instance (cannot be null)
      style - not used
      Throws:
      java.lang.IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the parent is null
      org.eclipse.swt.SWTException -
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
    • MultiChoice

      public MultiChoice​(org.eclipse.swt.widgets.Composite parent, int style, java.util.List<T> elements)
      Constructs a new instance of this class given its parent.
      Parameters:
      parent - a widget which will be the parent of the new instance (cannot be null)
      style - not used
      elements - list of elements displayed by this widget
      Throws:
      java.lang.IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the parent is null
      org.eclipse.swt.SWTException -
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
  • Method Details

    • validateEntry

      protected void validateEntry()
    • add

      public void add​(T value)
      Adds the argument to the end of the receiver's list.
      Parameters:
      values - new item
      Throws:
      java.lang.IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the string is null
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • add

      public void add​(T value, int index)
      Adds the argument to the receiver's list at the given zero-relative index.
      Parameters:
      values - new item
      index - the index for the item
      Throws:
      java.lang.IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the string is null
      • ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • addAll

      public void addAll​(java.util.List<T> values)
      Adds the argument to the end of the receiver's list.
      Parameters:
      values - new items
      Throws:
      java.lang.IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the string is null
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • addAll

      public void addAll​(T[] values)
      Adds the argument to the end of the receiver's list.
      Parameters:
      values - new items
      Throws:
      java.lang.IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the string is null
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getEditable

      public boolean getEditable()
      Returns the editable state.
      Returns:
      whether or not the receiver is editable
      Throws:
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getItem

      public T getItem​(int index)
      Returns the item at the given, zero-relative index in the receiver's list. Throws an exception if the index is out of range.
      Parameters:
      index - the index of the item to return
      Returns:
      the item at the given index
      Throws:
      java.lang.NullPointerException - if there is no item in the receiver
      java.lang.IllegalArgumentException -
      • ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getItemCount

      public int getItemCount()
      Returns the number of items contained in the receiver's list.
      Returns:
      the number of items
      Throws:
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getItems

      public java.util.List<T> getItems()
      Returns the list of items in the receiver's list.

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

      Returns:
      the items in the receiver's list
      Throws:
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • removeAt

      public void removeAt​(int index)
      Removes the item from the receiver's list at the given zero-relative index.
      Parameters:
      index - the index for the item
      Throws:
      java.lang.NullPointerException - if there is no item in the receiver
      java.lang.IllegalArgumentException -
      • ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • remove

      public void remove​(T object)
      Searches the receiver's list starting at the first item until an item is found that is equal to the argument, and removes that item from the list.
      Parameters:
      object - the item to remove
      Throws:
      java.lang.NullPointerException - if there is no item in the receiver
      java.lang.IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the object is null
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • removeAll

      public void removeAll()
      Remove all items of the receiver
      Throws:
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setLabelProvider

      public void setLabelProvider​(MultiChoiceLabelProvider labelProvider)
      Parameters:
      labelProvider - the Label Provider to set
    • setSelection

      public void setSelection​(java.util.Set<T> selection)
      Sets the selection of the receiver. If the item was already selected, it remains selected.
      Parameters:
      selection - the new selection
      Throws:
      java.lang.NullPointerException - if there is no item in the receiver
      java.lang.IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the selection is null
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • selectAll

      public void selectAll()
      Selects all selected items in the receiver's list.
      Throws:
      java.lang.NullPointerException - if there is no item in the receiver
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • selectAt

      public void selectAt​(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.
      Parameters:
      index - the index of the item to select
      Throws:
      java.lang.NullPointerException - if there is no item in the receiver
      java.lang.IllegalArgumentException -
      • ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • select

      public void select​(T value)
      Selects an item the receiver's list. If the item was already selected, it remains selected.
      Parameters:
      index - the index of the item to select
      Throws:
      java.lang.NullPointerException - if there is no item in the receiver
      java.lang.IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the selection is null
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setSelectedIndex

      public void setSelectedIndex​(int[] index)
      Selects items in the receiver. If the items were already selected, they remain selected.
      Parameters:
      index - the indexes of the items to select
      Throws:
      java.lang.NullPointerException - if there is no item in the receiver
      java.lang.IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the selection is null
      • ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getSelectedIndex

      public int[] getSelectedIndex()
      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
      Throws:
      java.lang.NullPointerException - if there is no item in the receiver
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getSelection

      public java.util.List<T> getSelection()
      Returns an array of Objects 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
      Throws:
      java.lang.NullPointerException - if there is no item in the receiver
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • deselectAt

      public void deselectAt​(int index)
      Deselects the item at the given zero-relative index in the receiver's list. If the item at the index was already deselected, it remains deselected. Indices that are out of range are ignored.
      Parameters:
      index - the index of the item to deselect
      Throws:
      java.lang.NullPointerException - if there is no item in the receiver
      java.lang.IllegalArgumentException -
      • ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • deselect

      public void deselect​(T value)
      Deselects the item in the receiver's list. If the item at the index was already deselected, it remains deselected.
      Parameters:
      value - the item to deselect
      Throws:
      java.lang.NullPointerException - if there is no item in the receiver
      java.lang.IllegalArgumentException -
      • ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • deselectAll

      public void deselectAll()
      Deselects all items in the receiver's list.
      Parameters:
      value - the item to deselect
      Throws:
      java.lang.NullPointerException - if there is no item in the receiver
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getNumberOfColumns

      public int getNumberOfColumns()
      Returns:
      the number of columns
    • setNumberOfColumns

      public void setNumberOfColumns​(int numberOfColumns)
      Parameters:
      numberOfColumns - the number of columns
    • getSeparator

      public java.lang.String getSeparator()
      Returns:
      the separator used in the text field. Default value is ","
    • setSeparator

      public void setSeparator​(java.lang.String separator)
      Parameters:
      separator - the new value of the separator
    • getForeground

      public org.eclipse.swt.graphics.Color getForeground()
      Overrides:
      getForeground in class org.eclipse.swt.widgets.Control
      See Also:
      Control.getForeground()
    • setForeground

      public void setForeground​(org.eclipse.swt.graphics.Color foreground)
      Overrides:
      setForeground in class org.eclipse.swt.widgets.Control
      See Also:
      Control.setForeground(org.eclipse.swt.graphics.Color)
    • getBackground

      public org.eclipse.swt.graphics.Color getBackground()
      Overrides:
      getBackground in class org.eclipse.swt.widgets.Control
      See Also:
      Control.getBackground()
    • setBackground

      public void setBackground​(org.eclipse.swt.graphics.Color background)
      Overrides:
      setBackground in class org.eclipse.swt.widgets.Control
      See Also:
      Control.setBackground(org.eclipse.swt.graphics.Color)
    • getFont

      public org.eclipse.swt.graphics.Font getFont()
      Overrides:
      getFont in class org.eclipse.swt.widgets.Control
      See Also:
      Control.getFont()
    • setFont

      public void setFont​(org.eclipse.swt.graphics.Font font)
      Overrides:
      setFont in class org.eclipse.swt.widgets.Control
      See Also:
      Control.setFont(org.eclipse.swt.graphics.Font)
    • refresh

      public void refresh()
      Refresh the widget (after the add of a new element for example)
    • computeSize

      public org.eclipse.swt.graphics.Point computeSize​(int wHint, int hHint, boolean changed)
      Overrides:
      computeSize in class org.eclipse.swt.widgets.Control
      See Also:
      Control.computeSize(int, int, boolean)
    • setEnabled

      public void setEnabled​(boolean enabled)
      Overrides:
      setEnabled in class org.eclipse.swt.widgets.Control
      See Also:
      Control.setEnabled(boolean)
    • setEditable

      public void setEditable​(boolean editable)
      Sets the editable state.
      Parameters:
      editable - the new editable state
      Throws:
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setToolTipText

      public void setToolTipText​(java.lang.String txt)
      Overrides:
      setToolTipText in class org.eclipse.swt.widgets.Control
      See Also:
      Control.setToolTipText(java.lang.String)
    • getSelectionListener

      public org.eclipse.swt.events.SelectionListener getSelectionListener()
      Returns:
      the selection listener
    • setSelectionListener

      public void setSelectionListener​(MultiChoiceSelectionListener<T> selectionListener)
      Parameters:
      selectionListener - the new selection listener
    • updateSelection

      public void updateSelection()
      Update the selection
    • getLastModified

      T getLastModified()
      Returns:
      the last modified item
    • getPopup

      org.eclipse.swt.widgets.Shell getPopup()
      Returns:
      the popup
    • setText

      public void setText​(java.lang.String textValue)
      Fill the text box. Please notice that the setted element MAY not be in the items list.
      For instance, your widget contains a list of european countries. If you use setText("USA"), the text will display "USA", but getSelection() will return and empty text. To retrieve "USA", you have to use the method getText();
      Parameters:
      textValue - new text value
    • getText

      public java.lang.String getText()
      Returns:
      the display value as text
    • isShowSelectUnselectAll

      public boolean isShowSelectUnselectAll()
      Returns:
      true if the hyperlinks "Select all" and "Deselect all" are displayted
    • setShowSelectUnselectAll

      public void setShowSelectUnselectAll​(boolean showSelectUnselectAll)
      Parameters:
      showSelectUnselectAll - set to "true" to display the hyperlinks "Select all" and "Deselect all"
    • setSelected

      public void setSelected​(java.util.Set<T> selection)
      Parameters:
      selection - elements to select
    • getSelected

      public java.util.Set<T> getSelected()
      Returns:
      selected elements
    • getTextControl

      public org.eclipse.swt.widgets.Text getTextControl()
      Returns:
      text control
    • getArrowButton

      public org.eclipse.swt.widgets.Button getArrowButton()
      Returns:
      the arrow button