Package org.eclipse.gef.ui.parts

# Class GraphicalViewerImpl

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

All Implemented Interfaces:
  `EditPartViewer`, `GraphicalViewer`, `ISelectionProvider`

Direct Known Subclasses:
  `ScrollingGraphicalViewer`

public class GraphicalViewerImpl extends AbstractEditPartViewer implements GraphicalViewer
An EditPartViewer implementation based on `Figures`.

## 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
`GraphicalViewerImpl()`
Constructs a GraphicalViewerImpl with the default root editpart.

## Method Summary

Modifier and Type
Method
Description
`Control`
`createControl(Composite composite)`
Optionally creates the default `Control` using the default style.
`protected void`
`createDefaultRoot()`
Creates the default root editpart.
`protected org.eclipse.draw2d.LightweightSystem`
`createLightweightSystem()`
Creates the lightweight system used to host figures.
`Handle`
`findHandleAt(org.eclipse.draw2d.geometry.Point p)`
Returns the `Handle` at the specified Point.
`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.
`void`
`flush()`
Flushes and pending layouts and paints in the lightweight system.
`protected DomainEventDispatcher`
`getEventDispatcher()`
Deprecated.
This method should not be called by subclasses
`protected LayerManager`
`getLayerManager()`
Convenience method for finding the layer manager.
`protected org.eclipse.draw2d.LightweightSystem`
`getLightweightSystem()`
Returns the lightweight system.
`protected org.eclipse.draw2d.IFigure`
`getRootFigure()`
Deprecated.
There is no reason to call this method $TODO delete this method
`protected void`
`handleDispose(DisposeEvent e)`
Called if and when the `Control` is disposed.
`protected void`
`handleFocusGained(FocusEvent fe)`
This method is invoked when this viewer's control gains focus.
`protected void`
`handleFocusLost(FocusEvent fe)`
This method is invoked when this viewer's control loses focus.
`protected void`
`hookControl()`
Extended to tell the lightweight system what its control is.
`protected void`
`hookDropTarget()`
Extended to flush paints during drop callbacks.
`protected void`
`hookRootFigure()`
Hook the root figure into this viewer's `LightweightSystem`.
`void`
`registerAccessibleEditPart(AccessibleEditPart acc)`
Registers the accessible editpart with the event dispatcher.
`void`
`reveal(EditPart part)`
Reveals the specified editpart by using `ExposeHelper`s.
`void`
`setContextMenu(MenuManager contextMenu)`
Extended implementation to flush the viewer as the context menu is shown.
`void`
`setCursor(Cursor newCursor)`
Sets the cursor for the viewer's `Control`.
`protected void`
`setDragSource(DragSource source)`
Extends the drag source to handle figures which handle MouseDown events, thereby aborting any DragDetect callbacks.
`void`
`setEditDomain(EditDomain domain)`
Sets the `EditDomain` for this viewer.
`void`
`setRootEditPart(RootEditPart editpart)`
Sets the root of this viewer.
`protected void`
`setRootFigure(org.eclipse.draw2d.IFigure figure)`
Deprecated.
This method should no longer be used.
`void`
`setRouteEventsToEditDomain(boolean value)`
Turns on/off the routing of events directly to the Editor.
`protected void`
`unhookControl()`
Called when the control is being set to `null`, but before it is null.
`void`
`unregisterAccessibleEditPart(AccessibleEditPart acc)`
Does nothing by default.

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

`addDragSourceListener, addDragSourceListener, addDropTargetListener, addDropTargetListener, addPropertyChangeListener, addSelectionChangedListener, appendSelection, deselect, deselectAll, findObjectAt, findObjectAtExcluding, fireSelectionChanged, getContents, getContextMenu, getControl, getDelegatingDragAdapter, getDelegatingDropAdapter, getDragSource, getDropTarget, getEditDomain, getEditPartFactory, getEditPartRegistry, getFocusEditPart, getKeyHandler, getProperty, getResourceManager, getRootEditPart, getSelectedEditParts, getSelection, getSelectionManager, getVisualPartMap, hookDragSource, init, primGetSelectedEditParts, refreshDragSourceAdapter, refreshDropTargetAdapter, removeDragSourceListener, removeDragSourceListener, removeDropTargetListener, removeDropTargetListener, removePropertyChangeListener, removeSelectionChangedListener, select, setContents, setContents, setControl, setDropTarget, setEditPartFactory, setFocus, setKeyHandler, setProperty, setSelection, setSelectionManager`

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

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

### Methods inherited from interface org.eclipse.gef.EditPartViewer

`addDragSourceListener, addDragSourceListener, addDropTargetListener, addDropTargetListener, addPropertyChangeListener, appendSelection, deselect, deselectAll, findObjectAt, findObjectAtExcluding, getContents, getContextMenu, getControl, getEditDomain, getEditPartFactory, getEditPartRegistry, getFocusEditPart, getKeyHandler, getProperty, getResourceManager, getRootEditPart, getSelectedEditParts, getSelection, getSelectionManager, getVisualPartMap, removeDragSourceListener, removeDragSourceListener, removeDropTargetListener, removeDropTargetListener, removePropertyChangeListener, select, setContents, setContents, setControl, setEditPartFactory, setFocus, setKeyHandler, setProperty, setSelectionManager`

### Methods inherited from interface org.eclipse.jface.viewers.ISelectionProvider

`addSelectionChangedListener, removeSelectionChangedListener, setSelection`

## Constructor Details

### GraphicalViewerImpl

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

## Method Details

### createControl

public Control createControl(Composite composite)
Description copied from interface: `EditPartViewer`
Optionally creates the default `Control` using the default style. The Control can also be created externally and then set into the Viewer.

Specified by:
  `createControl` in interface `EditPartViewer`
Specified by:
  `createControl` in class `AbstractEditPartViewer`
Parameters:
  `composite` - the parent in which create the SWT `Control`
Returns:
  the created Control for convenience
See Also:
  - `EditPartViewer.createControl(org.eclipse.swt.widgets.Composite)`

### createDefaultRoot

protected void createDefaultRoot()
Creates the default root editpart. Called during construction.

### createLightweightSystem

protected org.eclipse.draw2d.LightweightSystem createLightweightSystem()
Creates the lightweight system used to host figures. Subclasses should not need to override this method.

Returns:
  the lightweight system

### handleDispose

protected void handleDispose(DisposeEvent e)
Description copied from class: `AbstractEditPartViewer`
Called if and when the `Control` is disposed. Subclasses may extend this method to perform additional cleanup.

Overrides:
  `handleDispose` in class `AbstractEditPartViewer`
Parameters:
  `e` - the disposeevent
See Also:
  - `AbstractEditPartViewer.handleDispose(org.eclipse.swt.events.DisposeEvent)`

### handleFocusGained

protected void handleFocusGained(FocusEvent fe)
This method is invoked when this viewer's control gains focus. It gives focus to the `focusPart`, if there is one.

Parameters:
  `fe` - the focusEvent received by this viewer's control

### handleFocusLost

protected void handleFocusLost(FocusEvent fe)
This method is invoked when this viewer's control loses focus. It removes focus from the `focusPart`, if there is one.

Parameters:
  `fe` - the focusEvent received by this viewer's control

### findHandleAt

public Handle findHandleAt(org.eclipse.draw2d.geometry.Point p)
Description copied from interface: `GraphicalViewer`
Returns the `Handle` at the specified Point. Returns `null` if no handle exists at the given Point. The specified point should be relative to the `client area` for this Viewer's `Control`.

Specified by:
  `findHandleAt` in interface `GraphicalViewer`
Parameters:
  `p` - the location relative to the Control's client area
Returns:
  Handle `null` or a Handle
See Also:
  - `GraphicalViewer.findHandleAt(org.eclipse.draw2d.geometry.Point)`

### 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)`.

