Overview | Package | Class | 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.jface.viewers
Class AbstractTreeViewer

    java.lang.Object
      org.eclipse.jface.viewers.Viewer
          org.eclipse.jface.viewers.ContentViewer
              org.eclipse.jface.viewers.StructuredViewer
                  org.eclipse.jface.viewers.AbstractTreeViewer

All Implemented Interfaces:
  IInputProvider, IInputSelectionProvider, IPostSelectionProvider, ISelectionProvider

Direct Known Subclasses:
  TableTreeViewer, TreeViewer

public abstract class AbstractTreeViewer
extends StructuredViewer

Abstract base implementation for tree-structure-oriented viewers (trees and table trees).

Nodes in the tree can be in either an expanded or a collapsed state, depending on whether the children on a node are visible. This class introduces public methods for controlling the expanding and collapsing of nodes.

Content providers for abstract tree viewers must implement the `ITreeContentProvider` interface.

See Also:
  `TreeViewer`, `TableTreeViewer`

Field Summary
`static int` | `ALL_LEVELS` Constant indicating that all levels of the tree should be expanded or collapsed.

Fields inherited from class org.eclipse.jface.viewers.Viewer
`WIDGET_DATA_KEY`

Constructor Summary
`protected` | `AbstractTreeViewer()` Creates an abstract tree viewer.

