在子组合中嵌入一个zest图



我在Eclipse中有一个ViewPart,我想添加多个组合,每个zest图一个(用户可以选择性查看或隐藏),以及控件、标签和组合框。我一直在使用mxgraph来实现这一点,但mxgraph与eclipse ViewPart并不完全兼容,所以我想切换到Zest。

我尝试创建一个热情图,并将其添加到嵌入式复合中,如下所示:

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

但这并不奏效。

此外,我希望在zestGraph或GraphViewer上有一个方法,允许我在GridLayout中设置配置,并有一个更改父组件的方法。有可能做到这一点吗?

不能更改父组件-这是SWT的决定。

然而,如果我正确理解您的任务,您可以创建一个SWT SashForm,并将其用作Zest图及其相应的Composite with the Combos的容器。SashForm还有一个API,用于将其Sashe之一设置为唯一可见的组件(使用setMaximizedControl方法)。

所以您需要以下内容(未在编辑器中检查,仅显示基本想法:

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

这篇文章http://lowcoupling.com/post/58916245720/integrating-zest-with-xtext提供了关于如何创建描绘ZestGraph的Eclipse视图的详细解释和代码。在里面http://lowcoupling.com/post/58705347913/defining-a-work-breakdown-structure-through-the-wbs这里有一个如何使用它的例子。

最新更新