猿问

如果视图已分离,则活动透视图为空

如果我右键单击并分离视图,modelService.getActivePerspective(window)则开始返回 null。这意味着重置透视图无法正常工作。


如果视图未分离,则它可以正常工作。我在想,当一个新窗口打开时,它正在传递一个不包含透视图的不同窗口。


例子


public class ResetPerspectiveHandler {

    @Execute

    public static void resetPerspective(final MApplication app, final EPartService partService,

        final EModelService modelService, final MWindow window) {


    // Prints null

    System.out.println(modelService.getActivePerspective(window));


    PerspectiveSnippetsCopier.resetPerspective(modelService, partService, app, window,

        modelService.getActivePerspective(window).getElementId());

    }

}

是什么原因造成的?


莫回无
浏览 122回答 1
1回答

一只斗牛犬

的代码getActivePerspective是:public MPerspective getActivePerspective(MWindow window) {&nbsp; &nbsp; List<MPerspectiveStack> pStacks = findElements(window, null, MPerspectiveStack.class);&nbsp; &nbsp; if (pStacks.size() == 1) {&nbsp; &nbsp; &nbsp; &nbsp; MPerspective perspective = pStacks.get(0).getSelectedElement();&nbsp; &nbsp; &nbsp; &nbsp; return perspective;&nbsp; &nbsp; }&nbsp; &nbsp; return null;}所以它希望在给定的窗口中找到一个MPerspectiveStack,大概是分离的窗口没有这个。您可以尝试在应用程序中查找主窗口,而不是使用当前窗口。MWindow mainWindow = (MWindow)modelService.find("main window id", app);
随时随地看视频慕课网APP

相关分类

Java
我要回答