Class PopupList

java.lang.Object
de.willuhn.jameica.gui.internal.swt.PopupList

public class PopupList extends Object
A PopupList is a list of selectable items that appears in its own shell positioned above its parent shell. It is used for selecting items when editing a Table cell (similar to the list that appears when you open a Combo box). The list will be positioned so that it does not run off the screen and the largest number of items are visible. It may appear above the current cursor location or below it depending how close you are to the edge of the screen.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    PopupList(org.eclipse.swt.widgets.Shell parent)
    Creates a PopupList above the specified shell.
    PopupList(org.eclipse.swt.widgets.Shell parent, int style)
    Creates a PopupList above the specified shell.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.eclipse.swt.graphics.Font
    Gets the widget font.
    Gets the items.
    int
    Gets the minimum width of the list.
    int
    open(org.eclipse.swt.graphics.Rectangle rect)
    Launches the Popup List, waits for an item to be selected and then closes the PopupList.
    void
    select(String string)
    Selects an item with text that starts with specified String.
    void
    setFont(org.eclipse.swt.graphics.Font font)
    Sets the widget font.
    void
    setItems(String[] strings)
    Sets all items.
    void
    setMinimumWidth(int width)
    Sets the minimum width of the list.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PopupList

      public PopupList(org.eclipse.swt.widgets.Shell parent)
      Creates a PopupList above the specified shell.
      Parameters:
      parent - a Shell control which will be the parent of the new instance (cannot be null)
    • PopupList

      public PopupList(org.eclipse.swt.widgets.Shell parent, int style)
      Creates a PopupList above the specified shell.
      Parameters:
      parent - a widget which will be the parent of the new instance (cannot be null)
      style - the style of widget to construct
      Since:
      3.0
  • Method Details

    • getFont

      public org.eclipse.swt.graphics.Font getFont()
      Gets the widget font.

      Returns:
      the widget font
      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 String[] getItems()
      Gets the items.

      This operation will fail if the items cannot be queried from the OS.

      Returns:
      the items in the widget
      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
    • getMinimumWidth

      public int getMinimumWidth()
      Gets the minimum width of the list.
      Returns:
      the minimum width of the list
    • open

      public int open(org.eclipse.swt.graphics.Rectangle rect)
      Launches the Popup List, waits for an item to be selected and then closes the PopupList.
      Parameters:
      rect - the initial size and location of the PopupList; the dialog will be positioned so that it does not run off the screen and the largest number of items are visible
      Returns:
      the 0-based position of the selected item.
    • select

      public void select(String string)
      Selects an item with text that starts with specified String.

      If the item is not currently selected, it is selected. If the item at an index is selected, it remains selected. If the string is not matched, it is ignored.

      Parameters:
      string - the text of the item
      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
    • setFont

      public void setFont(org.eclipse.swt.graphics.Font font)
      Sets the widget font.

      When new font is null, the font reverts to the default system font for the widget.

      Parameters:
      font - the new font (or null)
      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
    • setItems

      public void setItems(String[] strings)
      Sets all items.

      The previous selection is cleared. The previous items are deleted. The new items are added. The top index is set to 0.

      Parameters:
      strings - the array of items This operation will fail when an item is null or could not be added in the OS.
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the items array is null
      • ERROR_INVALID_ARGUMENT - if an item in the items array 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
    • setMinimumWidth

      public void setMinimumWidth(int width)
      Sets the minimum width of the list.
      Parameters:
      width - the minimum width of the list