Handle the closing of the workbench window in Java RCP application
I'm writing an Eclipse RCP and I want to ask the user whether to backup the database when the application is closed. Doing it from the File>Exit menu was easy as I defined a command exit: public class ExitCommand extends AbstractHandler implements IHandler { @Override public Object execute(ExecutionEvent event) throws ExecutionException { final IWorkbench workbench = PlatformUI.getWorkbench(); if (workbench == null) return null; // Ask whether the user wants to back up the information Shell shell = new Shell(workbench.getDisplay()); MessageBox messageBox = new MessageBox(shell, SWT.ICON