Eclipse Platform
2.0

org.eclipse.swt.custom
Class TableTree

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.swt.custom.TableTree
All Implemented Interfaces:
Drawable

public class TableTree
extends Composite

A TableTree is a selectable user interface object that displays a hierarchy of items, and issues notification when an item is selected. A TableTree may be single or multi select.

The item children that may be added to instances of this class must be of type TableTreeItem.

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

Styles:
SINGLE, MULTI, CHECK, FULL_SELECTION
Events:
Selection, DefaultSelection, Collapse, Expand

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


Field Summary
 
Fields inherited from class org.eclipse.swt.widgets.Control
handle
 
Constructor Summary
TableTree(Composite parent, int style)
          Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.
 
Method Summary
 void addSelectionListener(SelectionListener listener)
          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.
 void addTreeListener(TreeListener listener)
          Adds the listener to receive tree events.
 Point computeSize(int wHint, int hHint)
          Returns the preferred size of the receiver.
 Rectangle computeTrim(int x, int y, int width, int height)
          Given a desired client area for the receiver (as described by the arguments), returns the bounding rectangle which would be required to produce that client area.
 void deselectAll()
          Deselects all items.
 Color getBackground()
          Returns the receiver's background color.
 Font getFont()
          Returns the font that the receiver will use to paint textual information.
 Color getForeground()
          Returns the foreground color that the receiver will use to draw.
 TableTreeItem getItem(Point point)
          Returns the item at the given point in the receiver or null if no such item exists.
 int getItemCount()
          Gets the number of items.
 int getItemHeight()
          Gets the height of one item.
 TableTreeItem[] getItems()
          Gets the items.
 TableTreeItem[] getSelection()
          Gets the selected items.
 int getSelectionCount()
          Gets the number of selected items.
 Table getTable()
          Returns the underlying Table control.
 int indexOf(TableTreeItem item)
          Gets the index of an item.
 void removeAll()
          Removes all items.
 void removeSelectionListener(SelectionListener listener)
          Removes the listener.
 void removeTreeListener(TreeListener listener)
          Removes the listener.
 void selectAll()
          Selects all items.
 void setBackground(Color color)
          Sets the receiver's background color to the color specified by the argument, or to the default system color for the control if the argument is null.
 void setEnabled(boolean enabled)
          Enables the receiver if the argument is true, and disables it otherwise.
 void setFont(Font font)
          Sets the font that the receiver will use to paint textual information to the font specified by the argument, or to the default font for that kind of control if the argument is null.
 void setForeground(Color color)
          Sets the receiver's foreground color to the color specified by the argument, or to the default system color for the control if the argument is null.
 void setMenu(Menu menu)
          Sets the receiver's pop up menu to the argument.
 void setSelection(TableTreeItem[] items)
          Sets the selection.
 void setToolTipText(String string)
          Sets the receiver's tool tip text to the argument, which may be null indicating that no tool tip text should be shown.
 void showItem(TableTreeItem item)
          Shows the item.
 void showSelection()
          Shows the selection.
 
Methods inherited from class org.eclipse.swt.widgets.Composite
checkSubclass, computeSize, getChildren, getLayout, getTabList, layout, layout, setFocus, setLayout, setTabList
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
getClientArea, getHorizontalBar, getVerticalBar
 
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addFocusListener, addHelpListener, addKeyListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addPaintListener, addTraverseListener, forceFocus, getAccessible, getBorderWidth, getBounds, getDisplay, getEnabled, getLayoutData, getLocation, getMenu, getParent, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isDisposed, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, redraw, redraw, removeControlListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removePaintListener, removeTraverseListener, setBounds, setBounds, setCapture, setCursor, setLayoutData, setLocation, setLocation, setParent, setRedraw, setSize, setSize, setVisible, toControl, toDisplay, traverse, update
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getStyle, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TableTree

public TableTree(Composite parent,
                 int style)
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 widget which will be the parent of the new instance (cannot be null)
style - the style of widget to construct
Throws:
IllegalArgumentException -
SWTException -
See Also:
SWT.SINGLE, SWT.MULTI, SWT.CHECK, SWT.FULL_SELECTION, Widget.getStyle()
Method Detail

addSelectionListener

public void addSelectionListener(SelectionListener listener)
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.

When widgetSelected is called, the item field of the event object is valid. If the reciever has SWT.CHECK style set and the check selection changes, the event object detail field contains the value SWT.CHECK. widgetDefaultSelected is typically called when an item is double-clicked. The item field of the event object is valid for default selection, but the detail field is not used.

Parameters:
listener - the listener which should be notified
Throws:
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the listener is null
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
See Also:
SelectionListener, removeSelectionListener(org.eclipse.swt.events.SelectionListener), SelectionEvent

addTreeListener

public void addTreeListener(TreeListener listener)
Adds the listener to receive tree events.

Parameters:
listener - the tree listener
Throws:
SWTError -
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
  • ERROR_NULL_ARGUMENT when listener is null

computeSize

public Point computeSize(int wHint,
                         int hHint)
Description copied from class: Control
Returns the preferred size of the receiver.

The preferred size of a control is the size that it would best be displayed at. The width hint and height hint arguments allow the caller to ask a control questions such as "Given a particular width, how high does the control need to be to show all of the contents?" To indicate that the caller does not wish to constrain a particular dimension, the constant SWT.DEFAULT is passed for the hint.

Overrides:
computeSize in class Control
Parameters:
wHint - the width hint (can be SWT.DEFAULT)
hHint - the height hint (can be SWT.DEFAULT)
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"

computeTrim

public Rectangle computeTrim(int x,
                             int y,
                             int width,
                             int height)
