org.eclipse.gef.zest.fx.jface

## Class ZestContentViewer

- java.lang.Object
- - org.eclipse.jface.viewers.Viewer
  - - org.eclipse.jface.viewers.ContentViewer
    - - org.eclipse.gef.zest.fx.jface.ZestContentViewer

All Implemented Interfaces:
  org.eclipse.jface.viewers.IInputProvider, org.eclipse.jface.viewers.IInputSelectionProvider, org.eclipse.jface.viewers.ISelectionProvider

    public class ZestContentViewer
    extends org.eclipse.jface.viewers.ContentViewer

The `ZestContentViewer` is a `ContentViewer` that is capable of displaying `Graph`s.

### Field Summary

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

`WIDGET_DATA_KEY`

### Constructor Summary

Constructors
Constructor and Description
`ZestContentViewer(Module module)` Constructs a new `ZestContentViewer`.

### Method Summary

All Methods Instance Methods Concrete Methods
`protected javafx.embed.swt.FXCanvas` `createCanvas(org.eclipse.swt.widgets.Composite parent, int style)` Creates an `FXCanvas` inside of the given parent `Composite`.
`void` `createControl(org.eclipse.swt.widgets.Composite parent, int style)` Creates the control for this `ZestContentViewer` inside of the given parent `Composite`.
`protected Edge` `createEdge(org.eclipse.jface.viewers.ILabelProvider labelProvider, java.lang.Object contentSourceNode, Node sourceNode, java.lang.Object contentTargetNode, Node targetNode)` Constructs and returns a new `Edge` connecting the given sourceNode and targetNode.
`protected Graph` `createEmptyGraph()` Constructs and returns a new `Graph` and inserts default attributes into it: layout algorithm
`protected Graph` `createNestedGraph(java.lang.Object contentNestingNode, IGraphContentProvider graphContentProvider, org.eclipse.jface.viewers.ILabelProvider labelProvider)` Creates a `Graph` nested in the node represented by the given contentNestingNode.
`protected Node` `createNode(java.lang.Object contentNode, IGraphContentProvider graphContentProvider, org.eclipse.jface.viewers.ILabelProvider labelProvider)` Creates a `Node` for the specified contentNode using the `IContentProvider` and `ILabelProvider`.
`protected void` `createNodesAndEdges(IGraphContentProvider graphContentProvider, org.eclipse.jface.viewers.ILabelProvider labelProvider, Graph graph, java.lang.Object[] contentNodes)` Creates graph `nodes` and `edges` from the given array of contentNodes.
`protected Graph` `createRootGraph(org.eclipse.jface.viewers.IContentProvider contentProvider, org.eclipse.jface.viewers.ILabelProvider labelProvider)` Creates a complete `Graph` using the given `IContentProvider` and `ILabelProvider`.
`java.util.Map<java.lang.Object,Node>` `getContentNodeMap()` Returns an unmodifiable view of the content-node-map.
`IViewer` `getContentViewer()` Returns the `IViewer` that displays the contents.
`javafx.embed.swt.FXCanvas` `getControl()`
`org.eclipse.jface.viewers.ILabelProvider` `getLabelProvider()`
`ILayoutAlgorithm` `getLayoutAlgorithm()` Returns the `ILayoutAlgorithm` that is used for laying out the contents.
`org.eclipse.jface.viewers.ISelection` `getSelection()`
`protected SelectionModel` `getSelectionModel()` Retrieves the `SelectionModel` used by the viewer ( `getContentViewer()`)
`protected void` `handleDispose(org.eclipse.swt.events.DisposeEvent event)`
`protected void` `inputChanged(java.lang.Object input, java.lang.Object oldInput)`
`void` `refresh()`
`void` `setLayoutAlgorithm(ILayoutAlgorithm layoutAlgorithm)` Changes the `ILayoutAlgorithm` that is used for laying out the contents to the given value.
`void` `setSelection(org.eclipse.jface.viewers.ISelection selection, boolean reveal)`
`protected java.lang.String` `toCssRgb(org.eclipse.swt.graphics.Color color)` Converts the given `Color` into a CSS string: `"rgb(red,green,blue)"`.

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

