如何以编程方式关闭eclipse rcp 4 mwindow

uti.devel

我在运行时创建一个MWindow

MWindow window = _modelService.createModelElement(MWindow.class);
window.setWidth(200);
window.setHeight(300);
// add new Window to the application 
// @Inject
// MApplication _application;
_application.getChildren().add(window);

比我添加一部分

EModelService windowModelService = window.getContext().get(EModelService.class);
EPartService windowPartService = window.getContext().get(EPartService.class);

// find part if exists
MPart part = windowPartService.findPart("partId");

if (part == null) {
    // create if not exists
    part = windowPartService.createPart("partId");
}


// Required if initial not visible
part.setVisible(true);

// Show the part
MPart newPart = windowPartService.showPart(part, PartState.VISIBLE);

但我不知道在不再使用该窗口后如何关闭或处置它。Mwindow没有关闭/处置或退出功能。如果我尝试将其从应用程序子级中删除,我会得到npe。

如何摆脱窗户?

greg-449

使用EPartService.hidePart(MPart)hidePart(MPart, boolean)

hidePart(MPart)通常只隐藏零件,但如果removeOnHide在零件标签中设置值,则也会将其删除。

hidePart(MPart, true) 无论标签如何,都可以强制删除。

编辑:

要关闭该窗口调用,MWindow.setToBeRendered(false)该窗口将保留在应用程序模型中,但将处理资源等。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章