org.eclipse.swt.widgets
Class List

java.lang.Object
  |
  +--org.eclipse.swt.widgets.Widget
        |
        +--org.eclipse.swt.widgets.Control
              |
              +--org.eclipse.swt.widgets.Scrollable
                    |
                    +--org.eclipse.swt.widgets.List
All Implemented Interfaces:
Drawable

public class List
extends Scrollable

Safe: Instances of this class represent a selectable user interface object that displays a list of strings and issues notificiation when a string selected. A list may be single or multi select.

Styles:
SINGLE, MULTI
Events:
Selection, DefaultSelection

Note: Only one of SINGLE and MULTI may be specified.

IMPORTANT: This class is not intended to be subclassed.


Field Summary
(package private) static org.eclipse.swt.internal.win32.TCHAR ListClass
           
(package private) static int ListProc
           
 
Fields inherited from class org.eclipse.swt.widgets.Scrollable
horizontalBar, verticalBar
 
Fields inherited from class org.eclipse.swt.widgets.Control
ACCENTS, accessible, background, drawCount, foreground, handle, hCursor, layoutData, menu, parent, toolTipText
 
Fields inherited from class org.eclipse.swt.widgets.Widget
CANVAS, COMCTL32_MAJOR, COMCTL32_MINOR, data, DEFAULT_HEIGHT, DEFAULT_WIDTH, DISABLED, DISPOSED, eventTable, HIDDEN, keys, MAJOR, MINOR, Mnemonic, state, style, values
 
Constructor Summary
List(Composite parent, int style)
          Enabled: Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.
 
Method Summary
 void add(String string)
          Enabled: Adds the argument to the end of the receiver's list.
 void add(String string, int index)
          Enabled: Adds the argument to the receiver's list at the given zero-relative index.
 void addSelectionListener(SelectionListener listener)
          Enabled: Adds the listener to the collection of listeners who will be notified when the receiver's selection changes, by sending it one of the messages defined in the SelectionListener interface.
(package private)  int callWindowProc(int msg, int wParam, int lParam)
           
(package private) static int checkStyle(int style)
           
 Point computeSize(int wHint, int hHint, boolean changed)
          Enabled:
(package private)  int defaultBackground()
           
 void deselect(int index)
          Enabled: Deselects the item at the given zero-relative index in the receiver.
 void deselect(int[] indices)
          Enabled: Deselects the items at the given zero-relative indices in the receiver.
 void deselect(int start, int end)
          Enabled: Deselects the items at the given zero-relative indices in the receiver.
 void deselectAll()
          Enabled: Deselects all selected items in the receiver.
 int getFocusIndex()
          Enabled: Returns the zero-relative index of the item which is currently has the focus in the receiver, or -1 if no item is has focus.
 String getItem(int index)
          Enabled: Returns the item at the given, zero-relative index in the receiver.
 int getItemCount()
          Enabled: Returns the number of items contained in the receiver.
 int getItemHeight()
          Enabled: Returns the height of the area which would be used to display one of the items in the tree.
 String[] getItems()
          Enabled: Returns an array of Strings which are the items in the receiver.
 String[] getSelection()
          Enabled: Returns an array of Strings that are currently selected in the receiver.
 int getSelectionCount()
          Enabled: Returns the number of selected items contained in the receiver.
 int getSelectionIndex()
          Enabled: Returns the zero-relative index of the item which is currently selected in the receiver, or -1 if no item is selected.
 int[] getSelectionIndices()
          Enabled: Returns the zero-relative indices of the items which are currently selected in the receiver.
 int getTopIndex()
          Enabled: Returns the zero-relative index of the item which is currently at the top of the receiver.
 int indexOf(String string)
          Enabled: Gets the index of an item.
 int indexOf(String string, int start)
          Enabled: Searches the receiver's list starting at the given, zero-relative index until an item is found that is equal to the argument, and returns the index of that item.
 boolean isSelected(int index)
          Enabled: Returns true if the item is selected, and false otherwise.
 void remove(int index)
          Enabled: Removes the item from the receiver at the given zero-relative index.
 void remove(int[] indices)
          Enabled: Removes the items from the receiver at the given zero-relative indices.
 void remove(int start, int end)
          Enabled: Removes the items from the receiver which are between the given zero-relative start and end indices (inclusive).
 void remove(String string)
          Enabled: 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()
          Enabled: Removes all of the items from the receiver.
 void removeSelectionListener(SelectionListener listener)
          Enabled: Removes the listener from the collection of listeners who will be notified when the receiver's selection changes.
 void select(int index)
          Enabled: Selects the item at the given zero-relative index in the receiver's list.
 void select(int[] indices)
          Enabled: Selects the items at the given zero-relative indices in the receiver.
