Class 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:
1.14
@noextend
This class is not intended to be subclassed by clients.
  • Constructor Details

    • AbstractStructuredGraphViewer

      protected AbstractStructuredGraphViewer(int graphStyle)
  • Method Details

    • 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:
    • 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:
    • 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 Graph getGraphControl()
    • getConnectionStyle

      public int getConnectionStyle()
      Returns:
      the connection style.
    • addConstraintAdapter

      public void addConstraintAdapter(ConstraintAdapter constraintAdapter)
      Adds a new constraint adapter to the list of constraints
      Parameters:
      constraintAdapter -
    • getConstraintAdapters

      public List<? extends ConstraintAdapter> getConstraintAdapters()
      Gets all the constraint adapters currently on the viewer
    • setLayoutAlgorithm

      public abstract void setLayoutAlgorithm(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 LayoutAlgorithm getLayoutAlgorithm()
      Gets the current layout algorithm.
      Returns:
      the current layout algorithm.
    • setLayoutAlgorithm

      public void setLayoutAlgorithm(LayoutAlgorithm algorithm)
      Equivalent to setLayoutAlgorithm(algorithm, false).
      Parameters:
      algorithm -
    • getNodeElements

      public Object[] getNodeElements()
    • getConnectionElements

      public Object[] getConnectionElements()
    • getNodesMap

      public Map<Object,GraphNode> getNodesMap()
      @noreference
      This method is not intended to be referenced by clients.
    • addGraphModelContainer

      public GraphNode addGraphModelContainer(Object element)
      @noreference
      This method is not intended to be referenced by clients.
    • addGraphModelNode

      public GraphNode addGraphModelNode(IContainer container, Object element)
      @noreference
      This method is not intended to be referenced by clients.
    • createNodeObject

      protected GraphNode createNodeObject(Graph graphModel, IFigure figure)
      Implement and return the new node object, enables to define custom graph nodes
      Parameters:
      graphModel - where the created nodes gets added to
      figure - of the created node object
      Returns:
      instance of a GraphNode
      Since:
      1.7
    • createConnectionObject

      protected GraphConnection createConnectionObject(Graph graphModel, GraphNode source, GraphNode destination)
      Implement and return the new connection object, enables to define custom graph connections
      Parameters:
      graphModel - where the created nodes gets added to
      source - GraphNode
      destination - GraphNode
      Returns:
      instance of a GraphConnection
      Since:
      1.7
    • addGraphModelNode

      public GraphNode addGraphModelNode(Object element, IFigure figure)
      @noreference
      This method is not intended to be referenced by clients.
    • addGraphModelConnection

      public GraphConnection addGraphModelConnection(Object element, GraphNode source, GraphNode target)
      @noreference
      This method is not intended to be referenced by clients.
    • getGraphModelConnection

      public GraphConnection getGraphModelConnection(Object obj)
      @noreference
      This method is not intended to be referenced by clients.
    • getGraphModelNode

      public GraphNode getGraphModelNode(Object obj)
      @noreference
      This method is not intended to be referenced by clients.
    • removeGraphModelConnection

      public void removeGraphModelConnection(Object obj)
      @noreference
      This method is not intended to be referenced by clients.
    • removeGraphModelNode

      public void removeGraphModelNode(Object obj)
      @noreference
      This method is not intended to be referenced by clients.
    • internalRefresh

      protected void internalRefresh(Object element)
      Specified by:
      internalRefresh in class StructuredViewer
    • doUpdateItem

      protected void doUpdateItem(Widget item, Object element, boolean fullMap)
      Specified by:
      doUpdateItem in class StructuredViewer
    • doFindInputItem

      protected Widget doFindInputItem(Object element)
      Specified by:
      doFindInputItem in class StructuredViewer
    • doFindItem

      protected GraphItem doFindItem(Object element)
      Specified by:
      doFindItem in class StructuredViewer
    • getSelectionFromWidget

      protected List<Object> getSelectionFromWidget()
      Specified by:
      getSelectionFromWidget in class StructuredViewer
    • findItems

      protected GraphItem[] findItems(List<Object> l)
    • setSelectionToWidget

      protected void setSelectionToWidget(List l, boolean reveal)
      Specified by:
      setSelectionToWidget in class StructuredViewer
    • getWidgetSelection

      protected List<? extends GraphItem> getWidgetSelection()
      Gets the internal model elements that are selected.
    • inputChanged

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

      protected abstract org.eclipse.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.
      @nooverride
      This method is not intended to be re-implemented or extended by clients.
      @noreference
      This method is not intended to be referenced by clients.
    • filterVisuals

      protected void filterVisuals()
    • getRawChildren

      protected Object[] getRawChildren(Object parent)
      Overrides:
      getRawChildren in class StructuredViewer
    • reveal

      public void reveal(Object element)
      Specified by:
      reveal in class StructuredViewer
    • unReveal

      public void unReveal(Object element)
    • applyLayout

      public abstract void applyLayout()
      Applies the viewers layouts.
    • removeRelationship

      public void removeRelationship(Object connection)
      Removes the given connection object from the layout algorithm and the model.
      Parameters:
      connection -
    • addNode

      public void addNode(Object element)
      Creates a new node and adds it to the graph. If it already exists nothing happens.
      Parameters:
      element -
    • removeNode

      public void removeNode(Object element)
      Removes the given element from the layout algorithm and the model.
      Parameters:
      element - The node element to remove.
    • addRelationship

      public void addRelationship(Object connection, Object srcNode, 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(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(Graph graph)
      Converts the list of GraphModelConnection objects into an array and returns it.
      Returns:
      GraphModelConnection[]
    • getNodesArray

      protected GraphNode[] getNodesArray(Graph graph)
      Converts the list of GraphModelNode objects into an array an returns it.
      Returns:
      GraphModelNode[]