Eclipse Platform
2.0

org.eclipse.swt.custom
Class TableTreeItem

java.lang.Object
  |
  +--org.eclipse.swt.widgets.Widget
        |
        +--org.eclipse.swt.widgets.Item
              |
              +--org.eclipse.swt.custom.TableTreeItem

public class TableTreeItem
extends Item

A TableTreeItem is a selectable user interface object that represents an item in a heirarchy of items in a TableTree.


Constructor Summary
TableTreeItem(TableTree parent, int style)
          Constructs a new instance of this class given its parent (which must be a TableTree) and a style value describing its behavior and appearance.
TableTreeItem(TableTree parent, int style, int index)
          Constructs a new instance of this class given its parent (which must be a TableTree, a style value describing its behavior and appearance, and the index at which to place it in the items maintained by its parent.
TableTreeItem(TableTreeItem parent, int style)
          Constructs a new instance of this class given its parent (which must be a TableTreeItem) and a style value describing its behavior and appearance.
TableTreeItem(TableTreeItem parent, int style, int index)
          Constructs a new instance of this class given its parent (which must be a TableTreeItem), a style value describing its behavior and appearance, and the index at which to place it in the items maintained by its parent.
 
Method Summary
 void dispose()
          Disposes of the operating system resources associated with the receiver and all its descendents.
 Color getBackground()
          Returns the receiver's background color.
 Rectangle getBounds(int index)
          Returns a rectangle describing the receiver's size and location relative to its parent.
 boolean getChecked()
          Returns true if the receiver is checked, and false otherwise.
 Display getDisplay()
          Returns the Display that is associated with the receiver.
 boolean getExpanded()
          Returns true if the receiver is expanded, and false otherwise.
 Color getForeground()
          Returns the foreground color that the receiver will use to draw.
 Image getImage()
          Gets the first image.
 Image getImage(int index)
          Gets the image at the specified index.
 int getItemCount()
          Returns the number of items contained in the receiver that are direct item children of the receiver.
 TableTreeItem[] getItems()
          Returns an array of TableTreeItems which are the direct item children of the receiver.
 TableTree getParent()
          Returns the receiver's parent, which must be a TableTree.
 TableTreeItem getParentItem()
          Returns the receiver's parent item, which must be a TableTreeItem or null when the receiver is a root.
 String getText()
          Returns the receiver's text, which will be an empty string if it has never been set.
 String getText(int index)
          Gets the item text at the specified index.
 int indexOf(TableTreeItem item)
          Gets the index of the specified item.
 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 item if the argument is null.
 void setChecked(boolean checked)
          Sets the checked state.
 void setExpanded(boolean expanded)
          Sets the expanded state.
 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 item if the argument is null.
 void setImage(Image image)
          Sets the first image.
 void setImage(int index, Image image)
          Sets the image at an index.
 void setText(int index, String text)
          Sets the widget text.
 void setText(String string)
          Sets the receiver's text.
 
Methods inherited from class org.eclipse.swt.widgets.Item
checkSubclass
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, getData, getData, getStyle, isDisposed, 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

TableTreeItem

public TableTreeItem(TableTree parent,
                     int style)
Constructs a new instance of this class given its parent (which must be a TableTree) and a style value describing its behavior and appearance. The item is added to the end of the items maintained by its parent.

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
Throws:
IllegalArgumentException -
SWTException -
See Also:
SWT, Widget.getStyle()

TableTreeItem

public TableTreeItem(TableTree parent,
                     int style,
                     int index)
Constructs a new instance of this class given its parent (which must be a TableTree, a style value describing its behavior and appearance, and the index at which to place it in the items maintained by its parent.

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
index - the index to store the receiver in its parent
Throws:
IllegalArgumentException -
SWTException -
See Also:
SWT, Widget.getStyle()

TableTreeItem

public TableTreeItem(TableTreeItem parent,
                     int style)
Constructs a new instance of this class given its parent (which must be a TableTreeItem) and a style value describing its behavior and appearance. The item is added to the end of the items maintained by its parent.

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:
style - the style of control to construct
Throws:
IllegalArgumentException -
SWTException -
See Also:
SWT, Widget.getStyle()

TableTreeItem

public TableTreeItem(TableTreeItem parent,
                     int style,
                     int index)
Constructs a new instance of this class given its parent (which must be a TableTreeItem), a style value describing its behavior and appearance, and the index at which to place it in the items maintained by its parent.

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:
style - the style of control to construct
index - the index to store the receiver in its parent
Throws:
IllegalArgumentException -
SWTException -
See Also:
SWT, Widget.getStyle()
Method Detail

getBackground

public Color getBackground()
Returns the receiver's background color.

Returns:
the background color
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
Since:
2.0

getBounds

public Rectangle getBounds(int index)
Returns a rectangle describing the receiver's size and location relative to its parent.

Returns:
the receiver's bounding rectangle
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

getChecked

public boolean getChecked()
Returns true if the receiver is checked, and false otherwise. When the parent does not have the CHECK style, return false.

Returns:
the checked state
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

getDisplay

public Display getDisplay()
Description copied from class: Widget
Returns the Display that is associated with the receiver.

A widget's display is either provided when it is created (for example, top level Shells) or is the same as its parent's display.

Specified by:
getDisplay in class Widget
Returns:
the receiver's display

getExpanded

public boolean getExpanded()
Returns true if the receiver is expanded, and false otherwise.

Returns:
the expanded state

getForeground

public Color getForeground()
Returns the foreground color that the receiver will use to draw.

Returns:
the receiver's foreground color
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
Since:
2.0

getImage

public Image getImage()
Gets the first image.

The image in column 0 is reserved for the [+] and [-] images of the tree, therefore getImage(0) will return null.

Overrides:
getImage in class Item
Returns:
the image at index 0
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

getImage

public Image getImage(int index)
Gets the image at the specified index.

Indexing is zero based. The image can be null. The image in column 0 is reserved for the [+] and [-] images of the tree, therefore getImage(0) will return null. Return null if the index is out of range.

Parameters:
index - the index of the image
Returns:
the image at the specified index or null

getItemCount

public int getItemCount()
Returns the number of items contained in the receiver that are direct item children of the receiver.

Returns:
the number of items

getItems

public TableTreeItem[] getItems()
Returns an array of TableTreeItems which are the direct item children of 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 receiver's items

getParent

public TableTree getParent()
Returns the receiver's parent, which must be a TableTree.

Returns:
the receiver's parent

getParentItem

public TableTreeItem getParentItem()
Returns the receiver's parent item, which must be a TableTreeItem or null when the receiver is a root.

Returns:
the receiver's parent item

getText

public String getText()
Description copied from class: Item
Returns the receiver's text, which will be an empty string if it has never been set.

Overrides:
getText in class Item
Returns:
the receiver's text

getText

public String getText(int index)
Gets the item text at the specified index.

Indexing is zero based. This operation will fail when the index is out of range or an item could not be queried from the OS.

Parameters:
index - the index of the item
Returns:
the item text at the specified index, which can be null

indexOf

public int indexOf(TableTreeItem item)
Gets the index of the specified 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 if the item is not found

dispose

public void dispose()
Description copied from class: Widget
Disposes of the operating system resources associated with the receiver and all its descendents. After this method has been invoked, the receiver and all descendents will answer true when sent the message isDisposed(). Any internal connections between the widgets in the tree will have been removed to facilitate garbage collection.

NOTE: This method is not called recursively on the descendents of the receiver. This means that, widget implementers can not detect when a widget is being disposed of by re-implementing this method, but should instead listen for the Dispose event.

Overrides:
dispose in class Widget
See Also:
Widget.addDisposeListener(org.eclipse.swt.events.DisposeListener), Widget.removeDisposeListener(org.eclipse.swt.events.DisposeListener), Widget.checkWidget()

setBackground

public 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 item if the argument is null.

Parameters:
color - the new color (or null)
Throws:
IllegalArgumentException -
  • ERROR_INVALID_ARGUMENT - if the argument has been disposed
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
Since:
2.0

setChecked

public void setChecked(boolean checked)
Sets the checked state.

Parameters:
checked - the new checked state.
Throws:
SWTError -
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed

setExpanded

public void setExpanded(boolean expanded)
Sets the expanded state.

Parameters:
expanded - the new expanded state.
Throws:
SWTError -
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed

setForeground

public 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 item if the argument is null.

Parameters:
color - the new color (or null)
Throws:
IllegalArgumentException -
  • ERROR_INVALID_ARGUMENT - if the argument has been disposed
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
Since:
2.0
, 2.0

setImage

public void setImage(int index,
                     Image image)
Sets the image at an index.

The image can be null. The image in column 0 is reserved for the [+] and [-] images of the tree, therefore do nothing if index is 0.

Parameters:
image - the new image or null
Throws:
SWTError -
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed

setImage

public void setImage(Image image)
Sets the first image.

The image can be null. The image in column 0 is reserved for the [+] and [-] images of the tree, therefore do nothing.

Overrides:
setImage in class Item
Parameters:
image - the new image or null
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 string is null

setText

public void setText(int index,
                    String text)
Sets the widget text.

The widget text for an item is the label of the item or the label of the text specified by a column number.

Parameters:
index - the column number
text - the new text
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 string is null

setText

public void setText(String string)
Description copied from class: Item
Sets the receiver's text.

Overrides:
setText in class Item
Parameters:
string - the new text

Eclipse Platform
2.0

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