/** Ask if user wants to save before exiting. */ public boolean onPreWindowClose(ApplicationWindow window) { boolean exit = true; final Household household = (Household) beanFactory.getBean("household"); // Only show dialog for saving before exiting if any data has been // changed if (household.hasChanged()) { final String question = getApplicationServices() .getMessages() .getMessage("gui.mainFrame.saveModificationsQuestion"); final int option = JOptionPane.showConfirmDialog(window.getControl(), question); // If user choses yes try to save. If that fails do not exit. if (option == JOptionPane.YES_OPTION) { ActionCommand command = window.getCommandManager().getActionCommand("saveCommand"); command.execute(); } else if (option == JOptionPane.CANCEL_OPTION) { exit = false; } } return exit; }
public void onCommandsCreated(ApplicationWindow window) { ActionCommand command = window.getCommandManager().getActionCommand("loadCommand"); command.execute(); super.onCommandsCreated(window); }