Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.eclipse.swt.widgets
Class Tree  view Tree download Tree.java

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

public class Tree
extends Composite

Instances of this class provide a selectable user interface object that displays a hierarchy of items and issue notificiation when an item in the hierarchy is selected.

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

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
Events:
Selection, DefaultSelection, Collapse, Expand

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

IMPORTANT: This class is not intended to be subclassed.


Field Summary
(package private) static int BACKGROUND_COLUMN
           
(package private) static int CHECKED_COLUMN
           
(package private)  long checkRenderer
           
(package private)  long columnHandle
           
(package private) static int FONT_COLUMN
           
(package private) static int FOREGROUND_COLUMN
           
(package private) static int GRAYED_COLUMN
           
(package private) static int ID_COLUMN
           
(package private)  ImageList imageList
           
(package private)  TreeItem[] items
           
(package private)  long modelHandle
           
(package private) static int PIXBUF_COLUMN
           
(package private)  long pixbufRenderer
           
(package private) static int TEXT_COLUMN
           
(package private)  long textRenderer
           
 
Fields inherited from class org.eclipse.swt.widgets.Composite
embeddedHandle, imHandle, layout, socketHandle, tabList
 
Fields inherited from class org.eclipse.swt.widgets.Scrollable
horizontalBar, scrolledHandle, verticalBar
 
Fields inherited from class org.eclipse.swt.widgets.Control
accessible, cursor, drawCount, enableWindow, fixedHandle, font, layoutData, menu, parent, redrawWindow, toolTipText
 
Fields inherited from class org.eclipse.swt.widgets.Widget
ACTIVATE, BUTTON_PRESS_EVENT, BUTTON_RELEASE_EVENT, CANVAS, CHANGED, CLICKED, COMMIT, CONFIGURE_EVENT, data, DEFAULT_HEIGHT, DEFAULT_WIDTH, DELETE_EVENT, DELETE_RANGE, DELETE_TEXT, DISABLED, display, DISPOSED, ENTER_NOTIFY_EVENT, EVENT, EVENT_AFTER, eventTable, EXPOSE_EVENT, FOCUS, FOCUS_IN_EVENT, FOCUS_OUT_EVENT, handle, HANDLE, HIDE, INSERT_TEXT, KEY_PRESS_EVENT, KEY_RELEASE_EVENT, KEYED_DATA, LEAVE_NOTIFY_EVENT, MAP_EVENT, MENU, MNEMONIC_ACTIVATE, MOTION_NOTIFY_EVENT, OBSCURED, POPUP_MENU, PREEDIT_CHANGED, REALIZE, ROW_ACTIVATED, SCROLL_CHILD, SELECT, SHOW, SHOW_HELP, SIZE_ALLOCATE, state, style, STYLE_SET, SWITCH_PAGE, TEST_COLLAPSE_ROW, TEST_EXPAND_ROW, TOGGLED, UNMAP_EVENT, UNREALIZE, VALUE_CHANGED, VISIBILITY_NOTIFY_EVENT, WINDOW_STATE_EVENT
 