Method Summary
`void` | `add(Object parentElement, Object childElement)` Adds the given child element to this viewer as a child of the given parent element.
`void` | `add(Object parentElement, Object[] childElements)` Adds the given child elements to this viewer as children of the given parent element.
`protected void` | `addSelectionListener(Control control, SelectionListener listener)` Deprecated.
`protected abstract void` | `addTreeListener(Control control, TreeListener listener)` Adds the given SWT tree listener to the given SWT control.
`void` | `addTreeListener(ITreeViewerListener listener)` Adds a listener for expand and collapse events in this viewer.
`protected void` | `associate(Object element, Item item)` Associates the given element with the given widget.
`void` | `collapseAll()` Collapses all nodes of the viewer's tree, starting with the root.
`void` | `collapseToLevel(Object element, int level)` Collapses the subtree rooted at the given element to the given level.
`protected void` | `createChildren(Widget widget)` Creates all children for the given widget.
`protected void` | `createTreeItem(Widget parent, Object element, int index)` Creates a single item for the given parent and synchronizes it with the given element.
`protected void` | `disassociate(Item item)` The `AbstractTreeViewer` implementation of this method also recurses over children of the corresponding element.
`protected Widget` | `doFindInputItem(Object element)` Returns the widget in this viewer's control which represents the given element if it is the viewer's input.
`protected Widget` | `doFindItem(Object element)` Returns the widget in this viewer's control which represent the given element.
`protected abstract void` | `doUpdateItem(Item item, Object element)` Copies the attributes of the given element into the given SWT item.
`protected void` | `doUpdateItem(Widget widget, Object element, boolean fullMap)` Copies the attributes of the given element into the given SWT item.
`void` | `expandAll()` Expands all nodes of the viewer's tree, starting with the root.
`void` | `expandToLevel(int level)` Expands the root of the viewer's tree to the given level.
`void` | `expandToLevel(Object element, int level)` Expands all ancestors of the given element so that the given element becomes visible in this viewer's tree control, and then expands the subtree rooted at the given element to the given level.
`protected void` | `fireTreeCollapsed(TreeExpansionEvent event)` Fires a tree collapsed event.
`protected void` | `fireTreeExpanded(TreeExpansionEvent event)` Fires a tree expanded event.
`int` | `getAutoExpandLevel()` Returns the auto-expand level.
`protected abstract Item[]` | `getChildren(Widget widget)` Returns the SWT child items for the given SWT widget.
`protected abstract boolean` | `getExpanded(Item item)` Returns whether the given SWT item is expanded or collapsed.
`Object[]` | `getExpandedElements()` Returns a list of elements corresponding to expanded nodes in this viewer's tree, including currently hidden ones that are marked as expanded but are under a collapsed ancestor.
`boolean` | `getExpandedState(Object element)` Returns whether the node corresponding to the given element is expanded or collapsed.
`protected abstract int` | `getItemCount(Control control)` Returns the number of child items of the given SWT control.
`protected abstract int` | `getItemCount(Item item)` Returns the number of child items of the given SWT item.
`protected abstract Item[]` | `getItems(Item item)` Returns the child items of the given SWT item.
`protected Item` | `getNextItem(Item item, boolean includeChildren)` Returns the item after the given item in the tree, or `null` if there is no next item.
`protected abstract Item` | `getParentItem(Item item)` Returns the parent item of the given item in the tree, or `null` if there is parent item.
`protected Item` | `getPreviousItem(Item item)` Returns the item before the given item in the tree, or `null` if there is no previous item.
`protected Object[]` | `getRawChildren(Object parent)` Returns the children of the given parent without sorting and filtering them.
`protected abstract Item[]` | `getSelection(Control control)` Returns all selected items for the given SWT control.
`protected List` | `getSelectionFromWidget()` Retrieves the selection, as a `List`, from the underlying widget.
`Object[]` | `getVisibleExpandedElements()` Gets the expanded elements that are visible to the user.
`protected void` | `handleTreeCollapse(TreeEvent event)` Handles a tree collapse event from the SWT widget.
`protected void` | `handleTreeExpand(TreeEvent event)` Handles a tree expand event from the SWT widget.
`protected void` | `hookControl(Control control)` Adds event listener hooks to the given control.
`protected int` | `indexForElement(Widget parent, Object element)` Returns the index where the item should be inserted.
`protected void` | `inputChanged(Object input, Object oldInput)` Internal hook method called when the input to this viewer is initially set or subsequently changed.
`protected void` | `internalCollapseToLevel(Widget widget, int level)` Recursively collapses the subtree rooted at the given widget to the given level.
`protected Widget` | `internalExpand(Object element, boolean expand)` Tries to create a path of tree items for the given element.
`protected void` | `internalExpandToLevel(Widget widget, int level)` Recursively expands the subtree rooted at the given widget to the given level.
`protected void` | `internalRefresh(Object element)` Refreshes this viewer starting at the given element.
`protected void` | `internalRefresh(Object element, boolean updateLabels)` Refreshes this viewer starting at the given element.
`boolean` | `isExpandable(Object element)` Return whether the tree node representing the given element can be expanded.
`protected void` | `labelProviderChanged()` Notifies that the label provider has changed.
`protected abstract Item` | `newItem(Widget parent, int style, int index)` Creates a new item.
`void` | `remove(Object element)` Removes the given element from the viewer.
`void` | `remove(Object[] elements)` Removes the given elements from this viewer.
`protected abstract void` | `removeAll(Control control)` Removes all items from the given control.
`void` | `removeTreeListener(ITreeViewerListener listener)` Removes a listener for expand and collapse events in this viewer.
`void` | `reveal(Object element)` Ensures that the given element is visible, scrolling the viewer if necessary.
`Item` | `scrollDown(int x, int y)` Scrolls the viewer's control down by one item from the given display-relative coordinates.
`Item` | `scrollUp(int x, int y)` Scrolls the viewer's control up by one item from the given display-relative coordinates.
`void` | `setAutoExpandLevel(int level)` Sets the auto-expand level.
`void` | `setContentProvider(IContentProvider provider)` The `AbstractTreeViewer` implementation of this method checks to ensure that the content provider is an `ITreeContentProvider`.
`protected abstract void` | `setExpanded(Item item, boolean expand)` Sets the expand state of the given item.
`void` | `setExpandedElements(Object[] elements)` Sets which nodes are expanded in this viewer's tree.
`void` | `setExpandedState(Object element, boolean expanded)` Sets whether the node corresponding to the given element is expanded or collapsed.
`protected abstract void` | `setSelection(List items)` Sets the selection to the given list of items.
`protected void` | `setSelectionToWidget(List v, boolean reveal)` Parlays the given list of selected elements into selections on this viewer's control.
`protected abstract void` | `showItem(Item item)` Shows the given item.
`protected void` | `updateChildren(Widget widget, Object parent, Object[] elementChildren)` Deprecated. this is no longer called by the framework
`protected void` | `updatePlus(Item item, Object element)` Updates the "+"/"-" icon of the tree node from the given element.

