GEF - 如何在 Composite 中打开编辑器?

发布于 2024-07-17 16:20:21 字数 1721 浏览 10 评论 0原文

我的名字是 Oleg,我正在编写高级功能 - BPEL 文件的可视化比较。 我想在“比较”窗格(左和右)中使用常规编辑器 作为第一步,我只想打开两个编辑器(每个文件一个) 稍后我可以对它们进行一些“破解”,使新部件变得绿色, 删除了红色部分等...

所以我的问题听起来很简单 我有: - 合成的 - 描述 .bpel 文件的资源 我必须为此组合中的该资源打开默认编辑器。

我将不胜感激任何提示或建议!

我尝试了什么:

我花了几天时间试图更深入地了解 GEF, 但毕竟我没有找到任何简单的解决方案 简单的问题。

另一个项目的人使用:

  • org.eclipse.gmf.runtime.notation.Diagram
  • org.eclipse.gmf.runtime.diagram.ui.parts.DiagramGraphicalViewer
  • diagramGraphicalViewer .setContents(diagram)

但我的编辑器是基于 GEF 的,而不是基于 GMF 的。

据我了解,我不能只在复合中打开编辑器 我必须使用很多“额外”的东西 - EditorManager, Workbrenchs,一些网站等等。

毕竟我写了一些简单的代码,但它没有 工作。 可能我写的方式完全错误,但是让 我引用它只是为了弄清楚我真正需要什么。

File file2open = new File(new Path("/p1/name2.bpel"), (Workspace) BPELPlugin.getPlugin().getWorkspace()) { };
BPELMultipageEditorPart editorPart = new BPELMultipageEditorPart();
FileEditorInput editorInput = new FileEditorInput(file2open);
EditorDescriptor editorDescriptor = null;
try {
   editorDescriptor = (EditorDescriptor)IDE.getEditorDescriptor(file2open);
} catch (PartInitException e) {
   e.printStackTrace();
}
WorkbenchPage workbrenchpage = (WorkbenchPage)   PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
EditorSite editorSite = new EditorSite(new EditorReference(workbrenchpage.getEditorManager(), editorInput, editorDescriptor), editorPart, workbrenchpage, editorDescriptor);
try {
 editorPart.init(editorSite, editorInput);
} catch (PartInitException e) {
 e.printStackTrace();
}
editorPart.createPartControl(mycomposite);

更新:终于我实现了我想要的,但不确定其他人是否感兴趣:)

My name is Oleg, I'm writing advanced feature - visual comparison of BPEL files.
I would like to use regular editors in "compare" panes (left and right)
As a first step I just want to open two editors (one for each file)
Later I can 'hack' them a little, make new parts green,
deleted parts red etc...

So my problem sounds pretty simple
I have:
- Composite
- Resource which describes .bpel file
And I gotta to open default editor for this Resource in this Composite.

I would appreciate any tips or suggestions!

What did I tried:

I've spent couple days trying to deeper understand GEF,
but after all I didn't found any simple solution for my
simple problem.

People from another project used:

  • org.eclipse.gmf.runtime.notation.Diagram
  • org.eclipse.gmf.runtime.diagram.ui.parts.DiagramGraphicalViewer
  • diagramGraphicalViewer.setContents(diagram)

but my editor is GEF-based, not GMF-based.

As far as I understood I can't just open editor in composite
I have to use a lot of "extra" stuff - EditorManager,
Workbrenchs, some sites etc. etc.

After all I wrote some straightforward code but it doesn't
work. Likely I wrote it in absolutely wrong way, but let
me quote it just to make clear what do I actually need.

File file2open = new File(new Path("/p1/name2.bpel"), (Workspace) BPELPlugin.getPlugin().getWorkspace()) { };
BPELMultipageEditorPart editorPart = new BPELMultipageEditorPart();
FileEditorInput editorInput = new FileEditorInput(file2open);
EditorDescriptor editorDescriptor = null;
try {
   editorDescriptor = (EditorDescriptor)IDE.getEditorDescriptor(file2open);
} catch (PartInitException e) {
   e.printStackTrace();
}
WorkbenchPage workbrenchpage = (WorkbenchPage)   PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
EditorSite editorSite = new EditorSite(new EditorReference(workbrenchpage.getEditorManager(), editorInput, editorDescriptor), editorPart, workbrenchpage, editorDescriptor);
try {
 editorPart.init(editorSite, editorInput);
} catch (PartInitException e) {
 e.printStackTrace();
}
editorPart.createPartControl(mycomposite);

upd: finally I've implemented what I wanted, but not sure if someone else is interested :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

≈。彩虹 2024-07-24 16:20:21

不,没有在 GEF 查看器中打开编辑器的好方法。 记住:
1.“编辑器”是Eclipse平台的概念。 也就是说,它不仅仅是一个小部件,而是一个完整的基础设施。 正如您所说 - 您将需要 IEditorSite 等。
2. GEF 数据是“轻量级”的。 整个 GraphicalViewer 是一个单一的 SWT 小部件,并且在其上绘制图形 - 它们没有操作系统小部件支持。

因此,如果您确实需要在 GEF 查看器中嵌套编辑器,则必须将 SWT 组合放在查看器顶部并管理其位置。

No, there's no good way to open editor in GEF viewer. Keep in mind:
1. "Editor" is Eclipse platform concept. I.e. it is not just a widget but a whole infrastructure. As you said - you would need IEditorSite and so on.
2. GEF figures are "lightweight". You whole GraphicalViewer is a single SWT widget and figures are drawn on it - they don't have OS widgets backing them.

So if you really need to nest an editor in GEF viewer you would have to place the SWT composite on top of viewer and manage its placement.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文