List of usage examples for java.util.prefs Preferences flush
public abstract void flush() throws BackingStoreException;
From source file:kindleclippings.quizlet.QuizletSync.java
public static void clearPrefs() throws BackingStoreException { Preferences prefs = Preferences.userNodeForPackage(QuizletSync.class); prefs.clear();/* w w w .j av a 2s . c o m*/ prefs.flush(); }
From source file:de.tbuchloh.kiskis.KisKis.java
private static void resetPreferences() { try {//from ww w .ja v a 2 s . c o m final Preferences p = Preferences.userNodeForPackage(KisKis.class); p.removeNode(); p.flush(); if (PREF_FILE.exists()) { PREF_FILE.delete(); } System.out.println("All preferences for package '" + KisKis.class.getPackage().getName() + "' were removed!\nYou can restart the application now!"); } catch (final BackingStoreException e) { throw new Error(e); } }
From source file:ec.nbdemetra.ui.Installer.java
public static void storeConfig(Collection<?> list, Preferences root) { Formatters.Formatter<Config> formatter = Config.xmlFormatter(false); for (IConfigurable o : Iterables.filter(list, IConfigurable.class)) { Config current = o.getConfig();//from w w w .j a v a2 s. c o m Preferences domain = root.node(current.getDomain()); InstallerStep.tryPut(domain, current.getName(), formatter, current); } try { root.flush(); } catch (BackingStoreException ex) { LOGGER.warn("Can't flush storage", ex); } }
From source file:com.projity.util.VersionUtils.java
public static boolean versionCheck(boolean warnIfBad) { String version = VersionUtils.getVersion(); if (version == null) // for running in debugger version = "0"; Preferences pref = Preferences.userNodeForPackage(VersionUtils.class); String localVersion = pref.get("Angel Falls Version", "unknown"); boolean updated = !localVersion.equals(version); String javaVersion = System.getProperty("java.version"); log.info("Angel Falls Version: " + version + " local version " + localVersion + " updated=" + updated + " java version=" + javaVersion); pref.put("JavaVersion", javaVersion); if (updated) { Environment.setUpdated(true); pref.put("PODVersion", version); try {/*from www. j a v a 2 s . c o m*/ pref.flush(); } catch (BackingStoreException e) { e.printStackTrace(); } if (warnIfBad && Environment.isApplet()) { if (javaVersion.equals("1.6.0_09") || javaVersion.equals("1.6.0_08") || javaVersion.equals("1.6.0_07") || javaVersion.equals("1.6.0_06") || javaVersion.equals("1.6.0_05") || javaVersion.equals("1.6.0_04")) { Environment.setNeedToRestart(true); SwingUtilities.invokeLater(new Runnable() { public void run() { Alert.error(Messages.getString("Error.restart")); } }); } } } else { try { pref.flush(); } catch (BackingStoreException e) { e.printStackTrace(); } } return updated; }
From source file:kindleclippings.quizlet.QuizletSync.java
public static Preferences getPrefs() throws IOException, URISyntaxException, InterruptedException, JSONException, BackingStoreException { Preferences prefs = Preferences.userNodeForPackage(QuizletSync.class); String token = prefs.get("access_token", null); if (token == null) { JSONObject o = GetAccessToken.oauthDance(); if (o == null) { JOptionPane.showMessageDialog(null, "Failed authorization to access Quizlet", "QuizletSync", JOptionPane.ERROR_MESSAGE); System.exit(0);//from w w w . j a v a 2 s. c o m } prefs.put("access_token", o.getString("access_token")); prefs.put("user_id", o.getString("user_id")); prefs.flush(); } return prefs; }
From source file:de.tbuchloh.kiskis.gui.common.Application.java
/** * @param prefs/*w w w. j a v a 2 s. c o m*/ * is the location to store the program information * @param list * is a list of Program objects */ public static void storePrograms(final Preferences prefs, final Collection list) { Preferences n = prefs.node(Settings.K_URL_ALLPROGS_NODE); try { n.removeNode(); } catch (final BackingStoreException e) { throw new Error(e); } n = prefs.node(Settings.K_URL_ALLPROGS_NODE); int cnt = 0; for (final Iterator i = list.iterator(); i.hasNext();) { final Program p = (Program) i.next(); final Preferences child = n.node(String.valueOf(cnt++)); child.put(Settings.K_URL_PROG_PREFIX, p.getUrlRegex()); child.put(Settings.K_URL_PROG_CMD, p.getCommand()); LOG.debug("storing " + p); //$NON-NLS-1$ } try { n.flush(); } catch (final BackingStoreException e1) { throw new Error(e1); } }
From source file:ome.formats.importer.ImportConfig.java
/** * Static method for creating {@link Preferences} during construction if * necessary./*from w ww . j a v a2s . c o m*/ */ private static Preferences prefs() { Preferences prefs = Preferences.userNodeForPackage(ImportConfig.class); try { prefs.flush(); } catch (Exception e) { log.error("Error flushing preferences"); } return prefs; }
From source file:org.fuin.utils4j.PropertiesFilePreferencesTest.java
/** * @testng.test/* w ww. j a v a 2 s . co m*/ */ public final void testChildRemove() throws BackingStoreException { final File dir = new File(baseDir, "user"); final File subDir = new File(dir, "abc"); final File file = new File(subDir, PropertiesFilePreferences.FILENAME); final PropertiesFilePreferences root = new PropertiesFilePreferences(dir); final Preferences pref = root.node("abc"); pref.flush(); Assert.assertTrue(file.exists()); pref.removeNode(); pref.flush(); Assert.assertFalse(file.exists()); }
From source file:org.pdfsam.ui.DefaultStageService.java
public void clear() { Preferences prefs = Preferences.userRoot().node(STAGE_PATH); try {//from w w w . j a va2 s .com prefs.removeNode(); prefs.flush(); } catch (BackingStoreException e) { LOG.error("Unable to clear stage status", e); } }
From source file:org.pdfsam.news.DefaultNewsService.java
public void clear() { Preferences prefs = Preferences.userRoot().node(NEWS_PATH); try {//from ww w . j ava 2 s . co m prefs.removeNode(); prefs.flush(); } catch (BackingStoreException e) { LOG.error("Unable to clear latest news store", e); } }