uti*_*vel 1 java eclipse rcp swt eclipse-rcp
我在运行时创建一个 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);
Run Code Online (Sandbox Code Playgroud)
比我添加一个部分
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);
Run Code Online (Sandbox Code Playgroud)
但我不知道在不再使用该窗口后如何关闭或处置它。Mwindow 没有关闭/处置或退出功能。如果我尝试简单地从应用程序中删除它,我会得到 npe。
如何摆脱窗户?
使用EPartService.hidePart(MPart)或hidePart(MPart, boolean).
hidePart(MPart)通常只是隐藏该部分,但如果removeOnHide在部分标签中设置了该值,那么它也会被删除。
hidePart(MPart, true)让您无论标签如何都强制删除。
编辑:
要关闭窗口,调用MWindow.setToBeRendered(false)窗口将保留在应用程序模型中,但资源等将被释放。
| 归档时间: |
|
| 查看次数: |
2703 次 |
| 最近记录: |