List of usage examples for java.util.prefs Preferences flush
public abstract void flush() throws BackingStoreException;
From source file:ch.astina.hesperid.installer.web.services.InstallationManager.java
public void saveHomeDirectory(String homedirectory) { Preferences prefs = Preferences.userNodeForPackage(InstallationManager.class); prefs.put(HOME_DIRECTORY, homedirectory); try {/*w ww.j a v a 2 s . co m*/ prefs.flush(); } catch (BackingStoreException ex) { logger.error("Could not store home directory", ex); } }
From source file:org.pentaho.di.core.util.AbstractStepMeta.java
/** * Saves properties to preferences./* w w w . j av a 2 s . com*/ * * @throws BackingStoreException * ... */ public void saveAsPreferences() throws BackingStoreException { final Preferences node = Preferences.userNodeForPackage(this.getClass()); this.getProperties().walk(new SaveToPreferences(node)); node.flush(); }
From source file:de.fhg.igd.mapviewer.server.tiles.CustomTileMapServerConfiguration.java
/** * Save the configuration//from w w w . ja v a2 s . c om * */ public void save() { Preferences preferences = getPreferences(); try { String name = getName(); Preferences node = preferences.node(name); setName(name); saveProperties(node); node.flush(); } catch (BackingStoreException e) { log.error("Error saving map server preferences", e); //$NON-NLS-1$ } }
From source file:de.fhg.igd.mapviewer.server.wms.WMSConfiguration.java
/** * Save the configuration/* w w w . j a va 2 s . com*/ * * @param overwrite if old settings/servers with the same name shall be * overridden */ public void save(boolean overwrite) { Preferences preferences = getPreferences(); try { String name = getName(); if (!overwrite) { int i = 1; // find unique name while (preferences.nodeExists(name)) { name = getName() + "_" + i; //$NON-NLS-1$ i++; } } Preferences node = preferences.node(name); setName(name); saveProperties(node); node.flush(); } catch (BackingStoreException e) { log.error("Error saving map server preferences", e); //$NON-NLS-1$ } }
From source file:org.settings4j.connector.PreferencesConnector.java
/** * Resolve the given path and key against the given Preferences. * * @param path the preferences path (placeholder part before '/') * @param key the preferences key (placeholder part after '/') * @param value the Value to store./* w w w. ja va2 s . c o m*/ * @param preferences the Preferences to resolve against */ protected void setPreferenceValue(final String path, final String key, final String value, final Preferences preferences) { if (path != null) { preferences.node(path).put(key, value); } else { preferences.put(key, value); } try { preferences.flush(); } catch (final BackingStoreException e) { throw new RuntimeException("Cannot access specified node path [" + path + "]", e); } }
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 {/*ww w . ja v a 2s . c om*/ 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:de.ailis.oneinstance.OneInstance.java
/** * Remembers an active port number in the preferences. * /* www . j a v a 2 s . c om*/ * @param mainClass * The main class of the application. * @param port * The port number. */ private void setActivePort(Class<?> mainClass, int port) { Preferences prefs = Preferences.userNodeForPackage(mainClass); prefs.putInt(PORT_KEY, port); try { prefs.flush(); } catch (BackingStoreException e) { LOG.error(e.toString(), e); } }
From source file:verdandi.ui.common.WidthStoringTable.java
/** * Stores thw width of the columns to a preference. The preference is stored * beneath the node for the Package of the implementing class. Preferences are * named {@link #PREFIX_COL_WIDTH} plus the column index. * // w w w . j ava 2 s . c o m * @see #PREFIX_COL_WIDTH */ public void storeWidths() { Preferences prefs = Preferences.userNodeForPackage(getClass()); LOG.debug("Storing widths to " + prefs.absolutePath() + "; " + getModel().getClass().getSimpleName()); for (int i = 0; i < getModel().getColumnCount(); i++) { int width = getColumnModel().getColumn(i).getWidth(); LOG.debug("Store " + widthPref + i + "=" + width); prefs.putInt(widthPref + i, width); } try { prefs.flush(); } catch (BackingStoreException e) { e.printStackTrace(); } }
From source file:de.ailis.oneinstance.OneInstance.java
/** * Unregisters this instance of the application. If this is the first * instance then the server is closed and the port is removed from * the preferences. If this is not the first instance then this method * does nothing./*from w w w . j av a 2 s. c o m*/ * * This method should be called when the application exits. But it is * not a requirement. When you don't do this then the port number will * stay in the preferences so on next start of the application this port * number must be validated. So by calling this method on application exit * you just save the time for this port validation. * * @param mainClass * The main class of the application. Must not be null. * This is used as the user node key for the preferences. */ public void unregister(Class<?> mainClass) { if (mainClass == null) throw new IllegalArgumentException("mainClass must be set"); // Nothing to do when no server socket is present if (this.server == null) return; // Close the server socket this.server.stop(); this.server = null; // Remove the port from the preferences Preferences prefs = Preferences.userNodeForPackage(mainClass); prefs.remove(PORT_KEY); try { prefs.flush(); } catch (BackingStoreException e) { LOG.error(e.toString(), e); } }
From source file:com.igormaznitsa.nbmindmap.nb.swing.PlainTextEditor.java
private void writeWrappingCode(final Wrapping code) { final Preferences docPreferences = CodeStylePreferences.get(this.document).getPreferences(); docPreferences.put(SimpleValueNames.TEXT_LINE_WRAP, code.getValue()); try {//from w w w .ja v a 2 s. c om docPreferences.flush(); } catch (BackingStoreException ex) { LOGGER.error("Can't write wrapping code", ex); } }