【发布时间】:2018-12-04 12:32:13
【问题描述】:
最近我一直在将所有视角和视图从 RCP 3 移植到 RCP 4。我现在想在我的 RCP 4 应用程序中切换视角。
第一次转换为透视图后输出。
!MESSAGE Perspective with name 'perspective_label' and id 'PerspectiveName' has been made into a local copy
要切换视角我用这个
@Inject
private static MApplication app;
@Inject
private static EPartService partService;
@Inject
private static EModelService modelService;
@Inject
private static MWindow window;
private static void switchPerspective(final String id)
{
final Optional<MPerspective> perspective = PerspectiveSwitcherToolbar.findPerspective(id);
if(perspective.isPresent())
{
partService.switchPerspective(perspective.get());
}
else
{
System.out.println("Perspective not found");
}
}
private static Optional<MPerspective> findPerspective(final String perspectiveId)
{
final MUIElement element = modelService.find(perspectiveId, app);
if(element instanceof MPerspective)
{
perspectiveIdsToElement.put(perspectiveId, (MPerspective) element);
return Optional.of((MPerspective)element);
}
System.out.println("Wrong type " + element);
return Optional.empty();
}
在第一次调用切换视角时,它会正确更改。在第二次调用 findPerspective 时返回 empty()。
我发现这个问题似乎与完全相同的问题有关,但并没有解决问题。
Open Perspective programmatically
这可能是什么原因造成的?
【问题讨论】:
标签: java eclipse-rcp