Class ZestContentViewer

All Implemented Interfaces:
IInputProvider, IInputSelectionProvider, ISelectionProvider

public class ZestContentViewer extends ContentViewer
The ZestContentViewer is a ContentViewer that is capable of displaying Graphs.
  • Constructor Details

    • 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 Details

    • createCanvas

      protected javafx.embed.swt.FXCanvas createCanvas(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(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(ILabelProvider labelProvider, Object contentSourceNode, Node sourceNode, 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(Object contentNestingNode, IGraphContentProvider graphContentProvider, 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(Object contentNode, IGraphContentProvider graphContentProvider, 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, ILabelProvider labelProvider, Graph graph, 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(IContentProvider contentProvider, 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 Map<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 Viewer
    • getLabelProvider

      public ILabelProvider getLabelProvider()
      Overrides:
      getLabelProvider in class 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 ISelection getSelection()
      Specified by:
      getSelection in interface ISelectionProvider
      Specified by:
      getSelection in class 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(DisposeEvent event)
      Overrides:
      handleDispose in class ContentViewer
    • inputChanged

      protected void inputChanged(Object input, Object oldInput)
      Overrides:
      inputChanged in class Viewer
    • refresh

      public void refresh()
      Specified by:
      refresh in class 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(ISelection selection, boolean reveal)
      Specified by:
      setSelection in class Viewer
    • toCssRgb

      protected String toCssRgb(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.