Methods inherited from class org.eclipse.jface.viewers.StructuredViewer
`addDoubleClickListener, addDragSupport, addDropSupport, addFilter, addOpenListener, addPostSelectionChangedListener, assertElementsNotNull, equals, filter, findItem, fireDoubleClick, fireOpen, firePostSelectionChanged, getComparer, getFilteredChildren, getFilters, getItem, getRoot, getSelection, getSortedChildren, getSorter, handleDoubleSelect, handleInvalidSelection, handleLabelProviderChanged, handleOpen, handlePostSelect, handleSelect, hasFilters, mapElement, needsRefilter, preservingSelection, refresh, refresh, refresh, refresh, refreshItem, removeDoubleClickListener, removeFilter, removeOpenListener, removePostSelectionChangedListener, resetFilters, setComparer, setInput, setSelection, setSelectionToWidget, setSorter, setUseHashlookup, testFindItem, unmapAllElements, unmapElement, unmapElement, update, update, updateItem, updateSelection, usingElementMap`

Methods inherited from class org.eclipse.jface.viewers.ContentViewer
`getContentProvider, getInput, getLabelProvider, handleDispose, setLabelProvider`

Methods inherited from class org.eclipse.jface.viewers.Viewer
`addHelpListener, addSelectionChangedListener, fireHelpRequested, fireSelectionChanged, getControl, getData, handleHelpRequest, removeHelpListener, removeSelectionChangedListener, setData, setSelection`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.eclipse.jface.viewers.ISelectionProvider
`addSelectionChangedListener, removeSelectionChangedListener, setSelection`

Field Detail

### ALL_LEVELS

    public static final int ALL_LEVELS

  Constant indicating that all levels of the tree should be expanded or collapsed.

  See Also:
    `expandToLevel(int)`, `collapseToLevel(java.lang.Object, int)`, Constant Field Values

Constructor Detail

### AbstractTreeViewer

    protected AbstractTreeViewer()

  Creates an abstract tree viewer. The viewer has no input, no content provider, a default label provider, no sorter, no filters, and has auto-expand turned off.

Method Detail

### add

    public void add(Object parentElement,
                    Object[] childElements)

  Adds the given child elements to this viewer as children of the given parent element. If this viewer does not have a sorter, the elements are added at the end of the parent's list of children in the order given; otherwise, the elements are inserted at the appropriate positions.

  This method should be called (by the content provider) when elements have been added to the model, in order to cause the viewer to accurately reflect the model. This method only affects the viewer, not the model.

  Parameters:
    `parentElement` - the parent element
    `childElements` - the child elements to add

### indexForElement

    protected int indexForElement(Widget parent,
                                  Object element)

  Returns the index where the item should be inserted.

  Parameters:
    `parent` - The parent widget the element will be inserted into.
    `element` - The element to insert.
  Returns:
    int

### add

    public void add(Object parentElement,
                    Object childElement)

  Adds the given child element to this viewer as a child of the given parent element. If this viewer does not have a sorter, the element is added at the end of the parent's list of children; otherwise, the element is inserted at the appropriate position.

  This method should be called (by the content provider) when a single element has been added to the model, in order to cause the viewer to accurately reflect the model. This method only affects the viewer, not the model. Note that there is another method for efficiently processing the simultaneous addition of multiple elements.

  Parameters:
    `parentElement` - the parent element
    `childElement` - the child element

### addSelectionListener

    protected void addSelectionListener(Control control,
                                        SelectionListener listener)

  Deprecated.

  Adds the given SWT selection listener to the given SWT control.

  Parameters:
    `control` - the SWT control
    `listener` - the SWT selection listener

### addTreeListener

    public void addTreeListener(ITreeViewerListener listener)

  Adds a listener for expand and collapse events in this viewer. Has no effect if an identical listener is already registered.

  Parameters:
    `listener` - a tree viewer listener

### addTreeListener

    protected abstract void addTreeListener(Control control,
                                            TreeListener listener)

  Adds the given SWT tree listener to the given SWT control.

  Parameters:
    `control` - the SWT control
    `listener` - the SWT tree listener

### associate

    protected void associate(Object element,
                             Item item)

  Description copied from class: `StructuredViewer`
  Associates the given element with the given widget. Sets the given item's data to be the element, and maps the element to the item in the element map (if enabled).

  Overrides:
    `associate` in class `StructuredViewer`
  Parameters:
    `element` - the element
    `item` - the widget

### collapseAll

    public void collapseAll()

  Collapses all nodes of the viewer's tree, starting with the root. This method is equivalent to `collapseToLevel(ALL_LEVELS)`.