`getContentProvider, getInput, handleLabelProviderChanged, hookControl, labelProviderChanged, setContentProvider, setInput, setLabelProvider`

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

`addHelpListener, addSelectionChangedListener, fireHelpRequested, fireSelectionChanged, 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`

### Constructor Detail

#### ZestContentViewer

    public ZestContentViewer(Module module)

Constructs a new `ZestContentViewer`. The given `Module` is saved so that it can be later used to create an `Injector` that is later used for the injection of members and the construction of the `IDomain`.

Parameters:
  `module` - The `Module` from which an `Injector` is created later.

### Method Detail

#### createCanvas

    protected javafx.embed.swt.FXCanvas createCanvas(org.eclipse.swt.widgets.Composite parent,
                                                     int style)

Creates an `FXCanvas` inside of the given parent `Composite`. The `FXCanvas` serves acs the container for the JavaFX `Scene` which renders the contents.

Parameters:
  `parent` - The parent `Composite`.
  `style` - The SWT style bits to be used for the to be created canvas.
Returns:
  An `FXCanvas` inside of the given parent.

#### createControl

    public void createControl(org.eclipse.swt.widgets.Composite parent,
                              int style)

Creates the control for this `ZestContentViewer` inside of the given parent `Composite`.

Parameters:
  `parent` - The parent `Composite`.
  `style` - The SWT style for this `ZestContentViewer`, which will be forwarded to its `FXCanvas` control.

#### createEdge

    protected Edge createEdge(org.eclipse.jface.viewers.ILabelProvider labelProvider,
                              java.lang.Object contentSourceNode,
                              Node sourceNode,
                              java.lang.Object contentTargetNode,
                              Node targetNode)

Constructs and returns a new `Edge` connecting the given sourceNode and targetNode. If the labelProvider implements `IGraphAttributesProvider`, then attributes for the edge are determined using the `IGraphAttributesProvider.getEdgeAttributes(Object, Object)` methods and inserted into the edge.

Parameters:
  `labelProvider` - This viewer's `ILabelProvider` for convenience.
  `contentSourceNode` - The content element representing the source node of this edge.
  `sourceNode` - The already created source `Node` of this edge.
  `contentTargetNode` - The content element representing the target node of this edge.
  `targetNode` - The already created target `Node` of this edge.
Returns:
  The new `Edge`.

#### createEmptyGraph

    protected Graph createEmptyGraph()

Constructs and returns a new `Graph` and inserts default attributes into it:

1. layout algorithm

Returns:
  A new `Graph` with default attributes.

#### createNestedGraph

    protected Graph createNestedGraph(java.lang.Object contentNestingNode,
                                      IGraphContentProvider graphContentProvider,
                                      org.eclipse.jface.viewers.ILabelProvider labelProvider)

Creates a `Graph` nested in the node represented by the given contentNestingNode.

Parameters:
  `contentNestingNode` - The content `Object` that represents the nesting node.
  `graphContentProvider` - This viewer's `IGraphContentProvider` for convenience.
  `labelProvider` - This viewer's `ILabelProvider` for convenience.
Returns:
  The new `Graph`.

#### createNode

    protected Node createNode(java.lang.Object contentNode,
                              IGraphContentProvider graphContentProvider,
                              org.eclipse.jface.viewers.ILabelProvider labelProvider)

Creates a `Node` for the specified contentNode using the `IContentProvider` and `ILabelProvider`. Moreover, the new node is put into the given contentToGraphMap.

Parameters:
  `contentNode` - The content `Object` that represents the node.
  `graphContentProvider` - This viewer's `IGraphContentProvider` for convenience.
  `labelProvider` - This viewer's `ILabelProvider` for convenience.
