/** shuts down the UI, including db backup */ public static void shutDownUI() { // prompt for shutdown and backup options boolean do_backup = false; boolean backup_email = false; final String backupdir = Prefs.getPref(PrefName.BACKUPDIR); if (backupdir != null && !backupdir.equals("")) { String shutdown_action = Prefs.getPref(PrefName.SHUTDOWN_ACTION); if (shutdown_action.isEmpty() || SHUTDOWN_ACTION.PROMPT.toString().equals(shutdown_action)) { JRadioButton b1 = new JRadioButton(Resource.getResourceString("backup_notice") + " " + backupdir); JRadioButton b2 = new JRadioButton(Resource.getResourceString("exit_no_backup")); JRadioButton b3 = new JRadioButton(Resource.getResourceString("dont_exit")); JRadioButton b4 = new JRadioButton(Resource.getResourceString("backup_with_email")); b1.setSelected(true); ButtonGroup group = new ButtonGroup(); group.add(b1); group.add(b2); group.add(b3); group.add(b4); Object[] array = { b1, b4, b2, b3, }; int res = JOptionPane.showConfirmDialog( null, array, Resource.getResourceString("shutdown_options"), JOptionPane.OK_CANCEL_OPTION); if (res != JOptionPane.YES_OPTION) { return; } if (b3.isSelected()) return; if (b1.isSelected() || b4.isSelected()) do_backup = true; if (b4.isSelected()) backup_email = true; } else if (SHUTDOWN_ACTION.BACKUP.toString().equals(shutdown_action)) { do_backup = true; } else if (SHUTDOWN_ACTION.EMAIL.toString().equals(shutdown_action)) { do_backup = true; backup_email = true; } } // stop popup timer and destroy popups ReminderManager rm = ReminderManager.getReminderManager(); if (rm != null) rm.remove(); // show a splash screen for shutdown try { SplashScreen ban = new SplashScreen(); ban.setText(Resource.getResourceString("shutdown")); ban.setVisible(true); } catch (Exception e) { e.printStackTrace(); } // backup data if (do_backup == true) { try { ExportImport.exportToZip(backupdir, backup_email); } catch (Exception e) { Errmsg.getErrorHandler().errmsg(e); return; } } // non-UI shutdown if (shutdownListener != null) shutdownListener.update(null, null); }