gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 18:43:55 25 4
gpt4 key购买 nike

我在运行时创建一个 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。

如何去掉窗口?

最佳答案

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

hidePart(MPart) 通常只是隐藏该部件,但如果在部件标签中设置了 removeOnHide 值,则该部件也会被删除。

hidePart(MPart, true) 允许您强制删除,而不管标签如何。

编辑:

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

关于java - 如何以编程方式关闭 eclipse rcp 4 mwindow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18715369/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com