Java 如何以编程方式关闭EclipseRCP4mWindows
我在运行时使用Java 如何以编程方式关闭EclipseRCP4mWindows,java,eclipse,swt,eclipse-rcp,rcp,Java,Eclipse,Swt,Eclipse Rcp,Rcp,我在运行时使用 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); 然后我在上面加了一部分
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,布尔)
hidePart(MPart)
通常仅隐藏零件,但如果零件标记中设置了removeOnHide
值,则也会将其删除
hidePart(MPart,true)
允许您强制删除,而不考虑标记
编辑:
要关闭窗口,请调用
mWindows.setToBernedered(false)
窗口将保留在应用程序模型中,但资源等将被释放。使用EPartService.hidePart(MPart)
或hidePart(MPart,布尔)
hidePart(MPart)
通常仅隐藏零件,但如果零件标记中设置了removeOnHide
值,则也会将其删除
hidePart(MPart,true)
允许您强制删除,而不考虑标记
编辑:
要关闭窗口,请调用
MWindow.setToBerndered(false)
窗口将保留在应用程序模型中,但资源等将被释放。hidePart(MPart,true)从窗口中删除MPart。但我想移除或关闭窗户本身。只要窗口保持活动状态,应用程序就无法关闭。您可以调用“IWorkbench.close()”退出应用程序,而不管打开的窗口是什么。添加了窗口关闭信息IWorkbench.close(),从mwindow中调用它只关闭此mwindow,而不关闭应用程序?根据它应该真正关闭所有窗口。但它没有:(hidePart(MPart,true)从窗口中删除MPart。但我想删除或关闭窗口本身。只要窗口保持活动状态,应用程序就无法关闭。您可以调用“IWorkbench.close()”退出应用程序,而不管是否打开窗口。添加了窗口关闭信息IWorkbench.close()从mwindow中调用只关闭此mwindow,而不关闭应用程序?根据说明,它应该真正关闭所有窗口。但它不会:(