org.eclipse.viatra.integration.zest.viewer

## Class ZestContentViewer

- java.lang.Object
- - org.eclipse.jface.viewers.Viewer
  - - org.eclipse.jface.viewers.ContentViewer
    - - org.eclipse.viatra.integration.zest.viewer.ZestContentViewer

- All Implemented Interfaces:
    org.eclipse.jface.viewers.IInputProvider, org.eclipse.jface.viewers.IInputSelectionProvider, org.eclipse.jface.viewers.ISelectionProvider
  Direct Known Subclasses:
    ModifiableZestContentViewer

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

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

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.util.Map<java.lang.Object,org.eclipse.gef.graph.Edge>` | `contentEdgeMap`
    `protected java.util.Map<java.lang.Object,org.eclipse.gef.graph.Node>` | `contentNodeMap`

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

      `WIDGET_DATA_KEY`

  - ### Constructor Summary

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

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected 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 org.eclipse.gef.graph.Edge` | `createEdge(org.eclipse.jface.viewers.ILabelProvider labelProvider, java.lang.Object contentEdgeNode, org.eclipse.gef.graph.Node sourceNode, org.eclipse.gef.graph.Node targetNode)` Constructs and returns a new `Edge` connecting the given sourceNode and targetNode.
    `protected org.eclipse.gef.graph.Edge` | `createEdge(org.eclipse.jface.viewers.ILabelProvider labelProvider, java.lang.Object contentSourceNode, org.eclipse.gef.graph.Node sourceNode, java.lang.Object contentTargetNode, org.eclipse.gef.graph.Node targetNode)` Constructs and returns a new `Edge` connecting the given sourceNode and targetNode.
    `protected org.eclipse.gef.graph.Graph` | `createEmptyGraph()` Constructs and returns a new `Graph` and inserts default attributes into it: layout algorithm
    `protected void` | `createNestedGraph(java.lang.Object contentNestingNode, org.eclipse.jface.viewers.IContentProvider contentProvider, org.eclipse.jface.viewers.ILabelProvider labelProvider)`
    `protected org.eclipse.gef.graph.Graph` | `createNestedGraph(java.lang.Object contentNestingNode, org.eclipse.gef.zest.fx.jface.IGraphContentProvider graphContentProvider, org.eclipse.jface.viewers.ILabelProvider labelProvider)` Creates a `Graph` nested in the node represented by the given contentNestingNode.
    `protected org.eclipse.gef.graph.Graph` | `createNestedGraph(java.lang.Object contentNestingNode, INestedGraphContentProvider graphContentProvider, org.eclipse.jface.viewers.ILabelProvider labelProvider)` Creates a `Graph` nested in the node represented by the given contentNestingNode.
    `protected org.eclipse.gef.graph.Node` | `createNode(java.lang.Object contentNode, org.eclipse.jface.viewers.IContentProvider graphContentProvider, org.eclipse.jface.viewers.ILabelProvider labelProvider)` Creates a `Node` for the specified contentNode using the `IContentProvider` and `ILabelProvider`.
    `protected void` | `createNodesAndEdges(org.eclipse.jface.viewers.IContentProvider contentProvider, org.eclipse.jface.viewers.ILabelProvider labelProvider, org.eclipse.gef.graph.Graph graph, java.lang.Object[] contentNodes)`
    `protected void` | `createNodesAndEdges(org.eclipse.gef.zest.fx.jface.IGraphContentProvider graphContentProvider, org.eclipse.jface.viewers.ILabelProvider labelProvider, org.eclipse.gef.graph.Graph graph, java.lang.Object[] contentNodes)` Creates graph `nodes` and `edges` from the given array of contentNodes.
    `protected void` | `createNodesAndEdges(IGraphEdgeContentProvider graphContentProvider, org.eclipse.jface.viewers.ILabelProvider labelProvider, org.eclipse.gef.graph.Graph graph, java.lang.Object[] contentNodes)` Creates graph `nodes` and `edges` from the given array of contentNodes.
    `protected void` | `createNodesAndEdges(IGraphEntityRelationshipContentProvider graphContentProvider, org.eclipse.jface.viewers.ILabelProvider labelProvider, org.eclipse.gef.graph.Graph graph, java.lang.Object[] contentNodes)` Creates graph `nodes` and `edges` from the given array of contentNodes.
    `protected org.eclipse.gef.graph.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,org.eclipse.gef.graph.Node>` | `getContentNodeMap()` Returns an unmodifiable view of the content-node-map.
    `FXCanvas` | `getControl()`
    `org.eclipse.gef.mvc.fx.viewer.IViewer` | `getFXViewer()` Returns the `FXViewer` that displays the contents.
    `org.eclipse.jface.viewers.ILabelProvider` | `getLabelProvider()`
    `org.eclipse.gef.layout.ILayoutAlgorithm` | `getLayoutAlgorithm()` Returns the `ILayoutAlgorithm` that is used for laying out the contents.
    `protected org.eclipse.gef.graph.Graph` | `getRootGraph()`
    `org.eclipse.jface.viewers.ISelection` | `getSelection()`
    `protected org.eclipse.gef.mvc.fx.models.SelectionModel` | `getSelectionModel()` Retrieves the `SelectionModel` used by the viewer ( `getFXViewer()`)
    `protected void` | `handleDispose(org.eclipse.swt.events.DisposeEvent event)`
    `protected void` | `inputChanged(java.lang.Object input, java.lang.Object oldInput)`
    `void` | `refresh()`
    `void` | `setLayoutAlgorithm(org.eclipse.gef.layout.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`

