Home » Eclipse Projects » GEF » Showing a Graph Zest inside of a Group widget(How to show a Graph zest in a SWT widget)
|
Re: Showing a Graph Zest inside of a Group widget [message #1760629 is a reply to message #1760625] |
Sat, 29 April 2017 06:14 |
Zoltan Ujhelyi Messages: 392 Registered: July 2015 |
Senior Member |
|
|
Hi,
I am sorry, but given your code snippets and description it is unclear to me what do you want to achieve here, e.g. I have no idea what is an Algorithm or a MetricGraph.
However, Zest graph can easily be included in any kind of SWT composite the following way:
* Zest 1.x (SWT): new Graph(composite, SWT.NONE);
* Zest 1.x (JFace): new GraphViewer(composite, SWT.NONE);
* GEF 5 Zest (JFace): viewer = new ZestContentViewer(); viewer.createControl(composite, SWT.NONE);
I hope this helps; if not, please try to clarify the question.
Best regards,
Zoltán
|
|
|
Re: Showing a Graph Zest inside of a Group widget [message #1760643 is a reply to message #1760625] |
Sat, 29 April 2017 14:52 |
Daniel San Martín Messages: 45 Registered: October 2012 |
Member |
|
|
Hello Zoltan,
Sorry by the explanation, I 'll try to be more accurate:
Algorithm class contains several methods that returns software metrics. One of them is the fanIn metric and I want to graph it (dependencies of methods). So this method, algorithm.getFanIn(), return a list of strings that I want to graph. For example, one string is conformed as nameMethodCall ---> nameMethodCalled.
The MetricGraph class graphs the strings above. I took the example from this site http://www.vogella.com/tutorials/EclipseZest/article.html
public void createPartControl(Composite parent)
{
List<String> nodes = null;
try {
nodes = this.getCalls();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (QueryException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
// Graph will hold all other objects
graph = new Graph(parent, SWT.NONE);
for (String node : nodes)
{
String from = node.split("\\|")[0];
String to = node.split("\\|")[1];
GraphNode node1 = null;
GraphNode node2 = null;
if (contains(graph.getNodes(), from) == false)
node1 = new GraphNode(graph, SWT.NONE, from);
else
node1 = searchNode(graph.getNodes(), from);
if (contains(graph.getNodes(), to) == false)
node2 = new GraphNode(graph, SWT.NONE, to);
else
node2 = searchNode(graph.getNodes(), to);
// Change line color and line width
GraphConnection graphConnection = new GraphConnection(graph, ZestStyles.CONNECTIONS_DIRECTED, node1, node2);
graphConnection.changeLineColor(parent.getDisplay().getSystemColor(SWT.COLOR_GREEN));
// Also set a text
graphConnection.setText("This is a text");
graphConnection.setHighlightColor(parent.getDisplay().getSystemColor(SWT.COLOR_RED));
graphConnection.setLineWidth(3);
//graph.setLayoutAlgorithm(new CompositeLayoutAlgorithm(LayoutStyles.NO_LAYOUT_NODE_RESIZING, new LayoutAlgorithm[] { new DirectedGraphLayoutAlgorithm(LayoutStyles.NO_LAYOUT_NODE_RESIZING), new HorizontalShift(LayoutStyles.NO_LAYOUT_NODE_RESIZING) }),false);
graph.setLayoutAlgorithm(new TreeLayoutAlgorithm(LayoutStyles.NO_LAYOUT_NODE_RESIZING), true);
//graph.setLayoutAlgorithm(new SpringLayoutAlgorithm(LayoutStyles.NO_LAYOUT_NODE_RESIZING), true);
// Selection listener on graphConnect or GraphNode is not supported
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=236528
graph.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
System.out.println(e);
}
});
}
}
This class (MetricGraph) extends ViewPart as the example of Vogella. In the main window of my plugin I want to graph the result of the fainIn metric:
//An instance of the metric class
Algorithm algorithm = new Algorithm(xx, projectName, xx);
//An instance of the graph class by passing the list of strings
MetricGraph mg = new MetricGraph(algorithm.getFanIn());
//I want to graph the metric in a Group composite called graphGroup
mg.createPartControl(graphGroup);
It is clear that there is something that I do not understand. How can I graph the metric inside my graphGroup composite?
I can graph it in a new Shell called ChildShell by using this code:
btnFCA.addSelectionListener(new SelectionAdapter()
{
public void widgetSelected(SelectionEvent e)
{
Display display = Display.getDefault();
ChildShell childShell = new ChildShell(display);
Algorithm algorithm = new Algorithm(kdmFileFolder, projectName, kdmFile);
algorithm.createPartControl(childShell.getShell());
childShell.open();
}
});
But of course, it opens another window.
I hope this explanation be better.
Than you,
Daniel.
[Updated on: Sat, 29 April 2017 15:53] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Sat Dec 14 17:47:56 GMT 2024
Powered by FUDForum. Page generated in 0.04836 seconds
|