### collapseToLevel

    public void collapseToLevel(Object element,
                                int level)

  Collapses the subtree rooted at the given element to the given level.

  Parameters:
    `element` - the element
    `level` - non-negative level, or `ALL_LEVELS` to collapse all levels of the tree

### createChildren

    protected void createChildren(Widget widget)

  Creates all children for the given widget.

  The default implementation of this framework method assumes that `widget.getData()` returns the element corresponding to the node. Note: the node is not visually expanded! You may have to call `parent.setExpanded(true)`.

  Parameters:
    `widget` - the widget

### createTreeItem

    protected void createTreeItem(Widget parent,
                                  Object element,
                                  int index)

  Creates a single item for the given parent and synchronizes it with the given element.

  Parameters:
    `parent` - the parent widget
    `element` - the element
    `index` - if non-negative, indicates the position to insert the item into its parent

### disassociate

    protected void disassociate(Item item)

  The `AbstractTreeViewer` implementation of this method also recurses over children of the corresponding element.

  Overrides:
    `disassociate` in class `StructuredViewer`
  Parameters:
    `item` - the widget

### doFindInputItem

    protected Widget doFindInputItem(Object element)

  Description copied from class: `StructuredViewer`
  Returns the widget in this viewer's control which represents the given element if it is the viewer's input.

  This method is internal to the framework; subclassers should not call this method.

  Specified by:
    `doFindInputItem` in class `StructuredViewer`
  Parameters:
    `element` -
  Returns:
    the corresponding widget, or `null` if none

### doFindItem

    protected Widget doFindItem(Object element)

  Description copied from class: `StructuredViewer`
  Returns the widget in this viewer's control which represent the given element. This method searchs all the children of the input element.

  This method is internal to the framework; subclassers should not call this method.

  Specified by:
    `doFindItem` in class `StructuredViewer`
  Parameters:
    `element` -
  Returns:
    the corresponding widget, or `null` if none

### doUpdateItem

    protected abstract void doUpdateItem(Item item,
                                         Object element)

  Copies the attributes of the given element into the given SWT item.

  Parameters:
    `item` - the SWT item
    `element` - the element

### doUpdateItem

    protected void doUpdateItem(Widget widget,
                                Object element,
                                boolean fullMap)

  Description copied from class: `StructuredViewer`
  Copies the attributes of the given element into the given SWT item. The element map is updated according to the value of `fullMap`. If `fullMap` is `true` then the current mapping from element to widgets is removed and the new mapping is added. If fullmap is `false` then only the new map gets installed. Installing only the new map is necessary in cases where only the order of elements changes but not the set of elements.

  This method is internal to the framework; subclassers should not call this method.

  Specified by:
    `doUpdateItem` in class `StructuredViewer`
  Parameters:
    `widget` -
    `element` - element
    `fullMap` - `true` if mappings are added and removed, and `false` if only the new map gets installed

### expandAll

    public void expandAll()

  Expands all nodes of the viewer's tree, starting with the root. This method is equivalent to `expandToLevel(ALL_LEVELS)`.

### expandToLevel

    public void expandToLevel(int level)

  Expands the root of the viewer's tree to the given level.

  Parameters:
    `level` - non-negative level, or `ALL_LEVELS` to expand all levels of the tree

### expandToLevel

    public void expandToLevel(Object element,
                              int level)

  Expands all ancestors of the given element so that the given element becomes visible in this viewer's tree control, and then expands the subtree rooted at the given element to the given level.

  Parameters:
    `element` - the element
    `level` - non-negative level, or `ALL_LEVELS` to expand all levels of the tree

### fireTreeCollapsed

    protected void fireTreeCollapsed(TreeExpansionEvent event)

  Fires a tree collapsed event. Only listeners registered at the time this method is called are notified.

  Parameters:
    `event` - the tree expansion event
  See Also:
    `ITreeViewerListener.treeCollapsed(org.eclipse.jface.viewers.TreeExpansionEvent)`

### fireTreeExpanded

    protected void fireTreeExpanded(TreeExpansionEvent event)

  Fires a tree expanded event. Only listeners registered at the time this method is called are notified.

  Parameters:
    `event` - the tree expansion event
  See Also:
    `ITreeViewerListener.treeExpanded(org.eclipse.jface.viewers.TreeExpansionEvent)`

### getAutoExpandLevel

    public int getAutoExpandLevel()

  Returns the auto-expand level.

  Returns:
    non-negative level, or `ALL_LEVELS` if all levels of the tree are expanded automatically
  See Also:
    `setAutoExpandLevel(int)`