- - ### Field Detail

    - #### contentNodeMap

          protected java.util.Map<java.lang.Object,org.eclipse.gef.graph.Node> contentNodeMap

    - #### contentEdgeMap

          protected java.util.Map<java.lang.Object,org.eclipse.gef.graph.Edge> contentEdgeMap

  - ### Constructor Detail

    - #### ZestContentViewer

          public ZestContentViewer(com.google.inject.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 `FXDomain`.
      Parameters:
        `module` - The `Module` from which an `Injector` is created later.

  - ### Method Detail

    - #### createCanvas

          protected 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 org.eclipse.gef.graph.Edge createEdge(org.eclipse.jface.viewers.ILabelProvider labelProvider,
                                                          java.lang.Object contentSourceNode,
                                                          org.eclipse.gef.graph.Node sourceNode,
                                                          java.lang.Object contentTargetNode,
                                                          org.eclipse.gef.graph.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`.

    - #### createEdge

          protected org.eclipse.gef.graph.Edge createEdge(org.eclipse.jface.viewers.ILabelProvider labelProvider,
                                                          java.lang.Object contentEdgeNode,
                                                          org.eclipse.gef.graph.Node sourceNode,
                                                          org.eclipse.gef.graph.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 org.eclipse.gef.graph.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 void createNestedGraph(java.lang.Object contentNestingNode,
                                           org.eclipse.jface.viewers.IContentProvider contentProvider,
                                           org.eclipse.jface.viewers.ILabelProvider labelProvider)

    - #### createNestedGraph

          protected org.eclipse.gef.graph.Graph createNestedGraph(java.lang.Object contentNestingNode,
                                                                  org.eclipse.gef.zest.fx.jface.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`.

    - #### createNestedGraph

          protected org.eclipse.gef.graph.Graph createNestedGraph(java.lang.Object contentNestingNode,
                                                                  INestedGraphContentProvider 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 org.eclipse.gef.graph.Node createNode(java.lang.Object contentNode,
                                                          org.eclipse.jface.viewers.IContentProvider 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(org.eclipse.jface.viewers.IContentProvider contentProvider,
                                             org.eclipse.jface.viewers.ILabelProvider labelProvider,
                                             org.eclipse.gef.graph.Graph graph,
                                             java.lang.Object[] contentNodes)

    - #### createNodesAndEdges

          protected void createNodesAndEdges(org.eclipse.gef.zest.fx.jface.IGraphContentProvider graphContentProvider,
                                             org.eclipse.jface.viewers.ILabelProvider labelProvider,
                                             org.eclipse.gef.graph.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.

    - #### createNodesAndEdges

          protected void createNodesAndEdges(IGraphEdgeContentProvider graphContentProvider,
                                             org.eclipse.jface.viewers.ILabelProvider labelProvider,
                                             org.eclipse.gef.graph.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.

    - #### createNodesAndEdges

          protected void createNodesAndEdges(IGraphEntityRelationshipContentProvider graphContentProvider,
                                             org.eclipse.jface.viewers.ILabelProvider labelProvider,
                                             org.eclipse.gef.graph.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 org.eclipse.gef.graph.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,org.eclipse.gef.graph.Node> getContentNodeMap()

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

    - #### getControl

          public FXCanvas getControl()

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

    - #### getFXViewer

          public org.eclipse.gef.mvc.fx.viewer.IViewer getFXViewer()

      Returns the `FXViewer` that displays the contents.
      Returns:
        The `FXViewer` that displays the contents.

    - #### getLabelProvider

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

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

    - #### getLayoutAlgorithm

          public org.eclipse.gef.layout.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 org.eclipse.gef.mvc.fx.models.SelectionModel getSelectionModel()

      Retrieves the `SelectionModel` used by the viewer ( `getFXViewer()`)
      Returns:
        The `SelectionModel` adapted to the viewer ( `getFXViewer()`).

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

    - #### getRootGraph

          protected org.eclipse.gef.graph.Graph getRootGraph()

    - #### refresh

          public void refresh()

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

    - #### setLayoutAlgorithm

          public void setLayoutAlgorithm(org.eclipse.gef.layout.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.