1

我正在 Eclipse 4.2 中创建一个 RCP。在我的 RCP 中,我有 3 个观点。
我在运行时创建一个部分,并以如下方式添加它。

@Inject
EPartService partService;
@Inject
MApplication application;    
...

Mpart part = .... ;    
...

List<MPartStack> stacks = modelService.findElements(application, null, MPartStack.class, null);
stacks.get(0).getChildren().add(part);
partService.showPart(part, PartState.ACTIVATE);

但问题是它在当前打开的透视图中添加了视图,因此如果您将透视图切换到其他视图,则不会显示该视图,这是正确的,因为我只是将其添加到第一个堆栈。
但我的要求是应该在每个角度添加它,所以如果它切换到其他角度,它应该在那里。

我得到如下 MPerspective 列表:

List<MPerspective> mPerspective = modelService.findElements(application, null, MPerspective.class, null);       

但是不知道怎么加。

那么如何在每个透视图中添加Part。?

谢谢

4

1 回答 1

0

In Eclipse 3.x there was the concept of StickyViews, and you might still be able to use it via the compatibility layer. However, the Eclipse 4 application model is much more flexible, and there should be several ways you can add such a 'sticky' MPart.

In the screenshot below you can see that in your Application.e4xmi you can have several Perspective Stacks, and even Mparts or MPartStacks on the same level. In your example above you can simply add the MPart to a second MPartStack that is on the same level in the application model as your Perspective Stack:

stacks.get(1).getChildren().add(part);

Application.e4xmi

于 2013-02-24T12:14:26.983 回答