Specified by:
  `findObjectAtExcluding` in interface `EditPartViewer`
Parameters:
  `pt` - The mouse location
  `exclude` - The set of EditParts 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)`

### flush

public void flush()
Flushes and pending layouts and paints in the lightweight system.

Specified by:
  `flush` in interface `EditPartViewer`
Overrides:
  `flush` in class `AbstractEditPartViewer`
See Also:
  - `EditPartViewer.flush()`

### getEventDispatcher

protected DomainEventDispatcher getEventDispatcher()
Deprecated.
This method should not be called by subclasses
Returns the event dispatcher

Returns:
  the event dispatcher

### getLayerManager

protected LayerManager getLayerManager()
Convenience method for finding the layer manager.

Returns:
  the LayerManager

### getLightweightSystem

protected org.eclipse.draw2d.LightweightSystem getLightweightSystem()
Returns the lightweight system.

Returns:
  the system

### getRootFigure

protected org.eclipse.draw2d.IFigure getRootFigure()
Deprecated.
There is no reason to call this method $TODO delete this method
Returns the root figure

Returns:
  the root figure

### hookDropTarget

protected void hookDropTarget()
Extended to flush paints during drop callbacks.

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

### hookControl

protected void hookControl()
Extended to tell the lightweight system what its control is.

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

### registerAccessibleEditPart

public void registerAccessibleEditPart(AccessibleEditPart acc)
Registers the accessible editpart with the event dispatcher.

Specified by:
  `registerAccessibleEditPart` in interface `EditPartViewer`
Overrides:
  `registerAccessibleEditPart` in class `AbstractEditPartViewer`
Parameters:
  `acc` - the accessible
See Also:
  - `EditPartViewer.registerAccessibleEditPart(AccessibleEditPart)`

### reveal

public void reveal(EditPart part)
Reveals the specified editpart by using `ExposeHelper`s. A bottom-up scan through the parent-chain is performed, looking for expose helpers along the way, and asking them to expose the given editpart.

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

### setContextMenu

public void setContextMenu(MenuManager contextMenu)
Extended implementation to flush the viewer as the context menu is shown.

Specified by:
  `setContextMenu` in interface `EditPartViewer`
Overrides:
  `setContextMenu` in class `AbstractEditPartViewer`
Parameters:
  `contextMenu` - the `ContextMenuProvider`
See Also:
  - `EditPartViewer.setContextMenu(org.eclipse.jface.action.MenuManager)`

### setCursor

public void setCursor(Cursor newCursor)
Description copied from interface: `EditPartViewer`
Sets the cursor for the viewer's `Control`. This method should only be called by `Tools`. `null` can be used to indicate that the default cursor should be restored.

Specified by:
  `setCursor` in interface `EditPartViewer`
Overrides:
  `setCursor` in class `AbstractEditPartViewer`
Parameters:
  `newCursor` - `null` or a Cursor
See Also:
  - `EditPartViewer.setCursor(org.eclipse.swt.graphics.Cursor)`

### setDragSource

protected void setDragSource(DragSource source)
Extends the drag source to handle figures which handle MouseDown events, thereby aborting any DragDetect callbacks.

Overrides:
  `setDragSource` in class `AbstractEditPartViewer`
Parameters:
  `source` - `null` or a drag source
See Also:
  - `AbstractEditPartViewer.setDragSource(org.eclipse.swt.dnd.DragSource)`

### setEditDomain

public void setEditDomain(EditDomain domain)
Description copied from interface: `EditPartViewer`
Sets the `EditDomain` for this viewer. The Viewer will route all mouse and keyboard events to the EditDomain.

Specified by:
  `setEditDomain` in interface `EditPartViewer`
Overrides:
  `setEditDomain` in class `AbstractEditPartViewer`
Parameters:
  `domain` - The EditDomain
See Also:
  - `EditPartViewer.setEditDomain(org.eclipse.gef.EditDomain)`

### setRootEditPart

public void setRootEditPart(RootEditPart editpart)
Description copied from interface: `EditPartViewer`
Sets the root of this viewer. The root should not be confused with the contents.

Specified by:
  `setRootEditPart` in interface `EditPartViewer`
Overrides:
  `setRootEditPart` in class `AbstractEditPartViewer`
Parameters:
  `editpart` - the RootEditPart
See Also:
  - `EditPartViewer.setRootEditPart(org.eclipse.gef.RootEditPart)`

### setRootFigure

protected void setRootFigure(org.eclipse.draw2d.IFigure figure)
Deprecated.
This method should no longer be used.
Sets the lightweight system's root figure.

Parameters:
  `figure` - the root figure

### hookRootFigure

protected void hookRootFigure()
Hook the root figure into this viewer's `LightweightSystem`.

Since:
  3.8

### setRouteEventsToEditDomain

public void setRouteEventsToEditDomain(boolean value)
Description copied from interface: `EditPartViewer`
Turns on/off the routing of events directly to the Editor. If supported by the viewer implementation, all Events should be routed to the `EditDomain` rather than handled in the default way.

Specified by:
  `setRouteEventsToEditDomain` in interface `EditPartViewer`
Overrides:
  `setRouteEventsToEditDomain` in class `AbstractEditPartViewer`
Parameters:
  `value` - true if the viewer should route events to the EditDomain
See Also:
  - `EditPartViewer.setRouteEventsToEditDomain(boolean)`

### unhookControl

protected void unhookControl()
Description copied from class: `AbstractEditPartViewer`
Called when the control is being set to `null`, but before it is null.

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

### unregisterAccessibleEditPart

public void unregisterAccessibleEditPart(AccessibleEditPart acc)
Description copied from class: `AbstractEditPartViewer`
Does nothing by default. Subclasses needing to add accessibility support should override this method.

Specified by:
  `unregisterAccessibleEditPart` in interface `EditPartViewer`
Overrides:
  `unregisterAccessibleEditPart` in class `AbstractEditPartViewer`
Parameters:
  `acc` - the accessible part
See Also:
  - `EditPartViewer.unregisterAccessibleEditPart(org.eclipse.gef.AccessibleEditPart)`