我有一个 Eclipse E4 应用程序。应用程序当前正在激活打开时链接到特定透视的所有 MPart。现在我发现打开一个新的视角需要很长时间(大约20多岁)。所以我正在重构代码以加快打开视角的速度。
我激活它们是因为否则 mPart 不会监听 EventBroker 事件。 我激活部件的代码如下所示:
public void makeAllActive(MPerspective perspective) {
List<MPart> part = service.findElements(application, null, MPart.class, null);
List<MPartStack> mainPartStack = service.findElements(application, "partstack.shared", MPartStack.class, null);
if (!mainPartStack.isEmpty()) {
for (int i = part.size() - 1; i >= 0; i--) {
List<MPart> children = service.findElements(mainPartStack.get(0), part.get(i).getElementId(),
MPart.class, null);
if (!children.contains(part.get(i))) {
this.partService.activate(part.get(i));
}
}
}
}
此外,当用户切换多个视角并返回到第一个视角时,所选部分将不会位于所有其他部分之上。这也不是真正的用户友好。
有没有办法激活透视图中的所有部分,以便这些部分可以监听 eventBroker 事件?
最佳答案
假设您想要在应用程序启动时打开所有对话框。理论上是可能的,但从用户角度来看会导致非常意想不到的事情。事实上,您的请求非常相似,因为您希望激活所有 MPart。
All the data must be loaded so that if the user select a tab it does show its data insantly (without calling the backend server again)
因此,您希望预取所有数据。此问题与 MPart 激活无关。您需要创建一些服务,它将为您执行所有后端调用。然后每个 MPart 将只渲染可用的结果。
关于java - 让MPart监听eventBroker事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56489774/