### getChildren

    protected abstract Item[] getChildren(Widget widget)

  Returns the SWT child items for the given SWT widget.

  Parameters:
    `widget` - the widget
  Returns:
    the child items

### getExpanded

    protected abstract boolean getExpanded(Item item)

  Returns whether the given SWT item is expanded or collapsed.

  Parameters:
    `item` - the item
  Returns:
    `true` if the item is considered expanded and `false` if collapsed

### getExpandedElements

    public Object[] getExpandedElements()

  Returns a list of elements corresponding to expanded nodes in this viewer's tree, including currently hidden ones that are marked as expanded but are under a collapsed ancestor.

  This method is typically used when preserving the interesting state of a viewer; `setExpandedElements` is used during the restore.

  Returns:
    the array of expanded elements
  See Also:
    `setExpandedElements(java.lang.Object[])`

### getExpandedState

    public boolean getExpandedState(Object element)

  Returns whether the node corresponding to the given element is expanded or collapsed.

  Parameters:
    `element` - the element
  Returns:
    `true` if the node is expanded, and `false` if collapsed

### getItemCount

    protected abstract int getItemCount(Control control)

  Returns the number of child items of the given SWT control.

  Parameters:
    `control` - the control
  Returns:
    the number of children

### getItemCount

    protected abstract int getItemCount(Item item)

  Returns the number of child items of the given SWT item.

  Parameters:
    `item` - the item
  Returns:
    the number of children

### getItems

    protected abstract Item[] getItems(Item item)

  Returns the child items of the given SWT item.

  Parameters:
    `item` - the item
  Returns:
    the child items

### getNextItem

    protected Item getNextItem(Item item,
                               boolean includeChildren)

  Returns the item after the given item in the tree, or `null` if there is no next item.

  Parameters:
    `item` - the item
    `includeChildren` - `true` if the children are considered in determining which item is next, and `false` if subtrees are ignored
  Returns:
    the next item, or `null` if none

### getParentItem

    protected abstract Item getParentItem(Item item)

  Returns the parent item of the given item in the tree, or `null` if there is parent item.

  Parameters:
    `item` - the item
  Returns:
    the parent item, or `null` if none

### getPreviousItem

    protected Item getPreviousItem(Item item)

  Returns the item before the given item in the tree, or `null` if there is no previous item.

  Parameters:
    `item` - the item
  Returns:
    the previous item, or `null` if none

### getRawChildren

    protected Object[] getRawChildren(Object parent)

  Description copied from class: `StructuredViewer`
  Returns the children of the given parent without sorting and filtering them. The resulting array must not be modified, as it may come directly from the model's internal state.

  Returns an empty array if the given parent is `null`.

  Overrides:
    `getRawChildren` in class `StructuredViewer`
  Parameters:
    `parent` - the parent element
  Returns:
    the child elements

### getSelection

    protected abstract Item[] getSelection(Control control)

  Returns all selected items for the given SWT control.

  Parameters:
    `control` - the control
  Returns:
    the list of selected items

### getSelectionFromWidget

    protected List getSelectionFromWidget()

  Description copied from class: `StructuredViewer`
  Retrieves the selection, as a `List`, from the underlying widget.

  Specified by:
    `getSelectionFromWidget` in class `StructuredViewer`
  Returns:
    the list of selected elements

### handleTreeCollapse

    protected void handleTreeCollapse(TreeEvent event)

  Handles a tree collapse event from the SWT widget.

  Parameters:
    `event` - the SWT tree event

### handleTreeExpand

    protected void handleTreeExpand(TreeEvent event)

  Handles a tree expand event from the SWT widget.

  Parameters:
    `event` - the SWT tree event

### hookControl

    protected void hookControl(Control control)

  Description copied from class: `ContentViewer`
  Adds event listener hooks to the given control.

  All subclasses must call this method when their control is first established.

  The `ContentViewer` implementation of this method hooks dispose events for the given control. Subclasses may override if they need to add other control hooks; however, `super.hookControl` must be invoked.

  Overrides:
    `hookControl` in class `StructuredViewer`