Description copied from class: Scrollable
Given a desired client area for the receiver (as described by the arguments), returns the bounding rectangle which would be required to produce that client area.

In other words, it returns a rectangle such that, if the receiver's bounds were set to that rectangle, the area of the receiver which is capable of displaying data (that is, not covered by the "trimmings") would be the rectangle described by the arguments (relative to the receiver's parent).

Overrides:
computeTrim in class Scrollable
Returns:
the required bounds to produce the given client area
See Also:
Scrollable.getClientArea()

deselectAll

public void deselectAll()
Deselects all items.

If an item is selected, it is deselected. If an item is not selected, it remains unselected.

Throws:
SWTError -
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed

getBackground

public Color getBackground()
Description copied from class: Control
Returns the receiver's background color.

Overrides:
getBackground in class Control
Returns:
the background color

getForeground

public Color getForeground()
Description copied from class: Control
Returns the foreground color that the receiver will use to draw.

Overrides:
getForeground in class Control
Returns:
the receiver's foreground color

getFont

public Font getFont()
Description copied from class: Control
Returns the font that the receiver will use to paint textual information.

Overrides:
getFont in class Control
Returns:
the receiver's font

getItemCount

public int getItemCount()
Gets the number of items.

Returns:
the number of items in the widget

getItemHeight

public int getItemHeight()
Gets the height of one item.

This operation will fail if the height of one item could not be queried from the OS.

Returns:
the height of one item in the widget
Throws:
SWTError -
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
  • ERROR_CANNOT_GET_ITEM_HEIGHT when the operation fails

getItems

public TableTreeItem[] getItems()
Gets the items.

Returns:
the items in the widget

getSelection

public TableTreeItem[] getSelection()
Gets the selected items.

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

Returns:
the selected items in the widget
Throws:
SWTError -
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
  • ERROR_CANNOT_GET_SELECTION when the operation fails

getSelectionCount

public int getSelectionCount()
Gets the number of selected items.

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

Returns:
the number of selected items in the widget
Throws:
SWTError -
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
  • ERROR_CANNOT_GET_COUNT when the operation fails

getTable

public Table getTable()
Returns the underlying Table control.

Returns:
the underlying Table control

indexOf

public int indexOf(TableTreeItem item)
Gets the index of an item.

The widget 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. This index is relative to the parent only.

Parameters:
item - the search item
Returns:
the index of the item or -1

getItem

public TableTreeItem getItem(Point point)
Returns the item at the given point in the receiver or null if no such item exists. The point is in the coordinate system of the receiver.

Parameters:
point - the point used to locate the item
Returns:
the item at the given point
Throws:
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the listener is null
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()
Removes all items.

This operation will fail when an item could not be removed in the OS.

Throws:
SWTError -
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
  • ERROR_ITEM_NOT_REMOVED when the operation fails

removeSelectionListener

public void removeSelectionListener(SelectionListener listener)
Removes the listener.

Parameters:
listener - the listener
Throws:
SWTError -
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
  • ERROR_NULL_ARGUMENT when listener is null

removeTreeListener

public void removeTreeListener(TreeListener listener)
Removes the listener.

Parameters:
listener - the listener
Throws:
SWTError -
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
  • ERROR_NULL_ARGUMENT when listener is null

selectAll

public void selectAll()
Selects all items.

If an item is not selected, it is selected. If an item is selected, it remains selected.

Throws:
SWTError -
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed

setBackground

public void setBackground(Color color)
Description copied from class: Control
Sets the receiver's background color to the color specified by the argument, or to the default system color for the control if the argument is null.

Overrides:
setBackground in class Control
Parameters:
color - the new color (or null)

setEnabled

public void setEnabled(boolean enabled)
Description copied from class: Control
Enables the receiver if the argument is true, and disables it otherwise. A disabled control is typically not selectable from the user interface and draws with an inactive or "grayed" look.

Overrides:
setEnabled in class Control
Parameters:
enabled - the new enabled state

setFont

public void setFont(Font font)
Description copied from class: Control
Sets the font that the receiver will use to paint textual information to the font specified by the argument, or to the default font for that kind of control if the argument is null.

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

setForeground

public void setForeground(Color color)
Description copied from class: Control
Sets the receiver's foreground color to the color specified by the argument, or to the default system color for the control if the argument is null.

Overrides:
setForeground in class Control
Parameters:
color - the new color (or null)

setMenu

public void setMenu(Menu menu)
Description copied from class: Control
Sets the receiver's pop up menu to the argument. All controls may optionally have a pop up menu that is displayed when the user requests one for the control. The sequence of key strokes, button presses and/or button releases that are used to request a pop up menu is platform specific.

Overrides:
setMenu in class Control
Parameters:
menu - the new pop up menu

setSelection

public void setSelection(TableTreeItem[] items)
Sets the selection.

Parameters:
items - new selection
Throws:
SWTError -
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
  • ERROR_NULL_ARGUMENT when items is null

setToolTipText

public void setToolTipText(String string)
Description copied from class: Control
Sets the receiver's tool tip text to the argument, which may be null indicating that no tool tip text should be shown.

Overrides:
setToolTipText in class Control
Parameters:
string - the new tool tip text (or null)

showItem

public void showItem(TableTreeItem item)
Shows the item.

Parameters:
item - the item to be shown
Throws:
SWTError -
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
  • ERROR_NULL_ARGUMENT when item is null

showSelection

public void showSelection()
Shows the selection.

If there is no selection or the selection is already visible, this method does nothing. If the selection is scrolled out of view, the top index of the widget is changed such that selection becomes visible.

Throws:
SWTError -
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed

Eclipse Platform
2.0

Copyright (c) IBM Corp. and others 2000, 2002. All Rights Reserved.