org.eclipse.gef4.zest.core.viewers

## Class AbstractStructuredGraphViewer

- java.lang.Object
- - org.eclipse.jface.viewers.Viewer
  - - org.eclipse.jface.viewers.ContentViewer
    - - org.eclipse.jface.viewers.StructuredViewer
      - - org.eclipse.gef4.zest.core.viewers.AbstractZoomableViewer
        - - org.eclipse.gef4.zest.core.viewers.AbstractStructuredGraphViewer

All Implemented Interfaces:
  IInputProvider, IInputSelectionProvider, IPostSelectionProvider, ISelectionProvider

Direct Known Subclasses:
  GraphViewer

    public abstract class AbstractStructuredGraphViewer
    extends AbstractZoomableViewer

Abstraction of graph viewers to implement functionality used by all of them. Not intended to be implemented by clients. Use one of the provided children instead.

Since:
  2.0

### Nested Class Summary

### Nested classes/interfaces inherited from class org.eclipse.jface.viewers.StructuredViewer

`StructuredViewer.ColorAndFontCollector, StructuredViewer.ColorAndFontCollectorWithProviders`

### Field Summary

### Fields inherited from class org.eclipse.jface.viewers.Viewer

`WIDGET_DATA_KEY`

### Constructor Summary

Constructors
`protected` `AbstractStructuredGraphViewer(int graphStyle)`

### Method Summary

Methods
`GraphConnection` `addGraphModelConnection(java.lang.Object element, GraphNode source, GraphNode target)`
`GraphNode` `addGraphModelContainer(java.lang.Object element)`
`GraphNode` `addGraphModelNode(GraphContainer container, java.lang.Object element)`
`GraphNode` `addGraphModelNode(java.lang.Object element, org.eclipse.draw2d.IFigure figure)`
`void` `addNode(java.lang.Object element)` Creates a new node and adds it to the graph.
`void` `addRelationship(java.lang.Object connection)` Adds a new relationship given the connection.
`void` `addRelationship(java.lang.Object connection, java.lang.Object srcNode, java.lang.Object destNode)` Creates a new relationship between the source node and the destination node.
`abstract void` `applyLayout()` Applies the viewers layouts.
`protected Widget` `doFindInputItem(java.lang.Object element)`
`protected Widget` `doFindItem(java.lang.Object element)`
`protected void` `doUpdateItem(Widget item, java.lang.Object element, boolean fullMap)`
`protected void` `filterVisuals()`
`protected GraphItem[]` `findItems(java.util.List l)`
`java.lang.Object[]` `getConnectionElements()`
`protected GraphConnection[]` `getConnectionsArray(GraphWidget graph)` Converts the list of GraphModelConnection objects into an array and returns it.
`int` `getConnectionStyle()`
`protected abstract org.eclipse.gef4.zest.core.viewers.internal.IStylingGraphModelFactory` `getFactory()` Returns the factory used to create the model.
`GraphWidget` `getGraphControl()`
`GraphConnection` `getGraphModelConnection(java.lang.Object obj)`
`GraphNode` `getGraphModelNode(java.lang.Object obj)`
`int` `getGraphStyle()` Returns the style set for the graph
`protected abstract org.eclipse.gef4.layout.LayoutAlgorithm` `getLayoutAlgorithm()` Gets the current layout algorithm.
`java.lang.Object[]` `getNodeElements()`
`protected GraphNode[]` `getNodesArray(GraphWidget graph)` Converts the list of GraphModelNode objects into an array an returns it.
`java.util.HashMap<java.lang.Object,GraphItem>` `getNodesMap()`
`int` `getNodeStyle()` Returns the style set for the nodes.
`protected java.lang.Object[]` `getRawChildren(java.lang.Object parent)`
`protected java.util.List<java.lang.Object>` `getSelectionFromWidget()`
`protected java.util.List` `getWidgetSelection()` Gets the internal model elements that are selected.
`protected void` `inputChanged(java.lang.Object input, java.lang.Object oldInput)`
`protected void` `internalRefresh(java.lang.Object element)`
`void` `removeGraphModelConnection(java.lang.Object obj)`
`void` `removeGraphModelNode(java.lang.Object obj)`
`void` `removeNode(java.lang.Object element)` Removes the given element from the layout algorithm and the model.
`void` `removeRelationship(java.lang.Object connection)` Removes the given connection object from the layout algorithm and the model.
`void` `reveal(java.lang.Object element)`
`void` `setConnectionStyle(int connectionStyle)` Sets the default style for connections in this graph.
`void` `setLayoutAlgorithm(org.eclipse.gef4.layout.LayoutAlgorithm algorithm)` Equivalent to setLayoutAlgorithm(algorithm, false).
`abstract void` `setLayoutAlgorithm(org.eclipse.gef4.layout.LayoutAlgorithm algorithm, boolean run)` Sets the layout algorithm for this viewer.
`void` `setNodeStyle(int nodeStyle)` Sets the default style for nodes in this graph.
`protected void` `setSelectionToWidget(java.util.List l, boolean reveal)`
`void` `unReveal(java.lang.Object element)`

