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.


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


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.


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.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.


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).


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


Remember, an e4 programmatic alternative is more flexible!


3.) Related questions

These would be rendered deprecated for the e4 release.


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.


1 个解决方案



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




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