(package private)  void select(int[] indices, boolean scroll)
           
(package private)  void select(int index, boolean scroll)
           
 void select(int start, int end)
          Enabled: Selects the items at the given zero-relative indices in the receiver.
(package private)  void select(int start, int end, boolean scroll)
           
 void selectAll()
          Enabled: Selects all the items in the receiver.
(package private)  void setBounds(int x, int y, int width, int height, int flags)
           
(package private)  void setFocusIndex(int index)
           
 void setFont(Font font)
          Enabled:
 void setItem(int index, String string)
          Enabled: Sets the text of the item in the receiver's list at the given zero-relative index to the string argument.
 void setItems(String[] items)
          Enabled: Sets the receiver's items to be the given array of items.
(package private)  void setScrollWidth()
           
(package private)  void setScrollWidth(int newWidth, boolean grow)
           
(package private)  void setScrollWidth(org.eclipse.swt.internal.win32.TCHAR buffer, boolean grow)
           
 void setSelection(int index)
          Enabled: Selects the item at the given zero-relative index in the receiver.
 void setSelection(int[] indices)
          Enabled: Selects the items at the given zero-relative indices in the receiver.
 void setSelection(int start, int end)
          Enabled: Selects the items at the given zero-relative indices in the receiver.
 void setSelection(String[] items)
          Enabled: Sets the receiver's selection to be the given array of items.
 void setTopIndex(int index)
          Enabled: Sets the zero-relative index of the item which is currently at the top of the receiver.
 void showSelection()
          Enabled: Shows the selection.
(package private)  int widgetStyle()
           
(package private)  org.eclipse.swt.internal.win32.TCHAR windowClass()
           
(package private)  int windowProc()
           
