Refine search
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); }
@Override protected void removeNodeSpi() throws BackingStoreException { prefsFile.delete(); boolean removeSucceed = dir.delete(); if (!removeSucceed) { throw new BackingStoreException("Cannot remove " + toString()); } }
/** * @param sourcePreferenceNode Preference node to be copied from. * @param destinationPreferenceNode Preference node to be copied to. */ public static <P extends Preferences> void copyPreferenceNode(P sourcePreferenceNode, P destinationPreferenceNode) { try { final String[] keys = sourcePreferenceNode.keys(); for (String key : keys) { final String value = sourcePreferenceNode.get(key, null); destinationPreferenceNode.put(key, value); } final String[] childNames = sourcePreferenceNode.childrenNames(); for (String childName : childNames) { final Preferences destinationChildNode = destinationPreferenceNode.node(childName); copyPreferenceNode(sourcePreferenceNode.node(childName), destinationChildNode); } } catch (BackingStoreException e) { Log.error(e.getMessage()); } }
public String getPref(String section, String key) { try { if (prefs.nodeExists(section)) return prefs.node(section).get(key, null); } catch (BackingStoreException e) { e.printStackTrace(); } return null; }
@Override public void start() { final Preferences preferences = Config.instance("s2tbx").load().preferences(); String cachePolicy = preferences.get(S2CacheUtils.SENTINEL_2_CACHE_MAX_TIME, null); if(cachePolicy == null) { cachePolicy = S2CacheUtils.SENTINEL_2_CACHE_OPTION_WEEK; preferences.put(S2CacheUtils.SENTINEL_2_CACHE_MAX_TIME, cachePolicy); try { preferences.flush(); } catch (BackingStoreException e) { Logger logger = Engine.getInstance().getLogger(); logger.severe(e.getMessage());
void add(final String name) { synchronized (lock) { ignore.add(name); final Preferences prefs = getPrefNode(); prefs.put(name, "true"); try { prefs.flush(); } catch (final BackingStoreException e) { log.log(Level.FINE, e.getMessage(), e); } } }
private static void putRecentFiles(Vector<File> files){ // save the last 20 files logger.info(files.size()); // first remove old ones for(int n = 0; n < 20; n++){ logger.info("n" + n); prefs.remove(RECENT_FILE + n); } // then add new ones for(int n = 0; n < files.size() && n < 20; n++){ logger.info("n" + n); prefs.put(RECENT_FILE + n, files.get(n).getAbsolutePath()); } // and flush changes try { prefs.flush(); } catch (BackingStoreException e) { // TODO Auto-generated catch block e.printStackTrace(); } fireRecentFilesChanged(); }
public static void putIntValue(SettingValue settingValue, int intValue){ prefs.putInt(settingValue.getPrefsKey(), intValue); try { prefs.flush(); } catch (BackingStoreException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
private void validateTree() { try { String[] uniqueNames = preferences.node("/os").childrenNames(); for (String uniqueName : Arrays.asList(uniqueNames)) { Preferences node = getKeyNode(uniqueName, "derivedFrom", null); String id = getKeyNode(uniqueName, "id", null).get("value", "0"); if (node != null) { String derivedFrom = node.get("value", null); if (derivedFrom != null && !idToUnameLookup.containsValue(derivedFrom)) { idToUnameLookup.remove(Integer.valueOf(id)); preferences.node("/os/" + uniqueName).removeNode(); log.warn("Illegal parent for os '{}'", uniqueName); } } } } catch (BackingStoreException e) { log.warn("Failed to validate Os Repository due to {}", e.getMessage()); log.debug("Exception", e); throw new RuntimeException("Failed to validate Os Repository due to " + e); } }
public static void putToggleShortNameOnly(boolean shortNameOnly) { prefs.putBoolean(TOGGLE_SHORT_NAME_ONLY, shortNameOnly); try { prefs.flush(); } catch (BackingStoreException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
void store() { final Preferences preferences = Config.instance("s2tbx").load().preferences(); preferences.putBoolean("s2tbx.dataio.detectorFootprintMasks", detectorFootprintMasks.isSelected()); preferences.putBoolean("s2tbx.dataio.radiometricQualityMasks", radiometricQualityMasks.isSelected()); preferences.putBoolean("s2tbx.dataio.technicalQualityMasks", technicalQualityMasks.isSelected()); preferences.putBoolean("s2tbx.dataio.cloudMasks", cloudMasks.isSelected()); try { preferences.flush(); } catch (BackingStoreException e) { SnapApp.getDefault().getLogger().severe(e.getMessage()); } }
private static void saveModel(GuiQuickstartDataModel model) { Preferences preferences = Preferences.userNodeForPackage(GuiBootstrapMain.class); updatePreferences(preferences, "transitDataBundlePath", model.getTransitDataBundlePath()); updatePreferences(preferences, "gtfsPath", model.getGtfsPath()); updatePreferences(preferences, "tripUpdatesUrl", model.getTripUpdatesUrl()); updatePreferences(preferences, "vehiclePositionsUrl", model.getVehiclePositionsUrl()); updatePreferences(preferences, "alertsUrl", model.getAlertsUrl()); try { preferences.sync(); } catch (BackingStoreException e) { e.printStackTrace(); } }
/** * Removes all of the preferences (key-value associations) in this * preference node and any descendants of this node. */ @SuppressWarnings("unused") private static <P extends Preferences> void deepClearPreferences(P preferenceNode) { try { preferenceNode.clear(); final String[] childrenPreferenceNodeNames = preferenceNode.childrenNames(); for (String childNodeName : childrenPreferenceNodeNames) { final Preferences childNode = preferenceNode.node(childNodeName); childNode.clear(); } } catch (BackingStoreException e) { Log.error(e.getMessage()); } }
@SuppressWarnings("deprecation") private void resetPreferences() { int dialogResult = JOptionPane.showConfirmDialog(app.getMainFrame(), Translator.get("MenuResetMachinePreferencesWarning"), Translator.get("MenuResetMachinePreferencesWarningHeader"), JOptionPane.YES_NO_OPTION); if(dialogResult == JOptionPane.YES_OPTION){ try { Preferences prefs = PreferencesHelper.getPreferenceNode(PreferencesHelper.MakelangeloPreferenceKey.LEGACY_MAKELANGELO_ROOT); prefs.removeNode(); Preferences.userRoot().flush(); } catch (BackingStoreException e1) { Log.error(e1.getMessage()); } } } }
private static void clearCommandItem(int i, String prefix){ prefs.remove(prefix + CMD_NAME_ + i); prefs.remove(prefix + CMD_PROGRAM_PATH_ + i); prefs.remove(prefix + CMD_COMMAND_ + i); prefs.remove(prefix + CMD_IS_ACTIVATED_ + i); prefs.remove(prefix + CMD_SHOW_COMMAND_WIN_ + i); try { prefs.flush(); } catch (BackingStoreException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
private void flushPrefs() { try { prefs.flush(); } catch (BackingStoreException e) { e.printStackTrace(); } }
static public void clearSession(boolean full) { session = null; if(full) { try { String[] keys = prefs.keys(); for (int i = 0; i < keys.length; i++) { if (keys[i].indexOf("session_") == 0) { prefs.remove(keys[i]); } } } catch (BackingStoreException e) { e.printStackTrace(); } } }
void remove(final String name) { synchronized (lock) { ignore.remove(name); final Preferences prefs = getPrefNode(); prefs.remove(name); try { prefs.flush(); } catch (final BackingStoreException e) { log.log(Level.FINE, e.getMessage(), e); } } }
@Deprecated public static void resetPreferences() { try { Preferences.userNodeForPackage(ChannelFinderClientImpl.class) .clear(); } catch (BackingStoreException e) { e.printStackTrace(); } }
/** * @param preferenceNode Preference node whose name, and key values, * as well as those of its children's are to be logged. */ public static <P extends Preferences> void logPreferenceNode(P preferenceNode) { try { Log.info("node name:"+preferenceNode); logKeyValuesForPreferenceNode(preferenceNode); final String[] childrenPreferenceNodeNames = preferenceNode.childrenNames(); for (String childNodeName : childrenPreferenceNodeNames) { final Preferences childNode = preferenceNode.node(childNodeName); logPreferenceNode(childNode); } } catch (BackingStoreException e) { Log.error(e.getMessage()); } }