public void storePrefs() { Preferences prefs = Preferences.userNodeForPackage(DurationFormatter.class); if (radioFormatHHQuarters.isSelected()) { prefs.putInt( DurationFormatter.PREF_DISPLAY_MODE, DurationFormatter.DISPLAY_DURATION_HH_QUARTER); } else if (radioFormatHHMM.isSelected()) { prefs.putInt(DurationFormatter.PREF_DISPLAY_MODE, DurationFormatter.DISPLAY_DURATION_HHMM); } try { prefs.flush(); } catch (BackingStoreException e) { LOG.error("Cannot store Prefs: ", e); } conf.setStorePasswd(storePasswordCheckBox.isSelected()); conf.setShowTimerOnStartup(showTimerOnStartupCheckBox.isSelected()); for (Entry<String, JTextField> pt : persistenceFields.entrySet()) { conf.setConfigProperty(pt.getKey(), pt.getValue().getText()); } conf.setConfigProperty( AnnotatedWorkRecordView.PREF_RESTORE_ON_INIT, Boolean.toString(initAnnotatedWorkRecordsOnStartup.isSelected())); workDaySettingsPanel.commit(); }
@Override public void reset() { Preferences prefs = Preferences.userNodeForPackage(DurationFormatter.class); int displayMode = prefs.getInt(DurationFormatter.PREF_DISPLAY_MODE, DurationFormatter.DISPLAY_DURATION_HHMM); if (displayMode == DurationFormatter.DISPLAY_DURATION_HHMM) { radioFormatHHMM.setSelected(true); } else { radioFormatHHQuarters.setSelected(true); } storePasswordCheckBox.setSelected(conf.isStorePasswd()); showTimerOnStartupCheckBox.setSelected(conf.isShowTimerOnStartup()); for (Entry<String, JTextField> pt : persistenceFields.entrySet()) { pt.getValue().setText(conf.getConfigProperty(pt.getKey())); } workDaySettingsPanel.reset(); }