Package 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:
IInputProvider
,IInputSelectionProvider
,ISelectionProvider
public class ZestContentViewer extends ContentViewer
-
-
Field Summary
-
Fields inherited from class org.eclipse.jface.viewers.Viewer
WIDGET_DATA_KEY
-
-
Constructor Summary
Constructors Constructor Description ZestContentViewer(Module module)
Constructs a newZestContentViewer
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected javafx.embed.swt.FXCanvas
createCanvas(Composite parent, int style)
Creates anFXCanvas
inside of the given parentComposite
.void
createControl(Composite parent, int style)
Creates the control for thisZestContentViewer
inside of the given parentComposite
.protected Edge
createEdge(ILabelProvider labelProvider, java.lang.Object contentSourceNode, Node sourceNode, java.lang.Object contentTargetNode, Node targetNode)
Constructs and returns a newEdge
connecting the given sourceNode and targetNode.protected Graph
createEmptyGraph()
Constructs and returns a newGraph
and inserts default attributes into it: layout algorithmprotected Graph
createNestedGraph(java.lang.Object contentNestingNode, IGraphContentProvider graphContentProvider, ILabelProvider labelProvider)
Creates aGraph
nested in the node represented by the given contentNestingNode.protected Node
createNode(java.lang.Object contentNode, IGraphContentProvider graphContentProvider, ILabelProvider labelProvider)
protected void
createNodesAndEdges(IGraphContentProvider graphContentProvider, ILabelProvider labelProvider, Graph graph, java.lang.Object[] contentNodes)
protected Graph
createRootGraph(IContentProvider contentProvider, ILabelProvider labelProvider)
java.util.Map<java.lang.Object,Node>
getContentNodeMap()
Returns an unmodifiable view of the content-node-map.IViewer
getContentViewer()
Returns theIViewer
that displays the contents.javafx.embed.swt.FXCanvas
getControl()
ILabelProvider
getLabelProvider()
ILayoutAlgorithm
getLayoutAlgorithm()
Returns theILayoutAlgorithm
that is used for laying out the contents.ISelection
getSelection()
protected SelectionModel
getSelectionModel()
Retrieves theSelectionModel
used by the viewer (getContentViewer()
)protected void
handleDispose(DisposeEvent event)
protected void
inputChanged(java.lang.Object input, java.lang.Object oldInput)
void
refresh()
void
setLayoutAlgorithm(ILayoutAlgorithm layoutAlgorithm)
Changes theILayoutAlgorithm
that is used for laying out the contents to the given value.void
setSelection(ISelection selection, boolean reveal)
protected java.lang.String
toCssRgb(Color color)
Converts the givenColor
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
-
-
-
-
Constructor Detail
-
ZestContentViewer
public ZestContentViewer(Module module)
Constructs a newZestContentViewer
. The givenModule
is saved so that it can be later used to create anInjector
that is later used for the injection of members and the construction of theIDomain
.
-
-
Method Detail
-
createCanvas
protected javafx.embed.swt.FXCanvas createCanvas(Composite parent, int style)
Creates anFXCanvas
inside of the given parentComposite
. TheFXCanvas
serves acs the container for the JavaFXScene
which renders the contents.- Parameters:
parent
- The parentComposite
.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 thisZestContentViewer
inside of the given parentComposite
.- Parameters:
parent
- The parentComposite
.style
- The SWT style for thisZestContentViewer
, which will be forwarded to itsFXCanvas
control.
-
createEdge
protected Edge createEdge(ILabelProvider labelProvider, java.lang.Object contentSourceNode, Node sourceNode, java.lang.Object contentTargetNode, Node targetNode)
Constructs and returns a newEdge
connecting the given sourceNode and targetNode. If the labelProvider implementsIGraphAttributesProvider
, then attributes for the edge are determined using theIGraphAttributesProvider.getEdgeAttributes(Object, Object)
methods and inserted into the edge.- Parameters:
labelProvider
- This viewer'sILabelProvider
for convenience.contentSourceNode
- The content element representing the source node of this edge.sourceNode
- The already created sourceNode
of this edge.contentTargetNode
- The content element representing the target node of this edge.targetNode
- The already created targetNode
of this edge.- Returns:
- The new
Edge
.
-
createEmptyGraph
protected Graph createEmptyGraph()
Constructs and returns a newGraph
and inserts default attributes into it:- layout algorithm
- Returns:
- A new
Graph
with default attributes.
-
createNestedGraph
protected Graph createNestedGraph(java.lang.Object contentNestingNode, IGraphContentProvider graphContentProvider, ILabelProvider labelProvider)
Creates aGraph
nested in the node represented by the given contentNestingNode.- Parameters:
contentNestingNode
- The contentObject
that represents the nesting node.graphContentProvider
- This viewer'sIGraphContentProvider
for convenience.labelProvider
- This viewer'sILabelProvider
for convenience.- Returns:
- The new
Graph
.
-
createNode
protected Node createNode(java.lang.Object contentNode, IGraphContentProvider graphContentProvider, ILabelProvider labelProvider)
Creates aNode
for the specified contentNode using theIContentProvider
andILabelProvider
. Moreover, the new node is put into the given contentToGraphMap.- Parameters:
contentNode
- The contentObject
that represents the node.graphContentProvider
- This viewer'sIGraphContentProvider
for convenience.labelProvider
- This viewer'sILabelProvider
for convenience.- Returns:
- The new
Node
.
-
createNodesAndEdges
protected void createNodesAndEdges(IGraphContentProvider graphContentProvider, ILabelProvider labelProvider, Graph graph, java.lang.Object[] contentNodes)
- Parameters:
graphContentProvider
- This viewer'sIGraphContentProvider
for convenience.labelProvider
- This viewer'sILabelProvider
for convenience.graph
- TheGraph
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)
- Parameters:
contentProvider
- TheIContentProvider
for this viewer.labelProvider
- TheILabelProvider
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 theIViewer
that displays the contents.- Returns:
- The
IViewer
that displays the contents.
-
getControl
public javafx.embed.swt.FXCanvas getControl()
- Specified by:
getControl
in classViewer
-
getLabelProvider
public ILabelProvider getLabelProvider()
- Overrides:
getLabelProvider
in classContentViewer
-
getLayoutAlgorithm
public ILayoutAlgorithm getLayoutAlgorithm()
Returns theILayoutAlgorithm
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 interfaceISelectionProvider
- Specified by:
getSelection
in classViewer
-
getSelectionModel
protected SelectionModel getSelectionModel()
Retrieves theSelectionModel
used by the viewer (getContentViewer()
)- Returns:
- The
SelectionModel
adapted to the viewer (getContentViewer()
).
-
handleDispose
protected void handleDispose(DisposeEvent event)
- Overrides:
handleDispose
in classContentViewer
-
inputChanged
protected void inputChanged(java.lang.Object input, java.lang.Object oldInput)
- Overrides:
inputChanged
in classViewer
-
setLayoutAlgorithm
public void setLayoutAlgorithm(ILayoutAlgorithm layoutAlgorithm)
Changes theILayoutAlgorithm
that is used for laying out the contents to the given value.- Parameters:
layoutAlgorithm
- The newILayoutAlgorithm
to use.
-
setSelection
public void setSelection(ISelection selection, boolean reveal)
- Specified by:
setSelection
in classViewer
-
-