### inputChanged

    protected void inputChanged(Object input,
                                Object oldInput)

  Description copied from class: `Viewer`
  Internal hook method called when the input to this viewer is initially set or subsequently changed.

  The default implementation does nothing. Subclassers may override this method to do something when a viewer's input is set. A typical use is populate the viewer.

  Overrides:
    `inputChanged` in class `Viewer`
  Parameters:
    `input` - the new input of this viewer, or `null` if none
    `oldInput` - the old input element or `null` if there was previously no input

### internalCollapseToLevel

    protected void internalCollapseToLevel(Widget widget,
                                           int level)

  Recursively collapses the subtree rooted at the given widget to the given level.

  Note that the default implementation of this method does not call `setRedraw`.

  Parameters:
    `widget` - the widget
    `level` - non-negative level, or `ALL_LEVELS` to collapse all levels of the tree

### internalExpand

    protected Widget internalExpand(Object element,
                                    boolean expand)

  Tries to create a path of tree items for the given element. This method recursively walks up towards the root of the tree and assumes that `getParent` returns the correct parent of an element.

  Parameters:
    `element` - the element
    `expand` - `true` if all nodes on the path should be expanded, and `false` otherwise
  Returns:
    Widget

### internalExpandToLevel

    protected void internalExpandToLevel(Widget widget,
                                         int level)

  Recursively expands the subtree rooted at the given widget to the given level.

  Note that the default implementation of this method does not call `setRedraw`.

  Parameters:
    `widget` - the widget
    `level` - non-negative level, or `ALL_LEVELS` to collapse all levels of the tree

### internalRefresh

    protected void internalRefresh(Object element)

  Description copied from class: `StructuredViewer`
  Refreshes this viewer starting at the given element.

  Specified by:
    `internalRefresh` in class `StructuredViewer`
  Parameters:
    `element` - the element

### internalRefresh

    protected void internalRefresh(Object element,
                                   boolean updateLabels)

  Description copied from class: `StructuredViewer`
  Refreshes this viewer starting at the given element. Labels are updated as described in `refresh(boolean updateLabels)`.

  The default implementation simply calls `internalRefresh(element)`, ignoring `updateLabels`.

  If this method is overridden to do the actual refresh, then `internalRefresh(Object element)` should simply call `internalRefresh(element, true)`.

  Overrides:
    `internalRefresh` in class `StructuredViewer`
  Parameters:
    `element` - the element
    `updateLabels` - `true` to update labels for existing elements, `false` to only update labels as needed, assuming that labels for existing elements are unchanged.

### isExpandable

    public boolean isExpandable(Object element)

  Return whether the tree node representing the given element can be expanded.

  The default implementation of this framework method calls `hasChildren` on this viewer's content provider. It may be overridden if necessary.

  Parameters:
    `element` - the element
  Returns:
    `true` if the tree node representing the given element can be expanded, or `false` if not

### labelProviderChanged

    protected void labelProviderChanged()

  Description copied from class: `ContentViewer`
  Notifies that the label provider has changed.

  The `ContentViewer` implementation of this method calls `refresh()`. Subclasses may reimplement or extend.

  Overrides:
    `labelProviderChanged` in class `ContentViewer`

### newItem

    protected abstract Item newItem(Widget parent,
                                    int style,
                                    int index)

  Creates a new item.

  Parameters:
    `parent` - the parent widget
    `style` - SWT style bits
    `index` - if non-negative, indicates the position to insert the item into its parent
  Returns:
    the newly-created item

### remove

    public void remove(Object[] elements)

  Removes the given elements from this viewer. The selection is updated if required.

  This method should be called (by the content provider) when elements have been removed from the model, in order to cause the viewer to accurately reflect the model. This method only affects the viewer, not the model.

  Parameters:
    `elements` - the elements to remove

### remove

    public void remove(Object element)

  Removes the given element from the viewer. The selection is updated if necessary.

  This method should be called (by the content provider) when a single element has been removed from the model, in order to cause the viewer to accurately reflect the model. This method only affects the viewer, not the model. Note that there is another method for efficiently processing the simultaneous removal of multiple elements.

  Parameters:
    `element` - the element

### removeAll

    protected abstract void removeAll(Control control)

  Removes all items from the given control.

  Parameters:
    `control` - the control

### removeTreeListener

    public void removeTreeListener(ITreeViewerListener listener)

  Removes a listener for expand and collapse events in this viewer. Has no affect if an identical listener is not registered.

  Parameters:
    `listener` - a tree viewer listener

