Open a View in the Editor Area (3.8/e4 hybrid)
I'm working on a 3.8-e4 hybrid (ie 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.
(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.
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).
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).
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.
我建议你去可能的修复3号,因为我认为没有一个更快的方法来做到这一点。
链接地址: http://www.djcxy.com/p/18690.html