如何将 GEF 编辑器添加到我的多页编辑器? (Eclipse RCP)
我想将图形编辑器添加到多页编辑器中。然而,当我简单地调用
addPage(new MyEditor());
addPages() 内部时,我就遇到了错误。由于我的 GEF 编辑器扩展了 GraphicalEditor,因此它也无法扩展 FormPage。所以,我让它实现了 IFormPage。但是,我仍然收到错误,实际上它说我用于多页编辑器的编辑器无法转换为与我的图形编辑器相对应的编辑器。
那么,最后我们如何将 GEF 编辑器添加到多页编辑器中呢?
有什么提示可以解决这个问题吗?
I would like to add a GraphicalEditor to a multipage editor. However, when I simply call
addPage(new MyEditor());
inside addPages(), I have an error since. Since my GEF editor extends GraphicalEditor, it cannot extend also FormPage. So, I made it implement IFormPage. But, I still get errors, actually it says that the editor that I'm using for the multipage editor cannot be cast to the one that corresponds to the my graphical editor.
So, finally How can we add a GEF editor to the multipage editor?
Any hint please to solve that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下是我为成功将 gef 编辑器添加到多页编辑器而完成的步骤:
扩展将 org.eclipse.gef.ui.parts.ScrollingGraphicalViewer 作为成员的 org.eclipse.ui.part.EditorPart。
公共类 GraphEditorPage 扩展了 EditorPart
{
私人SPEEditor编辑器;
私有 ScrollingGraphicalViewer 查看器;
...
}
createPartControl
中,您需要布局编辑器部分,在我的例子中,我使用 SashForm 作为父组件来完成此操作,之后,在父组件上为图形查看器创建控件。< /p>在方法
createPages()
中,创建一个 GraphEditorPage 并添加它私有无效initGraphPage()
{
graphPage = new GraphEditorPage(this);
addPage(0, graphPage, "图表");
}
这有帮助!
These are steps that I have done to add gef editor to multipage editor successfully:
Extend org.eclipse.ui.part.EditorPart that have org.eclipse.gef.ui.parts.ScrollingGraphicalViewer as a member.
public class GraphEditorPage extends EditorPart
{
private SPEEditor editor;
private ScrollingGraphicalViewer viewer;
...
}
In method
createPartControl
you need to layout the editor part, in my case, I did it with a SashForm as parent component, after that, create controls for you graphical viewer on parent component.In method
createPages()
, create an GraphEditorPage and add itprivate void initGraphPage()
{
graphPage = new GraphEditorPage(this);
addPage(0, graphPage, "Diagram");
}
Hope this help!