org.eclipse.swt.widgets
Class Tree

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.widgets.Tree
All Implemented Interfaces:
Drawable

public class Tree
extends Composite

Safe:


Field Summary
(package private)  boolean customDraw
           
(package private)  boolean dragStarted
           
(package private)  int hAnchor
           
(package private)  boolean ignoreDeselect
           
(package private)  boolean ignoreExpand
           
(package private)  boolean ignoreSelect
           
(package private)  ImageList imageList
           
(package private)  TreeItem[] items
           
(package private) static org.eclipse.swt.internal.win32.TCHAR TreeClass
           
(package private) static int TreeProc
           
 
Fields inherited from class org.eclipse.swt.widgets.Composite
font, layout, lpwp, tabList
 
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
Tree(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 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.
 void addTreeListener(TreeListener listener)
          Enabled: 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.
(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)  void createHandle()
           
(package private)  void createItem(TreeItem item, int hParent, int hInsertAfter)
           
(package private)  void createWidget()
           
(package private)  int defaultBackground()
           
 void deselectAll()
          Enabled: Deselects all selected items in the receiver.
(package private)  void destroyItem(TreeItem item)
           
(package private)  int getBackgroundPixel()
           
(package private)  int getForegroundPixel()
           
 TreeItem getItem(Point point)
          Enabled: Returns the item at the given point in the receiver or null if no such item exists.
 int getItemCount()
          Enabled: Returns the number of items contained in the receiver that are direct item children of the receiver.
 int getItemHeight()
          Enabled: Returns the height of the area which would be used to display one of the items in the tree.
 TreeItem[] getItems()
          Enabled: Returns the number of items contained in the receiver that are direct item children of the receiver.
 TreeItem getParentItem()
          Suppressed: Returns the receiver's parent item, which must be a TreeItem or null when the receiver is a root.
 TreeItem[] getSelection()
          Enabled: Returns an array of TreeItems that are currently selected in the receiver.
 int getSelectionCount()
          Enabled: Returns the number of selected items contained in the receiver.
 TreeItem getTopItem()
          Suppressed: Returns the item which is currently at the top of the receiver.
(package private)  int imageIndex(Image image)
           
(package private)  boolean releaseItem(TreeItem item, org.eclipse.swt.internal.win32.TVITEM tvItem)
           
(package private)  void releaseItems(TreeItem[] nodes, org.eclipse.swt.internal.win32.TVITEM tvItem)
           
(package private)  void releaseWidget()
           
 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 removeTreeListener(TreeListener listener)
          Enabled: Removes the listener from the collection of listeners who will be notified when items in the receiver are expanded or collapsed..
 void selectAll()
          Enabled: Selects all the items in the receiver.
(package private)  void setBackgroundPixel(int pixel)
           
(package private)  void setBounds(int x, int y, int width, int height, int flags)
           
(package private)  void setCheckboxImageList()
           
(package private)  void setForegroundPixel(int pixel)
           
 void setInsertMark(TreeItem item, boolean before)
          Enabled: Display a mark indicating the point at which an item will be inserted.
 void setRedraw(boolean redraw)
          Enabled:
 void setSelection(TreeItem[] items)
          Enabled: Sets the receiver's selection to be the given array of items.
 void setTopItem(TreeItem item)
          Suppressed: Sets the item which is currently at the top of the receiver.
(package private)  void showItem(int hItem)
           
 void showItem(TreeItem item)
          Enabled: Shows the item.
 void showSelection()
          Enabled: Shows the selection.
(package private)  String toolTipText(org.eclipse.swt.internal.win32.NMTTDISPINFO hdr)
           
(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 WM_CHAR(int wParam, int lParam)
           
(package private)  org.eclipse.swt.internal.win32.LRESULT WM_GETOBJECT(int wParam, int lParam)
           
(package private)  org.eclipse.swt.internal.win32.LRESULT WM_KEYDOWN(int wParam, int lParam)
           
(package private)  org.eclipse.swt.internal.win32.LRESULT WM_KILLFOCUS(int wParam, int lParam)
           
(package private)  org.eclipse.swt.internal.win32.LRESULT WM_LBUTTONDOWN(int wParam, int lParam)
           
(package private)  org.eclipse.swt.internal.win32.LRESULT WM_RBUTTONDOWN(int wParam, int lParam)
           
(package private)  org.eclipse.swt.internal.win32.LRESULT WM_SETFOCUS(int wParam, int lParam)
           
(package private)  org.eclipse.swt.internal.win32.LRESULT WM_SYSCOLORCHANGE(int wParam, int lParam)
           
(package private)  org.eclipse.swt.internal.win32.LRESULT wmNotifyChild(int wParam, int lParam)
           
 
Methods inherited from class org.eclipse.swt.widgets.Composite
_getChildren, _getTabList, checkSubclass, computeTabList, getChildren, getChildrenCount, getLayout, getTabList, hooksKeys, layout, layout, minimumSize, moveAbove, moveBelow, releaseChildren, resizeChildren, resizeChildren, setFocus, setLayout, setResizeChildren, setTabGroupFocus, setTabItemFocus, setTabList, translateMnemonic, updateFont, WM_ERASEBKGND, WM_GETDLGCODE, WM_GETFONT, WM_NOTIFY, WM_PAINT, WM_SETFONT, WM_SIZE, WM_SYSCOMMAND
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, createScrollBar, getClientArea, getHorizontalBar, getVerticalBar, widgetExtStyle, WM_HSCROLL, WM_MOUSEWHEEL, WM_VSCROLL, wmScroll
 
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addFocusListener, addHelpListener, addKeyListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addPaintListener, addTraverseListener, checkOrientation, computeSize, computeTabGroup, computeTabRoot, defaultFont, defaultForeground, deregister, destroyWidget, drawBackground, drawBackground, findBrush, findCursor, findMnemonic, fixFocus, forceFocus, forceResize, getAccessible, getBackground, getBorderWidth, getBounds, getCodePage, getDisplay, getEnabled, getFont, getForeground, 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, setBounds, setBounds, setCapture, setCursor, setDefaultFont, setEnabled, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setRadioFocus, setRadioSelection, setSavedFocus, setSize, setSize, setToolTipText, setVisible, sort, subclass, toControl, toControl, toDisplay, toDisplay, transferActive, transferFocus, translateAccelerator, translateMnemonic, translateTraversal, traverse, traverse, traverseEscape, traverseGroup, traverseItem, traverseMnemonic, traversePage, traverseReturn, unsubclass, update, update, windowProc, WM_ACTIVATE, WM_CLEAR, WM_CLOSE, WM_COMMAND, WM_CONTEXTMENU, WM_CTLCOLOR, WM_CUT, WM_DESTROY, WM_DRAWITEM, WM_ENDSESSION, WM_HELP, WM_HOTKEY, WM_IME_CHAR, WM_IME_COMPOSITION, WM_INITMENUPOPUP, WM_KEYUP, WM_LBUTTONDBLCLK, 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_PALETTECHANGED, WM_PASTE, WM_PRINTCLIENT, WM_QUERYENDSESSION, WM_QUERYNEWPALETTE, WM_QUERYOPEN, WM_RBUTTONDBLCLK, WM_RBUTTONUP, WM_SETCURSOR, WM_SETREDRAW, WM_SETTINGCHANGE, WM_SHOWWINDOW, WM_SYSCHAR, WM_SYSKEYDOWN, WM_SYSKEYUP, WM_TIMER, WM_UNDO, WM_WINDOWPOSCHANGING, wmColorChild, wmCommandChild, wmDrawChild, wmMeasureChild, wmScrollChild
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkBits, checkParent, 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

hAnchor

int hAnchor

items

TreeItem[] items

imageList

ImageList imageList

dragStarted

boolean dragStarted

ignoreSelect

boolean ignoreSelect

ignoreExpand

boolean ignoreExpand

ignoreDeselect

boolean ignoreDeselect

customDraw

boolean customDraw

TreeProc

static final int TreeProc

TreeClass

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

Tree

public Tree(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, SWT.CHECK, Widget.checkSubclass(), Widget.getStyle()
Method Detail

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.

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
See Also:
SelectionListener, removeSelectionListener(org.eclipse.swt.events.SelectionListener), SelectionEvent

addTreeListener

public void addTreeListener(TreeListener listener)
Enabled: 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
See Also:
TreeListener, removeTreeListener(org.eclipse.swt.events.TreeListener)

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 Composite
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"

createHandle

void createHandle()
Overrides:
createHandle in class Composite

createItem

void createItem(TreeItem item,
                int hParent,
                int hInsertAfter)

createWidget

void createWidget()
Overrides:
createWidget in class Scrollable

defaultBackground

int defaultBackground()
Overrides:
defaultBackground in class Control

deselectAll

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


destroyItem

void destroyItem(TreeItem item)

getBackgroundPixel

int getBackgroundPixel()
Overrides:
getBackgroundPixel in class Control

getForegroundPixel

int getForegroundPixel()
Overrides:
getForegroundPixel in class Control

getItem

public TreeItem getItem(Point point)
Enabled: 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

getItemCount

public int getItemCount()
Enabled: Returns the number of items contained in the receiver that are direct item children of the receiver. The number that is returned is the number of roots in the tree.

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 TreeItem[] getItems()
Enabled: Returns the number of items contained in the receiver that are direct item children of the receiver. These are the roots of the tree.

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 number of items

getParentItem

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

Returns:
the receiver's parent item

getSelection

public TreeItem[] getSelection()
Enabled: Returns an array of TreeItems 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

getTopItem

public TreeItem getTopItem()
Suppressed: Returns the item which is currently at the top of the receiver. This item can change when items are expanded, collapsed, scrolled or new items are added or removed.

Returns:
the item at the top of the receiver
Since:
2.1

imageIndex

int imageIndex(Image image)

releaseItem

boolean releaseItem(TreeItem item,
                    org.eclipse.swt.internal.win32.TVITEM tvItem)

releaseItems

void releaseItems(TreeItem[] nodes,
                  org.eclipse.swt.internal.win32.TVITEM tvItem)

releaseWidget

void releaseWidget()
Overrides:
releaseWidget in class Composite

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)

removeTreeListener

public void removeTreeListener(TreeListener listener)
Enabled: 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
See Also:
TreeListener, addTreeListener(org.eclipse.swt.events.TreeListener)

setInsertMark

public void setInsertMark(TreeItem item,
                          boolean before)
Enabled: Display a mark indicating the point at which an item will be inserted. The drop insert item has a visual hint to show where a dragged item will be inserted when dropped on the tree.

Parameters:
item - the insert item. Null will clear the insertion mark.

selectAll

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


setBackgroundPixel

void setBackgroundPixel(int pixel)
Overrides:
setBackgroundPixel in class Control

setBounds

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

setCheckboxImageList

void setCheckboxImageList()

setForegroundPixel

void setForegroundPixel(int pixel)
Overrides:
setForegroundPixel in class Control

setRedraw

public void setRedraw(boolean redraw)
Enabled:

Overrides:
setRedraw in class Control
Parameters:
redraw - the new redraw state
See Also:
Control.redraw(), Control.update()

setSelection

public void setSelection(TreeItem[] 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()

setTopItem

public void setTopItem(TreeItem item)
Suppressed: Sets the item which is currently at the top of the receiver. This item can change when items are expanded, collapsed, scrolled or new items are added or removed.

Parameters:
item - the item to be shown
Since:
2.1
See Also:
getTopItem()

showItem

void showItem(int hItem)

showItem

public void showItem(TreeItem item)
Enabled: 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
See Also:
showSelection()

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.

See Also:
showItem(TreeItem)

toolTipText

String toolTipText(org.eclipse.swt.internal.win32.NMTTDISPINFO hdr)
Overrides:
toolTipText in class Composite

widgetStyle

int widgetStyle()
Overrides:
widgetStyle in class Composite

windowClass

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

windowProc

int windowProc()
Overrides:
windowProc in class Scrollable

WM_CHAR

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

WM_GETOBJECT

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

WM_KEYDOWN

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

WM_KILLFOCUS

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

WM_LBUTTONDOWN

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

WM_RBUTTONDOWN

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

WM_SETFOCUS

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

WM_SYSCOLORCHANGE

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

wmNotifyChild

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


comments?