Package org.eclipse.gef.ui.parts

# Class TreeViewer

java.lang.Object
org.eclipse.gef.ui.parts.AbstractEditPartViewer
org.eclipse.gef.ui.parts.TreeViewer

All Implemented Interfaces:
  `EditPartViewer`, `ISelectionProvider`

public class TreeViewer extends AbstractEditPartViewer
An EditPartViewer implementation based on a `Tree`.

## Nested Class Summary

## Nested classes/interfaces inherited from interface org.eclipse.gef.EditPartViewer

`EditPartViewer.Conditional`

## Field Summary

### Fields inherited from class org.eclipse.gef.ui.parts.AbstractEditPartViewer

`constantSelection, focusPart, selection, selectionListeners`

## Constructor Summary

Constructors
Constructor
Description
`TreeViewer()`
Constructs a TreeViewer with the default root editpart.

## Method Summary

Modifier and Type
Method
Description
`Control`
`createControl(Composite parent)`
Creates the default tree and sets it as the control.
`EditPart`
`findObjectAtExcluding(org.eclipse.draw2d.geometry.Point pt, Collection<?> exclude, EditPartViewer.Conditional condition)`
Returns `null` or the `EditPart` at the specified location, using the given exclusion set and conditional.
`protected void`
`fireSelectionChanged()`
Fires selection changed to the registered listeners at the time called.
`Tree`
`getControl()`
Returns `null` or the SWT `Control` for this viewer.
`Map<Widget,EditPart>`
`getVisualPartMap()`
Returns the `Map` for associating visual parts with their `EditParts`.
`protected void`
`hookControl()`
"Hooks up" a Control, i.e. sets it as the control for the RootTreeEditPart, adds necessary listener for proper operation, etc.
`void`
`reveal(EditPart part)`
Reveals the given EditPart if it is not visible.
`protected void`
`unhookControl()`
Unhooks a control so that it can be reset.

### Methods inherited from class org.eclipse.gef.ui.parts.AbstractEditPartViewer

`addDragSourceListener, addDragSourceListener, addDropTargetListener, addDropTargetListener, addPropertyChangeListener, addSelectionChangedListener, appendSelection, deselect, deselectAll, findObjectAt, findObjectAtExcluding, flush, getContents, getContextMenu, getDelegatingDragAdapter, getDelegatingDropAdapter, getDragSource, getDropTarget, getEditDomain, getEditPartFactory, getEditPartForModel, getEditPartRegistry, getFocusEditPart, getKeyHandler, getProperty, getResourceManager, getRootEditPart, getSelectedEditParts, getSelection, getSelectionManager, handleDispose, hookDragSource, hookDropTarget, init, primGetSelectedEditParts, refreshDragSourceAdapter, refreshDropTargetAdapter, registerAccessibleEditPart, removeDragSourceListener, removeDragSourceListener, removeDropTargetListener, removeDropTargetListener, removePropertyChangeListener, removeSelectionChangedListener, select, setContents, setContents, setContextMenu, setControl, setCursor, setDragSource, setDropTarget, setEditDomain, setEditPartFactory, setFocus, setKeyHandler, setProperty, setRootEditPart, setRouteEventsToEditDomain, setSelection, setSelectionManager, unregisterAccessibleEditPart`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### TreeViewer

public TreeViewer()
Constructs a TreeViewer with the default root editpart.

## Method Details

### createControl

public Control createControl(Composite parent)
Creates the default tree and sets it as the control. The default styles will show scrollbars as needed, and allows for multiple selection.

Specified by:
  `createControl` in interface `EditPartViewer`
Specified by:
  `createControl` in class `AbstractEditPartViewer`
Parameters:
  `parent` - The parent for the Tree
Returns:
  the control
See Also:
  - `EditPartViewer.createControl(Composite)`

### findObjectAtExcluding

public EditPart findObjectAtExcluding(org.eclipse.draw2d.geometry.Point pt, Collection<?> exclude, EditPartViewer.Conditional condition)
Description copied from interface: `EditPartViewer`
Returns `null` or the `EditPart` at the specified location, using the given exclusion set and conditional. This method behaves similarly to `EditPartViewer.findObjectAt(Point)`.

Parameters:
  `pt` - The mouse location
  `exclude` - The set of parts to be excluded
  `condition` - the Conditional used to evaluate a potential hit
Returns:
  `null` or an EditPart
See Also:
  - `EditPartViewer.findObjectAtExcluding(Point, Collection, EditPartViewer.Conditional)`

### fireSelectionChanged

protected void fireSelectionChanged()
Description copied from class: `AbstractEditPartViewer`
Fires selection changed to the registered listeners at the time called.

Overrides:
  `fireSelectionChanged` in class `AbstractEditPartViewer`
See Also:
  - `AbstractEditPartViewer.fireSelectionChanged()`

### getControl

public Tree getControl()
Description copied from interface: `EditPartViewer`
Returns `null` or the SWT `Control` for this viewer. The control is either set explicitly or can be created by the viewer.

Specified by:
  `getControl` in interface `EditPartViewer`
Overrides:
  `getControl` in class `AbstractEditPartViewer`
Returns:
  the SWT `Control`
Since:
  3.16
See Also:
  - `EditPartViewer.getControl()`

### getVisualPartMap

public Map<Widget,EditPart> getVisualPartMap()
Description copied from interface: `EditPartViewer`
Returns the `Map` for associating visual parts with their `EditParts`. This map is used for hit-testing. Hit testing is performed by first determining which visual part is hit, and then mapping that part to an `EditPart`. What constitutes a visual part is viewer-specific. Examples include `Figures` and `TreeItems`.

Specified by:
  `getVisualPartMap` in interface `EditPartViewer`
Overrides:
  `getVisualPartMap` in class `AbstractEditPartViewer`
Returns:
  the visual part map
See Also:
  - `EditPartViewer.getVisualPartMap()`

### hookControl

protected void hookControl()
"Hooks up" a Control, i.e. sets it as the control for the RootTreeEditPart, adds necessary listener for proper operation, etc.

Overrides:
  `hookControl` in class `AbstractEditPartViewer`
See Also:
  - `AbstractEditPartViewer.unhookControl()`

### reveal

public void reveal(EditPart part)
Description copied from interface: `EditPartViewer`
Reveals the given EditPart if it is not visible.

Specified by:
  `reveal` in interface `EditPartViewer`
Overrides:
  `reveal` in class `AbstractEditPartViewer`
Parameters:
  `part` - the EditPart to reveal
See Also:
  - `AbstractEditPartViewer.reveal(org.eclipse.gef.EditPart)`

### unhookControl

protected void unhookControl()
Unhooks a control so that it can be reset. This method deactivates the contents, removes the Control as being the Control of the RootTreeEditPart, etc. It does not remove the listeners because it is causing errors, although that would be a desirable outcome.

Overrides:
  `unhookControl` in class `AbstractEditPartViewer`