### Methods inherited from class org.eclipse.gef4.zest.core.viewers.AbstractZoomableViewer

`getZoomManager, zoomTo`

### Methods inherited from class org.eclipse.jface.viewers.StructuredViewer

`addDoubleClickListener, addDragSupport, addDropSupport, addFilter, addOpenListener, addPostSelectionChangedListener, assertContentProviderType, assertElementsNotNull, associate, buildLabel, disassociate, equals, filter, findItem, findItems, fireDoubleClick, fireOpen, firePostSelectionChanged, getColorAndFontCollector, getComparator, getComparer, getFilteredChildren, getFilters, getItem, getRoot, getSelection, getSortedChildren, getSorter, handleDispose, handleDoubleSelect, handleInvalidSelection, handleLabelProviderChanged, handleOpen, handlePostSelect, handleSelect, hasFilters, hookControl, internalRefresh, internalUpdate, mapElement, needsRefilter, preservingSelection, refresh, refresh, refresh, refresh, refreshItem, removeDoubleClickListener, removeFilter, removeOpenListener, removePostSelectionChangedListener, resetFilters, setComparator, setComparer, setContentProvider, setFilters, setInput, setLabelProvider, setSelection, setSelectionToWidget, setSorter, setUseHashlookup, testFindItem, testFindItems, unmapAllElements, unmapElement, unmapElement, update, update, updateItem, updateSelection, usingElementMap`

### Methods inherited from class org.eclipse.jface.viewers.ContentViewer

`getContentProvider, getInput, getLabelProvider, labelProviderChanged`

### Methods inherited from class org.eclipse.jface.viewers.Viewer

`addHelpListener, addSelectionChangedListener, fireHelpRequested, fireSelectionChanged, getControl, getData, handleHelpRequest, removeHelpListener, removeSelectionChangedListener, scrollDown, scrollUp, 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`

### Constructor Detail

#### AbstractStructuredGraphViewer

    protected AbstractStructuredGraphViewer(int graphStyle)

### Method Detail

#### setNodeStyle

    public void setNodeStyle(int nodeStyle)

Sets the default style for nodes in this graph. Note: if an input is set on the viewer, a ZestException will be thrown.

Parameters:
  `nodeStyle` - the style for the nodes.
See Also:
  `#ZestStyles`

#### setConnectionStyle

    public void setConnectionStyle(int connectionStyle)

Sets the default style for connections in this graph. Note: if an input is set on the viewer, a ZestException will be thrown.

Parameters:
  `connectionStyle` - the style for the connections.
See Also:
  `#ZestStyles`

#### getGraphStyle

    public int getGraphStyle()

Returns the style set for the graph

Returns:
  The style set of the graph

#### getNodeStyle

    public int getNodeStyle()

Returns the style set for the nodes.

Returns:
  the style set for the nodes.

#### getGraphControl

    public GraphWidget getGraphControl()

#### getConnectionStyle

    public int getConnectionStyle()

Returns:
  the connection style.

#### setLayoutAlgorithm

    public abstract void setLayoutAlgorithm(org.eclipse.gef4.layout.LayoutAlgorithm algorithm,
                          boolean run)

Sets the layout algorithm for this viewer. Subclasses may place restrictions on the algorithms that it accepts.

Parameters:
  `algorithm` - the layout algorithm
  `run` - true if the layout algorithm should be run immediately. This is a hint.

#### getLayoutAlgorithm

    protected abstract org.eclipse.gef4.layout.LayoutAlgorithm getLayoutAlgorithm()

Gets the current layout algorithm.

Returns:
  the current layout algorithm.

#### setLayoutAlgorithm

    public void setLayoutAlgorithm(org.eclipse.gef4.layout.LayoutAlgorithm algorithm)

Equivalent to setLayoutAlgorithm(algorithm, false).

Parameters:
  `algorithm` -

#### getNodeElements

    public java.lang.Object[] getNodeElements()

#### getConnectionElements

    public java.lang.Object[] getConnectionElements()

#### getNodesMap

    public java.util.HashMap<java.lang.Object,GraphItem> getNodesMap()

Returns:

#### addGraphModelContainer

    public GraphNode addGraphModelContainer(java.lang.Object element)

