Previously in our 3.x code we would do this.
new IWorkbenchListener{
@Override
public boolean preShutdown(final IWorkbench workbench, final boolean forced) {
if (forced) {
return true;
}
//Logic here to determine if we really want the workbench to close.
}
}
I couldn't find a e4 workbench listener but I did find a IWindowCloseListener
new IWindowCloseHandler {
@Override
public boolean close(final MWindow window) {
//Logic here to determine if we want the window to close.
}
}
The only problem with the IWindowCloseListener is that I can't find a way to determine if the window is being forced closed. I would assume that if the workbench is being forced closed that the window would also be forced closed.
Is there a way to determine if the MWindow is being forced closed?
I checked the org.eclipse.e4.ui.workbench.IWorkbench API and it only has a run() and close() method. I didn't see any way to attach some sort listener to it that is comparable to the 3.x IWorkbenchListener, so that is why I converted from the Workbench to the MWindow.