Overview

 
Package  Use  Tree  Deprecated  Index  Help 
Eclipse Platform
Release 3.0
 PREV CLASS   NEXT CLASS FRAMES    NO FRAMES  
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD


 

org.eclipse.swt.custom
Class TableTree

java.lang.Object
  extended byorg.eclipse.swt.widgets.Widget
      extended byorg.eclipse.swt.widgets.Control
          extended byorg.eclipse.swt.widgets.Scrollable
              extended byorg.eclipse.swt.widgets.Composite
                  extended byorg.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 the collection of listeners who will be notified when an item in the receiver is expanded or collapsed by sending it one of the messages defined in the TreeListener interface.
 Point computeSize(int wHint, int hHint, boolean changed)
          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.
 Rectangle getClientArea()
          Returns a rectangle which describes the area of the receiver which is capable of displaying data (that is, not covered by the "trimmings").
 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.
 int getStyle()
          Returns the receiver's style information.
 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 from the collection of listeners who will be notified when the receiver's selection changes.
 void removeTreeListener(TreeListener listener)
          Removes the listener from the collection of listeners who will be notified when items in the receiver are expanded or collapsed..
 void selectAll()
          Selects all of the items in the receiver.
 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 receiver's selection to be the given array of items.
 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, getChildren, getLayout, getTabList, layout, layout, setFocus, setLayout, setTabList
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
getHorizontalBar, getVerticalBar
 
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addFocusListener, addHelpListener, addKeyListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addPaintListener, addTraverseListener, computeSize, forceFocus, getAccessible, getBorderWidth, getBounds, getEnabled, getLayoutData, getLocation, getMenu, getMonitor, getParent, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, 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, toControl, toDisplay, toDisplay, traverse, update
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, 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

 

 

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, 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 the collection of listeners who will be notified when an item in the receiver is expanded or collapsed by sending it one of the messages defined in the TreeListener interface.

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:
TreeListener, removeTreeListener(org.eclipse.swt.events.TreeListener)


 

 

computeSize

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

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.

If the changed flag is true, it indicates that the receiver's contents have changed, therefore any caches that a layout manager containing the control may have been keeping need to be flushed. When the control is resized, the changed flag will be false, so layout manager caches can be retained.

Overrides:
computeSize in class Composite


 

 

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

Parameters:
x - the desired x coordinate of the client area
y - the desired y coordinate of the client area
width - the desired width of the client area
height - the desired height of the client area
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


 

 

getClientArea

public Rectangle getClientArea()

Description copied from class: Scrollable
Returns a rectangle which describes the area of the receiver which is capable of displaying data (that is, not covered by the "trimmings").

Overrides:
getClientArea in class Scrollable

Returns:
the client area
See Also:
Scrollable.computeTrim(int, int, int, int)


 

 

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


 

 

getStyle

public int getStyle()

Description copied from class: Widget
Returns the receiver's style information.

Note that the value which is returned by this method may not match the value which was provided to the constructor when the receiver was created. This can occur when the underlying operating system does not support a particular combination of requested styles. For example, if the platform widget used to implement a particular SWT widget always has scroll bars, the result of calling this method would always have the SWT.H_SCROLL and SWT.V_SCROLL bits set.

Overrides:
getStyle in class Widget

Returns:
the style bits


 

 

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 point 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 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
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, addSelectionListener(org.eclipse.swt.events.SelectionListener)


 

 

removeTreeListener

public void removeTreeListener(TreeListener listener)

Removes the listener from the collection of listeners who will be notified when items in the receiver are expanded or collapsed..

Parameters:
listener - the listener which should no longer 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:
TreeListener, addTreeListener(org.eclipse.swt.events.TreeListener)


 

 

selectAll

public void selectAll()

Selects all of the items in the receiver.

If the receiver is single-select, do nothing.

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 receiver's selection to be the given array of items. The current selection is cleared before the new items are selected.

Items that are not in the receiver are ignored. If the receiver is single-select and multiple items are specified, then all items are ignored.

Parameters:
items - the array of items
Throws:
IllegalArgumentException -

  • ERROR_NULL_ARGUMENT - if the array of items is null
  • ERROR_INVALID_ARGUMENT - if one of the item 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

See Also:
deselectAll()


 

 

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. If the item is already showing in the receiver, this method simply returns. Otherwise, the items are scrolled and expanded until the item is visible.

Parameters:
item - the item to be shown
Throws:
IllegalArgumentException -

  • ERROR_NULL_ARGUMENT - if the item is null
  • ERROR_INVALID_ARGUMENT - if the item 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

See Also:
showSelection()


 

 

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


 

Overview

 
Package  Use  Tree  Deprecated  Index  Help 
Eclipse Platform
Release 3.0
 PREV CLASS   NEXT CLASS FRAMES    NO FRAMES  
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD


Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2004. All rights reserved.