(package private)  org.eclipse.swt.internal.win32.LRESULT wmCommandChild(int wParam, int lParam)
           
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, createScrollBar, createWidget, getClientArea, getHorizontalBar, getVerticalBar, releaseWidget, widgetExtStyle, WM_HSCROLL, WM_MOUSEWHEEL, WM_SIZE, WM_VSCROLL, wmScroll
 
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addFocusListener, addHelpListener, addKeyListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addPaintListener, addTraverseListener, checkOrientation, computeSize, computeTabGroup, computeTabList, computeTabRoot, createHandle, defaultFont, defaultForeground, deregister, destroyWidget, drawBackground, drawBackground, findBrush, findCursor, findMnemonic, fixFocus, forceFocus, forceResize, getAccessible, getBackground, getBackgroundPixel, getBorderWidth, getBounds, getCodePage, getDisplay, getEnabled, getFont, getForeground, getForegroundPixel, getLayoutData, getLocation, getMenu, getParent, getPath, getShell, getSize, getToolTipText, getVisible, hasCursor, hasFocus, internal_dispose_GC, internal_new_GC, isActive, isDisposed, isEnabled, isFocusAncestor, isFocusControl, isReparentable, isShowing, isTabGroup, isTabItem, isVisible, menuShell, mnemonicHit, mnemonicMatch, moveAbove, moveBelow, new_Accessible, pack, pack, redraw, redraw, register, releaseHandle, removeControlListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removePaintListener, removeTraverseListener, sendKeyEvent, sendKeyEvent, sendMouseEvent, sendMouseEvent, setBackground, setBackgroundPixel, setBounds, setBounds, setCapture, setCursor, setDefaultFont, setEnabled, setFocus, setForeground, setForegroundPixel, setLayoutData, setLocation, setLocation, setMenu, setParent, setRadioFocus, setRadioSelection, setRedraw, setSavedFocus, setSize, setSize, setTabGroupFocus, setTabItemFocus, setToolTipText, setVisible, sort, subclass, toControl, toControl, toDisplay, toDisplay, transferActive, transferFocus, translateAccelerator, translateMnemonic, translateMnemonic, translateTraversal, traverse, traverse, traverseEscape, traverseGroup, traverseItem, traverseMnemonic, traversePage, traverseReturn, unsubclass, update, update, updateFont, windowProc, WM_ACTIVATE, WM_CHAR, WM_CLEAR, WM_CLOSE, WM_COMMAND, WM_CONTEXTMENU, WM_CTLCOLOR, WM_CUT, WM_DESTROY, WM_DRAWITEM, WM_ENDSESSION, WM_ERASEBKGND, WM_GETDLGCODE, WM_GETFONT, WM_GETOBJECT, WM_HELP, WM_HOTKEY, WM_IME_CHAR, WM_IME_COMPOSITION, WM_INITMENUPOPUP, WM_KEYDOWN, WM_KEYUP, WM_KILLFOCUS, WM_LBUTTONDBLCLK, WM_LBUTTONDOWN, WM_LBUTTONUP, WM_MBUTTONDBLCLK, WM_MBUTTONDOWN, WM_MBUTTONUP, WM_MEASUREITEM, WM_MENUCHAR, WM_MENUSELECT, WM_MOUSEACTIVATE, WM_MOUSEHOVER, WM_MOUSELEAVE, WM_MOUSEMOVE, WM_MOVE, WM_NCACTIVATE, WM_NCCALCSIZE, WM_NCHITTEST, WM_NOTIFY, WM_PAINT, WM_PALETTECHANGED, WM_PASTE, WM_PRINTCLIENT, WM_QUERYENDSESSION, WM_QUERYNEWPALETTE, WM_QUERYOPEN, WM_RBUTTONDBLCLK, WM_RBUTTONDOWN, WM_RBUTTONUP, WM_SETCURSOR, WM_SETFOCUS, WM_SETFONT, WM_SETREDRAW, WM_SETTINGCHANGE, WM_SHOWWINDOW, WM_SYSCHAR, WM_SYSCOLORCHANGE, WM_SYSCOMMAND, WM_SYSKEYDOWN, WM_SYSKEYUP, WM_TIMER, WM_UNDO, WM_WINDOWPOSCHANGING, wmColorChild, wmDrawChild, wmMeasureChild, wmNotifyChild, wmScrollChild
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkBits, checkParent, checkSubclass, checkWidget, dispose, error, filters, getData, getData, getName, getNameText, getStyle, hooks, isListening, isValidSubclass, isValidThread, mbcsToWcs, mbcsToWcs, notifyListeners, postEvent, postEvent, releaseChild, releaseResources, removeDisposeListener, removeListener, removeListener, sendEvent, sendEvent, sendEvent, sendEvent, setData, setData, setInputState, setKeyState, toString, wcsToMbcs, wcsToMbcs
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ListProc

static final int ListProc

ListClass

static final org.eclipse.swt.internal.win32.TCHAR ListClass
Constructor Detail

List

public List(Composite parent,
            int style)
Enabled: Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.

The style value is either one of the style constants defined in class SWT which is applicable to instances of this class, or must be built by bitwise OR'ing together (that is, using the int "|" operator) two or more of those SWT style constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses.

Parameters:
parent - a composite control which will be the parent of the new instance (cannot be null)
style - the style of control to construct
See Also:
SWT.SINGLE, SWT.MULTI, Widget.checkSubclass(), Widget.getStyle()
Method Detail

add

public void add(String string)
Enabled: Adds the argument to the end of the receiver's list.

Parameters:
string - the new item
See Also:
add(String,int)

add

public void add(String string,
                int index)
Enabled: Adds the argument to the receiver's list at the given zero-relative index.

Note: To add an item at the end of the list, use the result of calling getItemCount() as the index or use add(String).

Parameters:
string - the new item
index - the index for the item
See Also:
add(String)

addSelectionListener

public void addSelectionListener(SelectionListener listener)
Enabled: Adds the listener to the collection of listeners who will be notified when the receiver's selection changes, by sending it one of the messages defined in the SelectionListener interface.

widgetSelected is called when the selection changes. widgetDefaultSelected is typically called when an item is double-clicked.

Parameters:
listener - the listener which should be notified
See Also:
SelectionListener, removeSelectionListener(org.eclipse.swt.events.SelectionListener), SelectionEvent

callWindowProc

int callWindowProc(int msg,
                   int wParam,
                   int lParam)
Overrides:
callWindowProc in class Scrollable

checkStyle

