/* * (non-Javadoc) * * @see net.sf.borg.ui.options.OptionsView.OptionsPanel#loadOptions() */ @Override public void loadOptions() { backupDir.setText(Prefs.getPref(PrefName.BACKUPDIR)); OptionsPanel.setCheckBox(colorprint, PrefName.COLORPRINT); OptionsPanel.setCheckBox(splashbox, PrefName.SPLASH); OptionsPanel.setCheckBox(stackbox, PrefName.STACKTRACE); OptionsPanel.setCheckBox(useSysTray, PrefName.USESYSTRAY); OptionsPanel.setCheckBox(startToSysTray, PrefName.BACKGSTART); OptionsPanel.setCheckBox(dateInSysTray, PrefName.SYSTRAYDATE); OptionsPanel.setCheckBox(dynamicLoading, PrefName.DYNAMIC_LOADING); OptionsPanel.setCheckBox(verboseLogging, PrefName.DEBUG); OptionsPanel.setCheckBox(useProxy, PrefName.USE_PROXY); String shutdown_action = Prefs.getPref(PrefName.SHUTDOWN_ACTION); if (shutdown_action.isEmpty() || SHUTDOWN_ACTION.PROMPT.toString().equals(shutdown_action)) shutdownAction.setSelectedIndex(0); else if (SHUTDOWN_ACTION.NONE.toString().equals(shutdown_action)) shutdownAction.setSelectedIndex(1); else if (SHUTDOWN_ACTION.BACKUP.toString().equals(shutdown_action)) shutdownAction.setSelectedIndex(2); else if (SHUTDOWN_ACTION.EMAIL.toString().equals(shutdown_action)) shutdownAction.setSelectedIndex(3); int socket = Prefs.getIntPref(PrefName.SOCKETPORT); socketPort.setText(Integer.toString(socket)); proxyHostText.setText(Prefs.getPref(PrefName.PROXY_HOST)); int port = Prefs.getIntPref(PrefName.PROXY_PORT); proxyPortText.setText(Integer.toString(port)); }
/** * get the folder where attachments are stored * * @return the attachment folder path */ public static String attachmentFolder() { String dbtype = Prefs.getPref(PrefName.DBTYPE); if (dbtype.equals("hsqldb")) { String path = Prefs.getPref(PrefName.HSQLDBDIR) + "/attachments"; File f = new File(path); if (!f.exists()) { if (!f.mkdir()) { Errmsg.getErrorHandler().notice(Resource.getResourceString("att_folder_err") + path); return null; } } return path; } if (dbtype.equals("h2")) { String path = Prefs.getPref(PrefName.H2DIR) + "/attachments"; File f = new File(path); if (!f.exists()) { if (!f.mkdir()) { Errmsg.getErrorHandler().notice(Resource.getResourceString("att_folder_err") + path); return null; } } return path; } return null; }
/** * determine if an appointment popup should be shown for an appointment that doesn't yet have a * popup associated with it * * @return true, if successful */ @Override public boolean shouldBeShown() { if (appt == null) return false; // check if we should show it based on public/private // flags boolean showpub = Prefs.getBoolPref(PrefName.SHOWPUBLIC); boolean showpriv = Prefs.getBoolPref(PrefName.SHOWPRIVATE); if (appt.isPrivate()) { if (!showpriv) return false; } else { if (!showpub) return false; } // don't popup untimed appointments that are not todos if (isNote() && !isTodo()) return false; boolean expires = true; // true if the reminder eventually stops at some // point after the appt // todos never expire if (isTodo() && appt.getReminderTimes() != null && appt.getReminderTimes().indexOf('Y') != -1) { expires = false; } // a normal timed appt only gets a popup // if it's within its range of reminder times if (isOutsideOfReminderTimes(!expires)) return false; return true; }
/** * complete the parts of the UI initialization that run after the splash screen has shown for a * while * * @param trayname name for the tray icon */ private static void completeUIInitialization(String trayname) { // tray icon SunTrayIconProxy.startTrayIcon(trayname); // create reminder manager if (Prefs.getBoolPref(PrefName.REMINDERLIST)) ReminderListManager.getReference(); else ReminderPopupManager.getReference(); // create the main window MultiView mv = MultiView.getMainView(); // load the UI modules into the main window mv.addModule(new MonthPanel()); mv.addModule(new WeekPanel()); mv.addModule(new DayPanel()); mv.addModule(new YearPanel()); mv.addModule(new AddrListView()); mv.addModule(new TodoView()); mv.addModule(new TaskModule()); mv.addModule(new MemoPanel()); mv.addModule(new CheckListPanel()); mv.addModule(new SearchView()); mv.addModule( new InfoView("/resource/RELEASE_NOTES.txt", Resource.getResourceString("rlsnotes"))); mv.addModule(new InfoView("/resource/CHANGES.txt", Resource.getResourceString("viewchglog"))); mv.addModule(new InfoView("/resource/license.htm", Resource.getResourceString("License"))); if (Prefs.getBoolPref(PrefName.DYNAMIC_LOADING) == true) { addExternalModule("net.sf.borg.plugin.reports.ReportModule"); addExternalModule("net.sf.borg.plugin.ical.IcalModule"); addExternalModule("net.sf.borg.plugin.sync.SyncModule"); } // make the main window visible if (!Prefs.getBoolPref(PrefName.BACKGSTART) || !SunTrayIconProxy.hasTrayIcon()) { mv.setVisible(true); // open all views that should be shown at startup mv.startupViews(); } // destroy the splash screen if (splashScreen != null) { splashScreen.dispose(); splashScreen = null; } }
/* * (non-Javadoc) * * @see net.sf.borg.ui.options.OptionsView.OptionsPanel#applyChanges() */ @Override public void applyChanges() { if (verboseLogging.isSelected()) log.setLevel(Level.ALL); else log.setLevel(Level.INFO); OptionsPanel.setBooleanPref(colorprint, PrefName.COLORPRINT); OptionsPanel.setBooleanPref(splashbox, PrefName.SPLASH); OptionsPanel.setBooleanPref(stackbox, PrefName.STACKTRACE); OptionsPanel.setBooleanPref(useSysTray, PrefName.USESYSTRAY); OptionsPanel.setBooleanPref(startToSysTray, PrefName.BACKGSTART); OptionsPanel.setBooleanPref(dateInSysTray, PrefName.SYSTRAYDATE); OptionsPanel.setBooleanPref(dynamicLoading, PrefName.DYNAMIC_LOADING); OptionsPanel.setBooleanPref(verboseLogging, PrefName.DEBUG); OptionsPanel.setBooleanPref(useProxy, PrefName.USE_PROXY); Prefs.putPref(PrefName.BACKUPDIR, backupDir.getText()); if (shutdownAction.getSelectedIndex() == 0) Prefs.putPref(PrefName.SHUTDOWN_ACTION, SHUTDOWN_ACTION.PROMPT.toString()); else if (shutdownAction.getSelectedIndex() == 1) Prefs.putPref(PrefName.SHUTDOWN_ACTION, SHUTDOWN_ACTION.NONE.toString()); else if (shutdownAction.getSelectedIndex() == 2) Prefs.putPref(PrefName.SHUTDOWN_ACTION, SHUTDOWN_ACTION.BACKUP.toString()); else if (shutdownAction.getSelectedIndex() == 3) Prefs.putPref(PrefName.SHUTDOWN_ACTION, SHUTDOWN_ACTION.EMAIL.toString()); // validate that socket is a number try { int socket = Integer.parseInt(socketPort.getText()); Prefs.putPref(PrefName.SOCKETPORT, new Integer(socket)); } catch (NumberFormatException e) { Errmsg.getErrorHandler().notice(Resource.getResourceString("socket_warn")); socketPort.setText("-1"); Prefs.putPref(PrefName.SOCKETPORT, new Integer(-1)); } Prefs.putPref(PrefName.PROXY_HOST, proxyHostText.getText()); try { int port = Integer.parseInt(proxyPortText.getText()); Prefs.putPref(PrefName.PROXY_PORT, new Integer(port)); } catch (NumberFormatException e) { Errmsg.getErrorHandler().notice(Resource.getResourceString("proxy_warn")); } }
/** * Main UI initialization. * * @param trayname - name for the tray icon */ public static void startUI(String trayname) { Errmsg.setErrorHandler(new UIErrorHandler()); // check database timestamp try { JdbcDB.checkTimestamp(); } catch (Warning e1) { Errmsg.getErrorHandler().notice(e1.getMessage()); } catch (Exception e) { Errmsg.getErrorHandler().errmsg(e); } // default font String deffont = Prefs.getPref(PrefName.DEFFONT); if (!deffont.equals("")) { Font f = Font.decode(deffont); NwFontChooserS.setDefaultFont(f); } // set the look and feel String lnf = Prefs.getPref(PrefName.LNF); try { // set default jgoodies theme if (lnf.contains("jgoodies")) { String theme = System.getProperty("Plastic.defaultTheme"); if (theme == null) { System.setProperty("Plastic.defaultTheme", Prefs.getPref(PrefName.GOODIESTHEME)); } } UIManager.setLookAndFeel(lnf); UIManager.getLookAndFeelDefaults().put("ClassLoader", UIControl.class.getClassLoader()); } catch (Exception e) { log.severe(e.toString()); } // pop up the splash if the option is set if (Prefs.getBoolPref(PrefName.SPLASH)) { splashScreen = new SplashScreen(); splashScreen.setText(Resource.getResourceString("Initializing")); splashScreen.setVisible(true); final String tn = trayname; /* * in order for the splash to be seen, we will complete * initialization later (in the swing thread). */ Timer t = new Timer( 3000, new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { completeUIInitialization(tn); } }); t.setRepeats(false); t.start(); } else completeUIInitialization(trayname); }
/** 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); }