List of usage examples for java.util.prefs Preferences userRoot
public static Preferences userRoot()
From source file:org.pdfsam.ui.PreferencesRecentWorkspacesService.java
@PreDestroy public void flush() { Preferences prefs = Preferences.userRoot().node(WORKSPACES_PATH); LOG.trace("Flushing recently used workspaces"); try {/* w ww . j a va 2 s. co m*/ prefs.clear(); for (Entry<String, String> entry : cache.entrySet()) { prefs.put(entry.getValue(), entry.getKey()); } prefs.flush(); } catch (BackingStoreException e) { LOG.error("Error storing recently used workspace", e); } }
From source file:org.pdfsam.ui.StatefullPreferencesStageServiceTest.java
@Test public void testClear() { StageStatus status = new StageStatus(10, 20, 100, 200); victim.save(status);/* ww w .jav a2 s .c om*/ victim.clearStageStatus(); assertTrue(isBlank(Preferences.userRoot().node(StatefullPreferencesStageService.STAGE_PATH) .get(StatefullPreferencesStageService.STAGE_STATUS_KEY, ""))); }
From source file:org.pdfsam.news.DefaultNewsService.java
public void setLatestNewsSeen(int id) { Preferences.userRoot().node(NEWS_PATH).putInt(LATEST_NEWS_ID, id); LOG.trace("Latest news id stored"); }
From source file:org.apache.cayenne.modeler.preferences.UpgradeCayennePreference.java
public void upgrade() { try {/*from w w w . j a v a2 s.c o m*/ if (!Preferences.userRoot().nodeExists(CAYENNE_PREFERENCES_PATH)) { File prefsFile = new File(preferencesDirectory(), PREFERENCES_NAME_OLD); if (prefsFile.exists()) { ExtendedProperties ep = new ExtendedProperties(); try { ep.load(new FileInputStream(prefsFile)); Preferences prefEditor = Preferences.userRoot().node(CAYENNE_PREFERENCES_PATH).node(EDITOR); prefEditor.putBoolean(ModelerPreferences.EDITOR_LOGFILE_ENABLED, ep.getBoolean(EDITOR_LOGFILE_ENABLED_OLD)); prefEditor.put(ModelerPreferences.EDITOR_LOGFILE, ep.getString(EDITOR_LOGFILE_OLD)); Preferences frefLastProjFiles = prefEditor.node(LAST_PROJ_FILES); Vector arr = ep.getVector(LAST_PROJ_FILES_OLD); while (arr.size() > ModelerPreferences.LAST_PROJ_FILES_SIZE) { arr.remove(arr.size() - 1); } frefLastProjFiles.clear(); int size = arr.size(); for (int i = 0; i < size; i++) { frefLastProjFiles.put(String.valueOf(i), arr.get(i).toString()); } } catch (FileNotFoundException e) { LOGGER.error(e); } catch (IOException e) { LOGGER.error(e); } } } } catch (BackingStoreException e) { // do nothing } }
From source file:org.pdfsam.ui.DefaultStageService.java
public void clear() { Preferences prefs = Preferences.userRoot().node(STAGE_PATH); try {/* w ww .j a va 2s. c o m*/ prefs.removeNode(); prefs.flush(); } catch (BackingStoreException e) { LOG.error("Unable to clear stage status", e); } }
From source file:org.pdfsam.news.DefaultNewsService.java
public int getLatestNewsSeen() { return Preferences.userRoot().node(NEWS_PATH).getInt(LATEST_NEWS_ID, -1); }
From source file:org.pdfsam.news.DefaultNewsService.java
public void clear() { Preferences prefs = Preferences.userRoot().node(NEWS_PATH); try {//from w ww . j a va2 s . c o m prefs.removeNode(); prefs.flush(); } catch (BackingStoreException e) { LOG.error("Unable to clear latest news store", e); } }
From source file:org.settings4j.connector.PreferencesConnector.java
/** * Default Constructor initialize the User and System {@link Preferences}. */ public PreferencesConnector() { this(Preferences.systemRoot(), Preferences.userRoot()); }
From source file:com.symbian.utils.config.ConfigUtils.java
/** * @param aConfigMap/* w w w .j a v a 2 s .c o m*/ * @param aPreferenceAddress * @param aPreferenceLiterals * @throws IOException */ protected ConfigUtils(String aPreferenceAddress, String[] aPreferenceLiterals) throws IOException { iNodeName = aPreferenceAddress; iConfigMap = new HashMap(); iSavedConfig = new HashMap(); iPreferenceLiterals = aPreferenceLiterals; iPrefrences = Preferences.userRoot().node(iNodeName); // if created for the first time, it needs to be flushed. try { iPrefrences.flush(); } catch (BackingStoreException lBackingStoreException) { LOGGER.warning("Failed to flush the configuration: " + lBackingStoreException.getMessage()); } // Register the listener for prefs changes iPrefrences.addPreferenceChangeListener(new PreferenceChangeListener() { public void preferenceChange(PreferenceChangeEvent evt) { try { iPrefrences.flush(); } catch (BackingStoreException lBackingStoreException) { LOGGER.warning("Failed to flush the configuration: " + lBackingStoreException.getMessage()); } } }); }
From source file:org.pdfsam.ui.PreferencesRecentWorkspacesService.java
private void populateCache() { Preferences prefs = Preferences.userRoot().node(WORKSPACES_PATH); try {//from ww w.jav a 2s . c o m Arrays.stream(prefs.keys()).sorted().forEach(k -> { String currentValue = prefs.get(k, EMPTY); if (isNotBlank(currentValue)) { cache.put(currentValue, k); } }); } catch (BackingStoreException e) { LOG.error("Error retrieving recently used workspaces", e); } }