static int checkStyle(int style)

computeSize

public Point computeSize(int wHint,
                         int hHint,
                         boolean changed)
Enabled:

Overrides:
computeSize in class Control
Parameters:
wHint - the width hint (can be SWT.DEFAULT)
hHint - the height hint (can be SWT.DEFAULT)
changed - true if the control's contents have changed, and false otherwise
Returns:
the preferred size of the control.
See Also:
Layout, Control.getBorderWidth(), Control.getBounds(), Control.getSize(), Control.pack(), "computeTrim, getClientArea for controls that implement them"

defaultBackground

int defaultBackground()
Overrides:
defaultBackground in class Control

deselect

public void deselect(int[] indices)
Enabled: Deselects the items at the given zero-relative indices in the receiver. If the item at the given zero-relative index in the receiver is selected, it is deselected. If the item at the index was not selected, it remains deselected. Indices that are out of range and duplicate indices are ignored.

Parameters:
indices - the array of indices for the items to deselect

deselect

public void deselect(int index)
Enabled: Deselects the item at the given zero-relative index in the receiver. 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

deselect

public void deselect(int start,
                     int end)
Enabled: Deselects the items at the given zero-relative indices in the receiver. If the item at the given zero-relative index in the receiver is selected, it is deselected. If the item at the index was not selected, it remains deselected. The range of the indices is inclusive. Indices that are out of range are ignored.

Parameters:
start - the start index of the items to deselect
end - the end index of the items to deselect

deselectAll

public void deselectAll()
Enabled: Deselects all selected items in the receiver.


getFocusIndex

public int getFocusIndex()
Enabled: Returns the zero-relative index of the item which is currently has the focus in the receiver, or -1 if no item is has focus.

Returns:
the index of the selected item

getItem

public String getItem(int index)
Enabled: Returns the item at the given, zero-relative index in the receiver. 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

getItemCount

public int getItemCount()
Enabled: Returns the number of items contained in the receiver.

Returns:
the number of items

getItemHeight

public int getItemHeight()
Enabled: Returns the height of the area which would be used to display one of the items in the tree.

Returns:
the height of one item

getItems

public String[] getItems()
Enabled: Returns an array of Strings which are the items in the receiver.

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

getSelection

public String[] getSelection()
Enabled: Returns an array of Strings that are currently selected in the receiver. 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

getSelectionCount

public int getSelectionCount()
Enabled: Returns the number of selected items contained in the receiver.

Returns:
the number of selected items

getSelectionIndex

public int getSelectionIndex()
Enabled: Returns the zero-relative index of the item which is currently selected in the receiver, or -1 if no item is selected.

Returns:
the index of the selected item

getSelectionIndices

public int[] getSelectionIndices()
Enabled: Returns the zero-relative indices of the items which are currently selected in the receiver. 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

getTopIndex

public int getTopIndex()
Enabled: Returns the zero-relative index of the item which is currently at the top of the receiver. This index can change when items are scrolled or new items are added or removed.

Returns:
the index of the top item

indexOf

public int indexOf(String string)
Enabled: Gets the index of an item.

The list is searched starting at 0 until an item is found that is equal to the search item. If no item is found, -1 is returned. Indexing is zero based.

Parameters:
string - the search item
Returns:
the index of the item

indexOf

public int indexOf(String string,
                   int start)
Enabled: Searches the receiver's list starting at the given, zero-relative index until an item is found that is equal to the argument, and returns the index of that item. If no item is found or the starting index is out of range, returns -1.

Parameters:
string - the search item
Returns:
the index of the item

isSelected

public boolean isSelected(int index)
Enabled: Returns true if the item is selected, and false otherwise. Indices out of range are ignored.

Parameters:
index - the index of the item
Returns:
the visibility state of the item at the index

remove

public void remove(int[] indices)
Enabled: Removes the items from the receiver at the given zero-relative indices.

Parameters:
indices - the array of indices of the items

remove

public void remove(int index)
Enabled: Removes the item from the receiver at the given zero-relative index.

Parameters:
index - the index for the item

remove

public void remove(int start,
                   int end)
Enabled: Removes the items from the receiver which are between the given zero-relative start and end indices (inclusive).

Parameters:
start - the start of the range
end - the end of the range

remove

public void remove(String string)
Enabled: 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:
string - the item to remove

removeAll