Constructor Summary
Tree(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(org.eclipse.swt.events.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(org.eclipse.swt.events.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.
(package private) static int checkStyle(int style)
           
 org.eclipse.swt.graphics.Point computeSize(int wHint, int hHint, boolean changed)
          Returns the preferred size of the receiver.
(package private)  void createHandle(int index)
           
(package private)  void createItem(TreeItem item, long iter, int index)
           
(package private)  void createWidget(int index)
           
(package private)  org.eclipse.swt.internal.gtk.GdkColor defaultBackground()
           
(package private)  org.eclipse.swt.internal.gtk.GdkColor defaultForeground()
           
(package private)  void deregister()
           
 void deselectAll()
          Deselects all selected items in the receiver.
(package private)  void destroyItem(TreeItem item)
           
(package private)  void destroyWidget()
           
(package private)  org.eclipse.swt.internal.gtk.GdkColor getBackgroundColor()
           
(package private)  TreeItem getFocusItem()
           
(package private)  org.eclipse.swt.internal.gtk.GdkColor getForegroundColor()
           
 TreeItem getItem(org.eclipse.swt.graphics.Point point)
          Returns the item at the given point in the receiver or null if no such item exists.
 int getItemCount()
          Returns the number of items contained in the receiver that are direct item children of the receiver.
 int getItemHeight()
          Returns the height of the area which would be used to display one of the items in the tree.
 TreeItem[] getItems()
          Returns the items contained in the receiver that are direct item children of the receiver.
(package private)  TreeItem[] getItems(long parent)
           
 TreeItem getParentItem()
          Returns the receiver's parent item, which must be a TreeItem or null when the receiver is a root.
 TreeItem[] getSelection()
          Returns an array of TreeItems that are currently selected in the receiver.
 int getSelectionCount()
          Returns the number of selected items contained in the receiver.
 TreeItem getTopItem()
          Returns the item which is currently at the top of the receiver.
(package private)  long gtk_button_press_event(long widget, long event)
           
(package private)  long gtk_changed(long widget)
           
(package private)  long gtk_key_press_event(long widget, long eventPtr)
           
(package private)  long gtk_row_activated(long tree, long path, long column)
           
(package private)  long gtk_test_collapse_row(long tree, long iter, long path)
           
(package private)  long gtk_test_expand_row(long tree, long iter, long path)
           
(package private)  long gtk_toggled(long renderer, long pathStr)
           
(package private)  void hookEvents()
           
(package private)  long paintWindow()
           
(package private)  void register()
           
(package private)  boolean releaseItem(TreeItem item, int[] index)
           
(package private)  void releaseItems(TreeItem[] nodes, int[] index)
           
(package private)  void releaseWidget()
           
 void removeAll()
          Removes all of the items from the receiver.
(package private)  void removeColumn()
           
 void removeSelectionListener(org.eclipse.swt.events.SelectionListener listener)
          Removes the listener from the collection of listeners who will be notified when the receiver's selection changes.
 void removeTreeListener(org.eclipse.swt.events.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.
(package private)  void setBackgroundColor(org.eclipse.swt.internal.gtk.GdkColor color)
           
(package private)  boolean setBounds(int x, int y, int width, int height, boolean move, boolean resize)
           
(package private)  void setForegroundColor(org.eclipse.swt.internal.gtk.GdkColor color)
           
 void setInsertMark(TreeItem item, boolean before)
          Display a mark indicating the point at which an item will be inserted.
 void setSelection(TreeItem[] items)
          Sets the receiver's selection to be the given array of items.
 void setTopItem(TreeItem item)
          Sets the item which is currently at the top of the receiver.
(package private)  void showItem(long path, boolean scroll)
           
 void showItem(TreeItem item)
          Shows the item.
 void showSelection()
          Shows the selection.
(package private)  long treeSelectionProc(long model, long path, long iter, int[] selection, int length)
           
 
Methods inherited from class org.eclipse.swt.widgets.Composite
_getChildren, _getTabList, checkSubclass, computeTabList, createHandle, enableWidget, findMenus, fixChildren, fixTabList, focusHandle, forceFocus, getChildren, getChildrenCount, getLayout, getTabList, gtk_expose_event, gtk_focus_in_event, gtk_focus_out_event, gtk_focus, gtk_realize, gtk_scroll_child, gtk_style_set, hasBorder, hooksKeys, imHandle, isTabGroup, layout, layout, minimumSize, moveAbove, moveBelow, parentingHandle, releaseChildren, removeControl, resizeHandle, setFocus, setLayout, setTabGroupFocus, setTabItemFocus, setTabList, translateMnemonic, translateTraversal, traversalCode
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
clientHandle, computeTrim, createScrollBar, getBorderWidth, getClientArea, getHorizontalBar, getVerticalBar, hScrollBarWidth, releaseHandle, setOrientation, topHandle, vScrollBarWidth
 
Methods inherited from class org.eclipse.swt.widgets.Control
_getShell, addControlListener, addFocusListener, addHelpListener, addKeyListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addPaintListener, addTraverseListener, computeNativeSize, computeSize, computeTabGroup, computeTabRoot, defaultFont, drawGripper, eventHandle, filterKey, fixFocus, fontHandle, forceFocus, getAccessible, getBackground, getBaseColor, getBgColor, getBounds, getEnabled, getFgColor, getFont, getFontDescription, getForeground, getIMCaretPos, getLayoutData, getLocation, getMenu, getMonitor, getParent, getPath, getShell, getSize, getTextColor, getToolTipText, getVisible, gtk_button_release_event, gtk_commit, gtk_enter_notify_event, gtk_event_after, gtk_key_release_event, gtk_leave_notify_event, gtk_mnemonic_activate, gtk_motion_notify_event, gtk_popup_menu, gtk_preedit_changed, gtk_show_help, gtk_unrealize, gtk_visibility_notify_event, hasFocus, hoverProc, internal_dispose_GC, internal_new_GC, isEnabled, isFocusAncestor, isFocusControl, isReparentable, isShowing, isTabItem, isVisible, menuShell, mnemonicHit, mnemonicMatch, moveAbove, moveBelow, moveHandle, pack, pack, paintHandle, redraw, redraw, redrawWidget, releaseChild, removeControlListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removePaintListener, removeTraverseListener, sendFocusEvent, sendHelpEvent, sendIMKeyEvent, sendKeyEvent, sendMouseEvent, setBackground, setBackgroundColor, setBounds, setBounds, setCapture, setCursor, setCursor, setEnabled, setFont, setFontDescription, setForeground, setInitialSize, setLayoutData, setLocation, setLocation, setMenu, setParent, setRadioSelection, setRedraw, setSize, setSize, setToolTipText, setVisible, setZOrder, setZOrder, showMenu, sort, toControl, toControl, toDisplay, toDisplay, translateMnemonic, traverse, traverse, traverseEscape, traverseGroup, traverseItem, traverseMnemonic, traversePage, traverseReturn, update, update
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkBits, checkOrientation, checkParent, checkWidget, dispose, error, filterProc, filters, fixMnemonic, fontHeight, getData, getData, getDisplay, getName, getNameText, getStyle, gtk_activate, gtk_clicked, gtk_configure_event, gtk_delete_event, gtk_delete_range, gtk_delete_text, gtk_event, gtk_hide, gtk_insert_text, gtk_map_event, gtk_select, gtk_show, gtk_size_allocate, gtk_switch_page, gtk_timer, gtk_unmap_event, gtk_value_changed, gtk_window_state_event, hooks, isDisposed, isListening, isValidSubclass, isValidThread, isValidWidget, menuPositionProc, mnemonicHit, mnemonicMatch, notifyListeners, pixbufCellDataProc, postEvent, postEvent, releaseResources, removeDisposeListener, removeListener, removeListener, sendEvent, sendEvent, sendEvent, sendEvent, setData, setData, setInputState, setKeyState, shellMapProc, textCellDataProc, timerProc, toString, translateTraversal, windowProc, windowProc, windowProc, windowProc
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

modelHandle

long modelHandle

columnHandle

long columnHandle

checkRenderer

long checkRenderer

pixbufRenderer

long pixbufRenderer

textRenderer

long textRenderer

items

TreeItem[] items

imageList

ImageList imageList

TEXT_COLUMN

static final int TEXT_COLUMN
See Also:
Constant Field Values

PIXBUF_COLUMN

static final int PIXBUF_COLUMN
See Also:
Constant Field Values

FOREGROUND_COLUMN

static final int FOREGROUND_COLUMN
See Also:
Constant Field Values

BACKGROUND_COLUMN

static final int BACKGROUND_COLUMN
See Also:
Constant Field Values

FONT_COLUMN

static final int FONT_COLUMN
See Also:
Constant Field Values

ID_COLUMN

static final int ID_COLUMN
See Also:
Constant Field Values

CHECKED_COLUMN

static final int CHECKED_COLUMN
See Also:
Constant Field Values

GRAYED_COLUMN

static final int GRAYED_COLUMN
See Also:
Constant Field Values
Constructor Detail

Tree

public Tree(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.

Method Detail

checkStyle

static int checkStyle(int style)

addSelectionListener

public void addSelectionListener(org.eclipse.swt.events.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.


addTreeListener

public void addTreeListener(org.eclipse.swt.events.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.


computeSize

public org.eclipse.swt.graphics.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

createHandle

void createHandle(int index)
Overrides:
createHandle in class Composite

createItem

void createItem(TreeItem item,
                long iter,
                int index)

createWidget

void createWidget(int index)
Overrides:
createWidget in class Scrollable

defaultBackground

org.eclipse.swt.internal.gtk.GdkColor defaultBackground()

defaultForeground

org.eclipse.swt.internal.gtk.GdkColor defaultForeground()

deregister

void deregister()
Overrides:
deregister in class Composite

deselectAll

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


destroyItem

void destroyItem(TreeItem item)

destroyWidget

void destroyWidget()
Overrides:
destroyWidget in class Widget

getBackgroundColor

org.eclipse.swt.internal.gtk.GdkColor getBackgroundColor()
Overrides:
getBackgroundColor in class Control

getFocusItem

TreeItem getFocusItem()

getForegroundColor

org.eclipse.swt.internal.gtk.GdkColor getForegroundColor()
Overrides:
getForegroundColor in class Control

getItem

public TreeItem getItem(org.eclipse.swt.graphics.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.


getItemCount

public int getItemCount()
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.


getItemHeight

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


getItems

public TreeItem[] getItems()
Returns the 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.


getItems

TreeItem[] getItems(long parent)

getParentItem

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


getSelection

public TreeItem[] getSelection()
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.


getSelectionCount

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


getTopItem

public TreeItem getTopItem()
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.

Since:
2.1

gtk_changed

long gtk_changed(long widget)
Overrides:
gtk_changed in class Widget

gtk_key_press_event

long gtk_key_press_event(long widget,
                         long eventPtr)
Overrides:
gtk_key_press_event in class Composite

gtk_row_activated

long gtk_row_activated(long tree,
                       long path,
                       long column)
Overrides:
gtk_row_activated in class Widget

gtk_test_collapse_row

long gtk_test_collapse_row(long tree,
                           long iter,
                           long path)
Overrides:
gtk_test_collapse_row in class Widget

gtk_test_expand_row

long gtk_test_expand_row(long tree,
                         long iter,
                         long path)
Overrides:
gtk_test_expand_row in class Widget

gtk_toggled

long gtk_toggled(long renderer,
                 long pathStr)
Overrides:
gtk_toggled in class Widget

gtk_button_press_event

long gtk_button_press_event(long widget,
                            long event)
Overrides:
gtk_button_press_event in class Composite

hookEvents

void hookEvents()
Overrides:
hookEvents in class Composite

paintWindow

long paintWindow()
Overrides:
paintWindow in class Control

register

void register()
Overrides:
register in class Composite

releaseItem

boolean releaseItem(TreeItem item,
                    int[] index)

releaseItems

void releaseItems(TreeItem[] nodes,
                  int[] index)

releaseWidget

void releaseWidget()
Overrides:
releaseWidget in class Composite

removeAll

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


removeColumn

void removeColumn()

removeSelectionListener

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


removeTreeListener

public void removeTreeListener(org.eclipse.swt.events.TreeListener listener)
Removes the listener from the collection of listeners who will be notified when items in the receiver are expanded or collapsed..


setInsertMark

public void setInsertMark(TreeItem item,
                          boolean before)
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.


selectAll

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

If the receiver is single-select, do nothing.


setBackgroundColor

void setBackgroundColor(org.eclipse.swt.internal.gtk.GdkColor color)
Overrides:
setBackgroundColor in class Control

setBounds

boolean setBounds(int x,
                  int y,
                  int width,
                  int height,
                  boolean move,
                  boolean resize)
Overrides:
setBounds in class Composite

setForegroundColor

void setForegroundColor(org.eclipse.swt.internal.gtk.GdkColor color)
Overrides:
setForegroundColor in class Control

setSelection

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


setTopItem

public void setTopItem(TreeItem item)
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.

Since:
2.1

showSelection

public void showSelection()
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.


showItem

void showItem(long path,
              boolean scroll)

showItem

public void showItem(TreeItem 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.


treeSelectionProc

long treeSelectionProc(long model,
                       long path,
                       long iter,
                       int[] selection,
                       int length)
Overrides:
treeSelectionProc in class Widget