### reveal

    public void reveal(Object element)

  Description copied from class: `StructuredViewer`
  Ensures that the given element is visible, scrolling the viewer if necessary. The selection is unchanged.

  Specified by:
    `reveal` in class `StructuredViewer`
  Parameters:
    `element` - the element to reveal

### scrollDown

    public Item scrollDown(int x,
                           int y)

  Description copied from class: `Viewer`
  Scrolls the viewer's control down by one item from the given display-relative coordinates. Returns the newly revealed Item, or `null` if no scrolling occurred or if the viewer doesn't represent an item-based widget.

  Overrides:
    `scrollDown` in class `Viewer`
  Parameters:
    `x` - horizontal coordinate
    `y` - vertical coordinate

### scrollUp

    public Item scrollUp(int x,
                         int y)

  Description copied from class: `Viewer`
  Scrolls the viewer's control up by one item from the given display-relative coordinates. Returns the newly revealed Item, or `null` if no scrolling occurred or if the viewer doesn't represent an item-based widget.

  Overrides:
    `scrollUp` in class `Viewer`
  Parameters:
    `x` - horizontal coordinate
    `y` - vertical coordinate

### setAutoExpandLevel

    public void setAutoExpandLevel(int level)

  Sets the auto-expand level. The value 0 means that there is no auto-expand; 1 means that top-level elements are expanded, but not their children; 2 means that top-level elements are expanded, and their children, but not grandchildren; and so on.

  The value `ALL_LEVELS` means that all subtrees should be expanded.

  Parameters:
    `level` - non-negative level, or `ALL_LEVELS` to expand all levels of the tree

### setContentProvider

    public void setContentProvider(IContentProvider provider)

  The `AbstractTreeViewer` implementation of this method checks to ensure that the content provider is an `ITreeContentProvider`.

  Overrides:
    `setContentProvider` in class `StructuredViewer`

### setExpanded

    protected abstract void setExpanded(Item item,
                                        boolean expand)

  Sets the expand state of the given item.

  Parameters:
    `item` - the item
    `expand` - the expand state of the item

### setExpandedElements

    public void setExpandedElements(Object[] elements)

  Sets which nodes are expanded in this viewer's tree. The given list contains the elements that are to be expanded; all other nodes are to be collapsed.

  This method is typically used when restoring the interesting state of a viewer captured by an earlier call to `getExpandedElements`.

  Parameters:
    `elements` - the array of expanded elements
  See Also:
    `getExpandedElements()`

### setExpandedState

    public void setExpandedState(Object element,
                                 boolean expanded)

  Sets whether the node corresponding to the given element is expanded or collapsed.

  Parameters:
    `element` - the element
    `expanded` - `true` if the node is expanded, and `false` if collapsed

### setSelection

    protected abstract void setSelection(List items)

  Sets the selection to the given list of items.

  Parameters:
    `items` - list of items (element type: `org.eclipse.swt.widgets.Item`)

### setSelectionToWidget

    protected void setSelectionToWidget(List v,
                                        boolean reveal)

  Description copied from class: `StructuredViewer`
  Parlays the given list of selected elements into selections on this viewer's control.

  Subclasses should override to set their selection based on the given list of elements.

  Specified by:
    `setSelectionToWidget` in class `StructuredViewer`
  Parameters:
    `v` - list of selected elements (element type: `Object`) or `null` if the selection is to be cleared
    `reveal` - `true` if the selection is to be made visible, and `false` otherwise

### showItem

    protected abstract void showItem(Item item)

  Shows the given item.

  Parameters:
    `item` - the item

### updateChildren

    protected void updateChildren(Widget widget,
                                  Object parent,
                                  Object[] elementChildren)

  Deprecated. this is no longer called by the framework

  Updates the tree items to correspond to the child elements of the given parent element. If null is passed for the children, this method obtains them (only if needed).

  Parameters:
    `widget` - the widget
    `parent` - the parent element
    `elementChildren` - the child elements, or null

### updatePlus

    protected void updatePlus(Item item,
                              Object element)

  Updates the "+"/"-" icon of the tree node from the given element. It calls `isExpandable` to determine whether an element is expandable.

  Parameters:
    `item` - the item
    `element` - the element

### getVisibleExpandedElements

    public Object[] getVisibleExpandedElements()

  Gets the expanded elements that are visible to the user. An expanded element is only visible if the parent is expanded.

  Returns:
    the visible expanded elements
  Since:
    2.0

Overview | Package | Class | 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.