public void removeAll()
Enabled: Removes all of the items from the receiver.


removeSelectionListener

public void removeSelectionListener(SelectionListener listener)
Enabled: Removes the listener from the collection of listeners who will be notified when the receiver's selection changes.

Parameters:
listener - the listener which should no longer be notified
See Also:
SelectionListener, addSelectionListener(org.eclipse.swt.events.SelectionListener)

select

public void select(int[] indices)
Enabled: Selects the items at the given zero-relative indices in the receiver. If the item at the given zero-relative index in the receiver is not selected, it is selected. If the item at the index was selected, it remains selected. Indices that are out of range and duplicate indices are ignored.

Parameters:
indices - the array of indices for the items to select

select

void select(int[] indices,
            boolean scroll)

select

public void select(int index)
Enabled: 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.

Parameters:
index - the index of the item to select

select

void select(int index,
            boolean scroll)

select

public void select(int start,
                   int end)
Enabled: Selects the items at the given zero-relative indices in the receiver. If the item at the index was already selected, it remains selected. The range of the indices is inclusive. Indices that are out of range are ignored and no items will be selected if start is greater than end.

Parameters:
start - the start of the range
end - the end of the range

select

void select(int start,
            int end,
            boolean scroll)

selectAll

public void selectAll()
Enabled: Selects all the items in the receiver.


setBounds

void setBounds(int x,
               int y,
               int width,
               int height,
               int flags)
Overrides:
setBounds in class Control

setFocusIndex

void setFocusIndex(int index)

setFont

public void setFont(Font font)
Enabled:

Overrides:
setFont in class Control
Parameters:
font - the new font (or null)

setItem

public void setItem(int index,
                    String string)
Enabled: Sets the text of the item in the receiver's list at the given zero-relative index to the string argument. This is equivalent to remove'ing the old item at the index, and then add'ing the new item at that index.

Parameters:
index - the index for the item
string - the new text for the item

setItems

public void setItems(String[] items)
Enabled: Sets the receiver's items to be the given array of items.

Parameters:
items - the array of items

setScrollWidth

void setScrollWidth()

setScrollWidth

void setScrollWidth(org.eclipse.swt.internal.win32.TCHAR buffer,
                    boolean grow)

setScrollWidth

void setScrollWidth(int newWidth,
                    boolean grow)

setSelection

public void setSelection(int[] indices)
Enabled: Selects the items at the given zero-relative indices in the receiver. The current selection is first cleared, then the new items are selected.

Parameters:
indices - the indices of the items to select
See Also:
deselectAll(), select(int[])

setSelection

public void setSelection(String[] items)
Enabled: Sets the receiver's selection to be the given array of items. The current selected is first cleared, then the new items are selected.

Parameters:
items - the array of items
See Also:
deselectAll(), select(int)

setSelection

public void setSelection(int index)
Enabled: Selects the item at the given zero-relative index in the receiver. If the item at the index was already selected, it remains selected. The current selected is first cleared, then the new items are selected. Indices that are out of range are ignored.

Parameters:
index - the index of the item to select
See Also:
deselectAll(), select(int)

setSelection

public void setSelection(int start,
                         int end)
Enabled: Selects the items at the given zero-relative indices in the receiver. The current selection is first cleared, then the new items are selected. Indices that are out of range are ignored and no items will be selected if start is greater than end.

Parameters:
start - the start index of the items to select
end - the end index of the items to select
See Also:
Table.deselectAll(), Table.select(int,int)

setTopIndex

public void setTopIndex(int index)
Enabled: Sets the zero-relative index of the item which is currently at the top of the receiver. This index can change when items are scrolled or new items are added and removed.

Parameters:
index - the index of the top item

showSelection

public void showSelection()
Enabled: Shows the selection. If the selection is already showing in the receiver, this method simply returns. Otherwise, the items are scrolled until the selection is visible.


widgetStyle

int widgetStyle()
Overrides:
widgetStyle in class Scrollable

windowClass

org.eclipse.swt.internal.win32.TCHAR windowClass()
Overrides:
windowClass in class Scrollable

windowProc

int windowProc()
Overrides:
windowProc in class Scrollable

wmCommandChild

org.eclipse.swt.internal.win32.LRESULT wmCommandChild(int wParam,
                                                      int lParam)
Overrides:
wmCommandChild in class Control


comments?