public void set(ControlPanelTypes type, boolean newValue) throws Exception { cache.put(type, newValue); preferences.putBoolean(makeKey(type), newValue); preferences.flush(); }
public static boolean isAdmin(){ Preferences prefs = Preferences.systemRoot(); try{ prefs.put("foo", "bar"); // SecurityException on Windows prefs.remove("foo"); prefs.flush(); // BackingStoreException on Linux return true; }catch(Exception e){ return false; } }
public static boolean isAdmin(){ Preferences prefs = Preferences.systemRoot(); PrintStream systemErr = System.err; synchronized(systemErr){ // better synchroize to avoid problems with other threads that access System.err System.setErr(null); try{ prefs.put("foo", "bar"); // SecurityException on Windows prefs.remove("foo"); prefs.flush(); // BackingStoreException on Linux return true; }catch(Exception e){ return false; }finally{ System.setErr(systemErr); } } }
/** * Saves properties to preferences. * * @throws BackingStoreException * ... */ public void saveAsPreferences() throws BackingStoreException { final Preferences node = Preferences.userNodeForPackage( this.getClass() ); this.getProperties().walk( new SaveToPreferences( node ) ); node.flush(); }
/** * Adds an OnCloseRequest handle to the window which will store the position, * size and maximized status of the window. * * @param stage the stage to read settings from * @param name the name under which we store the settings */ public static void applySaveOnCloseMethod(Stage stage, String name){ stage.setOnCloseRequest( ev -> { try { Preferences stagePreferences = PREFERENCES.node(name); if( stage.isMaximized() ){ stagePreferences.putBoolean(WINDOW_MAXIMIZED, true); } else { stagePreferences.putBoolean(WINDOW_MAXIMIZED, false); stagePreferences.putDouble(WINDOW_X_POS, stage.getX()); stagePreferences.putDouble(WINDOW_Y_POS, stage.getY()); stagePreferences.putDouble(WINDOW_WIDTH, stage.getWidth()); stagePreferences.putDouble(WINDOW_HEIGHT, stage.getHeight()); } stagePreferences.flush(); } catch (final BackingStoreException ex) { LOGGER.error(ex, "Could not flush preferences for window " + name); } }); }
@Override public synchronized void save() { try { this.preferences.flush(); } catch (BackingStoreException e) { throw new IllegalStateException(e); } } }
public void flush() { Preferences prefs = Preferences.userRoot().node(USAGE_PATH); try { LOG.trace("Flushing modules usage"); prefs.flush(); } catch (BackingStoreException e) { LOG.error("Unable to flush modules usage statistics", e); } }
public void doSave() { // TODO Re-enable this when there are actual preferences. // JOptionPane.showMessageDialog(this, "Please restart NodeBox for the changes to take effect."); try { preferences.flush(); } catch (BackingStoreException e) { throw new RuntimeException(e); } dispose(); }
public static void writeRecentFiles(ArrayList<File> fileList) { int i = 1; for (File f : fileList) { try { recentFilesPreferences.put(String.valueOf(i), f.getCanonicalPath()); } catch (IOException e) { logger.log(Level.WARNING, "Could not get canonical file name", e); return; } i++; if (i > 10) break; } try { recentFilesPreferences.flush(); } catch (BackingStoreException e) { logger.log(Level.WARNING, "Could not write recent files preferences", e); } }
public void flush() { Preferences prefs = Preferences.userRoot().node(WORKSPACES_PATH); LOG.trace("Flushing recently used workspaces"); try { 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); } }
@Override public void clear() { Preferences prefs = Preferences.userRoot().node(WORKSPACES_PATH); cache.clear(); try { prefs.removeNode(); prefs.flush(); } catch (BackingStoreException e) { LOG.error("Unable to clear recently used workspaces", e); } }
@Override public void clear() { Preferences prefs = Preferences.userRoot().node(STAGE_PATH); try { prefs.removeNode(); prefs.flush(); } catch (BackingStoreException e) { LOG.error("Unable to clear stage status", e); } } }
public void clear() { Preferences prefs = Preferences.userRoot().node(USAGE_PATH); try { prefs.removeNode(); prefs.flush(); } catch (BackingStoreException e) { LOG.error("Unable to clear modules usage statistics", e); } }
@Override public void clear() { Preferences prefs = Preferences.userRoot().node(NEWS_PATH); try { prefs.removeNode(); prefs.flush(); } catch (BackingStoreException e) { LOG.error("Unable to clear latest news store", e); } } }
@Override public void clear() { try { prefs.removeNode(); prefs.flush(); initNode(); } catch (BackingStoreException e) { LOG.error("Unable to clear user preferences", e); } }
public static void saveValue(String key, String value) { Preferences prefs = MageFrame.getPreferences(); prefs.put(key, value); try { prefs.flush(); } catch (BackingStoreException ex) { ex.printStackTrace(); JOptionPane.showMessageDialog(null, "Error: couldn't save preferences. Please try once again."); } updateCache(key, value); }
public void actionPerformed(ActionEvent actionEvent) { boolean changed = false; if (isDeviceSupportEnabled() != enableDeviceSupportCheck.isSelected()) { setEnableDeviceSupport(enableDeviceSupportCheck.isSelected()); changed = true; } if (changed) { JOptionPane.showMessageDialog(this, "Please restart NodeBox for the changes to take effect."); try { preferences.flush(); } catch (BackingStoreException e) { throw new RuntimeException(e); } } dispose(); } }
/** * The update checker completed the check without error. * * @param checker the update checker * @param appcast the appcast */ public void checkCompleted(UpdateChecker checker, Appcast appcast) { hideUpdateCheckDialog(); // Delegate method. if (delegate != null) if (delegate.checkCompleted(checker, appcast)) return; // Store last check update check time. getPreferences().putLong(LAST_UPDATE_CHECK, System.currentTimeMillis()); try { getPreferences().flush(); } catch (BackingStoreException e) { throw new RuntimeException("Error while storing preferences", e); } }
SessionHandler.updatePreferencesForServer(getUserData()); prefs.flush(); } catch (BackingStoreException ex) { logger.error("Error: couldn't save preferences", ex);