Parameters:
  `element` -
Returns:

#### addGraphModelNode

    public GraphNode addGraphModelNode(GraphContainer container,
                              java.lang.Object element)

Parameters:
  `container` -
  `element` -
Returns:

#### addGraphModelNode

    public GraphNode addGraphModelNode(java.lang.Object element,
                              org.eclipse.draw2d.IFigure figure)

Parameters:
  `element` -
  `figure` -
Returns:

#### addGraphModelConnection

    public GraphConnection addGraphModelConnection(java.lang.Object element,
                                          GraphNode source,
                                          GraphNode target)

Parameters:
  `element` -
  `source` -
  `target` -
Returns:

#### getGraphModelConnection

    public GraphConnection getGraphModelConnection(java.lang.Object obj)

Parameters:
  `obj` -
Returns:

#### getGraphModelNode

    public GraphNode getGraphModelNode(java.lang.Object obj)

Parameters:
  `obj` -
Returns:

#### removeGraphModelConnection

    public void removeGraphModelConnection(java.lang.Object obj)

Parameters:
  `obj` -

#### removeGraphModelNode

    public void removeGraphModelNode(java.lang.Object obj)

#### internalRefresh

    protected void internalRefresh(java.lang.Object element)

Specified by:
  `internalRefresh` in class `StructuredViewer`

#### doUpdateItem

    protected void doUpdateItem(Widget item,
                    java.lang.Object element,
                    boolean fullMap)

Specified by:
  `doUpdateItem` in class `StructuredViewer`

#### doFindInputItem

    protected Widget doFindInputItem(java.lang.Object element)

Specified by:
  `doFindInputItem` in class `StructuredViewer`

#### doFindItem

    protected Widget doFindItem(java.lang.Object element)

Specified by:
  `doFindItem` in class `StructuredViewer`

#### getSelectionFromWidget

    protected java.util.List<java.lang.Object> getSelectionFromWidget()

Specified by:
  `getSelectionFromWidget` in class `StructuredViewer`

#### findItems

    protected GraphItem[] findItems(java.util.List l)

#### setSelectionToWidget

    protected void setSelectionToWidget(java.util.List l,
                            boolean reveal)

Specified by:
  `setSelectionToWidget` in class `StructuredViewer`

#### getWidgetSelection

    protected java.util.List getWidgetSelection()

Gets the internal model elements that are selected.

Returns:

#### inputChanged

    protected void inputChanged(java.lang.Object input,
                    java.lang.Object oldInput)

Overrides:
  `inputChanged` in class `Viewer`

#### getFactory

    protected abstract org.eclipse.gef4.zest.core.viewers.internal.IStylingGraphModelFactory getFactory()

Returns the factory used to create the model. This must not be called before the content provider is set.

Returns:

#### filterVisuals

    protected void filterVisuals()

#### getRawChildren

    protected java.lang.Object[] getRawChildren(java.lang.Object parent)

Overrides:
  `getRawChildren` in class `StructuredViewer`

#### reveal

    public void reveal(java.lang.Object element)

Specified by:
  `reveal` in class `StructuredViewer`

#### unReveal

    public void unReveal(java.lang.Object element)

#### applyLayout

    public abstract void applyLayout()

Applies the viewers layouts.

#### removeRelationship

    public void removeRelationship(java.lang.Object connection)

Removes the given connection object from the layout algorithm and the model.

Parameters:
  `connection` -

#### addNode

    public void addNode(java.lang.Object element)

Creates a new node and adds it to the graph. If it already exists nothing happens.

Parameters:
  `newNode` -

#### removeNode

    public void removeNode(java.lang.Object element)

Removes the given element from the layout algorithm and the model.

Parameters:
  `element` - The node element to remove.

#### addRelationship

    public void addRelationship(java.lang.Object connection,
                       java.lang.Object srcNode,
                       java.lang.Object destNode)

Creates a new relationship between the source node and the destination node. If either node doesn't exist then it will be created.

Parameters:
  `connection` - The connection data object.
  `srcNode` - The source node data object.
  `destNode` - The destination node data object.

#### addRelationship

    public void addRelationship(java.lang.Object connection)

Adds a new relationship given the connection. It will use the content provider to determine the source and destination nodes.

Parameters:
  `connection` - The connection data object.

#### getConnectionsArray

    protected GraphConnection[] getConnectionsArray(GraphWidget graph)

Converts the list of GraphModelConnection objects into an array and returns it.

Returns:
  GraphModelConnection[]

#### getNodesArray

    protected GraphNode[] getNodesArray(GraphWidget graph)

Converts the list of GraphModelNode objects into an array an returns it.

Returns:
  GraphModelNode[]