Embed a zest graph in a sub composite

590 Views Asked by At

I have a ViewPart in Eclipse that I want to add multiple composites, one per zest graph (that can be selective viewed or hidden by the user) along with controls, labels and combo boxes. I have been working with mxgraph to do this, but mxgraph is not fully compatible with the eclipse ViewPart, so I want to switch to Zest.

I have tried to create a zest graph and add it into an embedded composite as:

m_swtAwtComponent1 = new Composite(m_parentComposite, SWT.EMBEDDED);
m_swtAwtComponent1.setLayoutData(grid);
viewer = new GraphViewer(m_swtAwtComponent1, SWT.NONE);

But this does not work.

Also, I would "like" a method on the zest Graph or on the GraphViewer that would allow me set the configuration within GridLayout and a method to change the parent component. Is it possible to do this?

2

There are 2 best solutions below

0
On

The parent component cannot be changed - that is an SWT decision.

However, if I understand correctly your task, you could create an SWT SashForm, and use that as the container of both the Zest graph and its corresponding Composite with the Combos. The SashForm also has an API to set one of its Sashes the only visible component (with the setMaximizedControl method).

So you would need something like follows (not checked in editor, only showing the basic idea:

SashForm form = new SashForm(parent, SWT.HORIZONTAL);
viewer = new GraphViewer(form, SWT.NONE);
//Note that no layout is set here!
Composite controls = new Composite(form, SWT.NONE);
//TODO load your control widgets inside this composite
form.setWeights(new int[]{2,1}); //Making the graph use more area then the widgets
0
On

this post http://lowcoupling.com/post/58916245720/integrating-zest-with-xtext provides a detailed explanation, and code, on how to create an Eclipse view depicting a Zest Graph. In http://lowcoupling.com/post/58705347913/defining-a-work-breakdown-structure-through-the-wbs there is an example of how it has been used.