Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Showing a Graph Zest inside of a Group widget(How to show a Graph zest in a SWT widget)
Showing a Graph Zest inside of a Group widget [message #1760625] Sat, 29 April 2017 03:19 Go to next message
Daniel San Martín is currently offline Daniel San MartínFriend
Messages: 45
Registered: October 2012
Member
Hello,

I have created a Graph with Zest but I want to show it inside of my main window. This window has several components (a tabfolder and tabitems) and a button as is shown in the figure.

index.php/fa/29183/0/

I also create a Group widget called (Graph Result) and my ideia is to show my graph inside this group, but I do not know how to do it.

The following version of the code inside of the button works.
Display display = Display.getDefault();
ChildShell childShell = new ChildShell(display);
Algorithm algorithm = new Algorithm(xx, projectName, xx);
algorithm.createPartControl(childShell.getShell());
childShell.open();


But opens a new window. I thought this code could work but nothing happens:

Algorithm algorithm = new Algorithm(xx, projectName, xx);
MetricGraph mg = new MetricGraph(algorithm.getFanIn());
mg.createPartControl(graphGroup);


Is it possible to perform what i am thinking?

My MetricGraph class extends ViewPart.

Thank you!,

Daniel.



Re: Showing a Graph Zest inside of a Group widget [message #1760629 is a reply to message #1760625] Sat, 29 April 2017 06:14 Go to previous messageGo to next message
Zoltan Ujhelyi is currently offline Zoltan UjhelyiFriend
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 Go to previous message
Daniel San Martín is currently offline Daniel San MartínFriend
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

Previous Topic:Trouble with Connection Content Parts (GEF4 0.4.0)
Next Topic:Drag & drop in parent - child relation
Goto Forum:
  


Current Time: Thu Apr 25 23:48:00 GMT 2024

Powered by FUDForum. Page generated in 0.03640 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top