Eclipse RCP -在编辑器区域中打开一个视图(3.8/e4混合)

时间:2023-01-21 15:28:17

I'm working on a 3.8-e4 hybrid (i.e we have the Luna dependencies, but we do not use the Application.e4xmi, yet). So we're basically running the compact layer.

我正在做一个3.8-e4混合动力车。我们有Luna依赖项,但我们不使用应用程序。然而,e4xmi)。我们运行的是压缩层。

With that being said, it would be nice to find an e4 programmatic way to stack these nasty views onto the editor folder.

说到这里,最好找到一种e4编程方式将这些讨厌的视图堆叠到编辑器文件夹中。


1.) Problem

I want to place a generic view folder in the editor area, so that each view which is opened at runtime will be opened there.

我想在编辑器区域中放置一个通用视图文件夹,以便在运行时打开的每个视图都将在那里打开。

Eclipse RCP -在编辑器区域中打开一个视图(3.8/e4混合)

(pic stolen from this question)

(图片被偷)


2.1) Possible fix no.1: Using plugin.xml

Create a perspective extension, and add each possible view to that extension, with relationship stack over relative org.eclipse.ui.editorss. This is a bit inconvenient if you have too many views awating to be opened, and if the project scales quickly. I also noticed that wildcard view IDs do not work here.

创建一个透视图扩展,并将每个可能的视图添加到该扩展中,并在相对的org.eclipse.ui.editorss中使用关系堆栈。如果您有太多要打开的视图,并且项目快速扩展,这就有点不方便了。我还注意到通配符视图id在这里不起作用。

Eclipse RCP -在编辑器区域中打开一个视图(3.8/e4混合)

If you find yourself the time to add each possible view to the perspective extension, that would work. Although, IF you open a view which is not added here (ie: opens in a different folder), then each subsequent opened view will be opened in the previous folder, and NOT in the editor area (inquire further explanation if you don't get it).

如果您发现自己有时间将每个可能的视图添加到透视图的扩展中,那么这将起作用。但是,如果您打开一个未添加到这里的视图(即:在另一个文件夹中打开),则随后打开的每个视图将在前一个文件夹中打开,而不是在编辑器区域中(如果您不了解的话,请进一步解释)。


2.2) Possible fix no.2: Using code in the perspective factory

In the IPerspectiveFactory, we do have access to the IPageLayout, which happens to be org.eclipse.ui.internal.e4.compatibility.ModeledPageLayout (e4 stuff).

在iperspective tivefactory中,我们确实可以访问IPageLayout,它正好是org. eclipsee .ui. ui.internal.e4. compatibility.modeledpagelayout (e4之类的)。

Now, this ModeledPageLayout implementation is reasonable, but also no documentation and weird public APIs. This one gives the possibility to stack a view over any other relative

现在,这个ModeledPageLayout实现是合理的,但是没有文档和奇怪的公共api。这一项提供了将视图堆叠到任何其他相关项之上的可能性

modeledPageLayout.stackView("newView0", IPageLayout.ID_EDITOR_AREA);

This would be the programmatic version of 2.1. Also, the same problem appears here. If a view is opened somewhere else, the code above becomes useless.

这将是2.1的程序化版本。同样的问题也出现在这里。如果在其他地方打开了视图,上面的代码将变得无用。

Interesting enough, the stackView API does not support wildcards (while others such as addView do).

有趣的是,stackView API不支持通配符(而其他API如addView则支持通配符)。


2.3) Possible fix no.3: Workarounds yaaay!

I have a lot of perspectives, and a lot of different folders in each one. Everything is precisely placed.

我有很多不同的观点,而且每一个都有很多不同的文件夹。一切都是精确地放置。

Since Eclipse offers the APIs to get all the view IDs from everywhere around the system, I want to do the following, per perspective: each view ID which wasn't added to a specific folder will be appended to the editor area (ie editor folder, editor stack).

由于Eclipse提供了从系统各处获取所有视图ID的api,因此我希望按照每个透视图执行以下操作:未添加到特定文件夹的每个视图ID将被追加到编辑器区域(即编辑器文件夹、编辑器堆栈)。

This would be my last resort, unless someone offers a more convenient and timesaving solution.

这将是我最后的选择,除非有人提供一个更方便省时的解决方案。

Remember, an e4 programmatic alternative is more flexible!

记住,e4编程替代方案更灵活!


3.) Related questions

These would be rendered deprecated for the e4 release.

对于e4版本来说,这些都是不赞成的。


4.) Related Bug on Eclipse's Bugzilla:

This recent bug opened by myself has an attachment with a small SSCCE. The steps to reproduce this are described in this comment, so I'm not going to copy-paste them here.

我最近打开的这个bug有一个小SSCCE附件。复制它的步骤在注释中有描述,所以我不会在这里复制粘贴它们。

1 个解决方案

#1


1  

I suggest you go with Possible fix no.3, since i think there isn't a faster method to do this.

我建议你用可能的方法去做。既然我认为没有比这更快的方法了。

#1


1  

I suggest you go with Possible fix no.3, since i think there isn't a faster method to do this.

我建议你用可能的方法去做。既然我认为没有比这更快的方法了。