Returns:
  The new `Node`.

#### createNodesAndEdges

    protected void createNodesAndEdges(IGraphContentProvider graphContentProvider,
                                       org.eclipse.jface.viewers.ILabelProvider labelProvider,
                                       Graph graph,
                                       java.lang.Object[] contentNodes)

Creates graph `nodes` and `edges` from the given array of contentNodes.

Parameters:
  `graphContentProvider` - This viewer's `IGraphContentProvider` for convenience.
  `labelProvider` - This viewer's `ILabelProvider` for convenience.
  `graph` - The `Graph` for which nodes and edges are created.
  `contentNodes` - Content elements which represent nodes that are to be created together with the edges between them.

#### createRootGraph

    protected Graph createRootGraph(org.eclipse.jface.viewers.IContentProvider contentProvider,
                                    org.eclipse.jface.viewers.ILabelProvider labelProvider)

Creates a complete `Graph` using the given `IContentProvider` and `ILabelProvider`.

Parameters:
  `contentProvider` - The `IContentProvider` for this viewer.
  `labelProvider` - The `ILabelProvider` for this viewer.
Returns:
  A complete `Graph` constructed by using the given providers.

#### getContentNodeMap

    public java.util.Map<java.lang.Object,Node> getContentNodeMap()

Returns an unmodifiable view of the content-node-map.

Returns:
  An unmodifiable view of the content-node-map.

#### getContentViewer

    public IViewer getContentViewer()

Returns the `IViewer` that displays the contents.

Returns:
  The `IViewer` that displays the contents.

#### getControl

    public javafx.embed.swt.FXCanvas getControl()

Specified by:
  `getControl` in class `org.eclipse.jface.viewers.Viewer`

#### getLabelProvider

    public org.eclipse.jface.viewers.ILabelProvider getLabelProvider()

Overrides:
  `getLabelProvider` in class `org.eclipse.jface.viewers.ContentViewer`

#### getLayoutAlgorithm

    public ILayoutAlgorithm getLayoutAlgorithm()

Returns the `ILayoutAlgorithm` that is used for laying out the contents.

Returns:
  The `ILayoutAlgorithm` that is used for laying out the contents.

#### getSelection

    public org.eclipse.jface.viewers.ISelection getSelection()

Specified by:
  `getSelection` in interface `org.eclipse.jface.viewers.ISelectionProvider`
Specified by:
  `getSelection` in class `org.eclipse.jface.viewers.Viewer`

#### getSelectionModel

    protected SelectionModel getSelectionModel()

Retrieves the `SelectionModel` used by the viewer ( `getContentViewer()`)

Returns:
  The `SelectionModel` adapted to the viewer ( `getContentViewer()`).

#### handleDispose

    protected void handleDispose(org.eclipse.swt.events.DisposeEvent event)

Overrides:
  `handleDispose` in class `org.eclipse.jface.viewers.ContentViewer`

#### inputChanged

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

Overrides:
  `inputChanged` in class `org.eclipse.jface.viewers.Viewer`

#### refresh

    public void refresh()

Specified by:
  `refresh` in class `org.eclipse.jface.viewers.Viewer`

#### setLayoutAlgorithm

    public void setLayoutAlgorithm(ILayoutAlgorithm layoutAlgorithm)

Changes the `ILayoutAlgorithm` that is used for laying out the contents to the given value.

Parameters:
  `layoutAlgorithm` - The new `ILayoutAlgorithm` to use.

#### setSelection

    public void setSelection(org.eclipse.jface.viewers.ISelection selection,
                             boolean reveal)

Specified by:
  `setSelection` in class `org.eclipse.jface.viewers.Viewer`

#### toCssRgb

    protected java.lang.String toCssRgb(org.eclipse.swt.graphics.Color color)

Converts the given `Color` into a CSS string: `"rgb(red,green,blue)"`.

Parameters:
  `color` - The `Color` to convert.
Returns:
  The corresponding CSS string.