private void flushPreferences() { try { snapPreferences.flush(); } catch (BackingStoreException bse) { SystemUtils.LOG.severe("Could not store preferences: " + bse.getMessage()); } } }
@Override public String toString() { StringBuilder sb = new StringBuilder(); try { walkTree(sb, preferences); } catch (BackingStoreException e) { log.error("Error traversing OS tree: {}", e.getMessage()); log.debug("Exception", e); } return sb.toString(); }
@Override public Iterable<String> keys() { try { final ArrayList<String> keys = new ArrayList<>(Arrays.asList(this.preferences.keys())); Collections.sort(keys); return keys; } catch (final BackingStoreException exception) { logger.log(ILevel.DEBUG, exception.getMessage()); logger.log(ILevel.ALL, exception.getMessage(), exception); return new ArrayList<>(); } }
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); } } }
@Override public void flush() { try { this.preferences.flush(); } catch (final BackingStoreException exception) { logger.log(ILevel.WARNING, exception.getMessage()); logger.log(ILevel.DEBUG, exception.getMessage(), exception); } }
ChatIgnoreList() { final Preferences prefs = getPrefNode(); try { Collections.addAll(ignore, prefs.keys()); } catch (final BackingStoreException e) { log.log(Level.FINE, e.getMessage(), e); } }
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()); } }
@Override public void delete() { try { this.preferences.removeNode(); this.preferences.flush(); } catch (final BackingStoreException exception) { logger.log(ILevel.DEBUG, exception.getMessage()); logger.log(ILevel.ALL, exception.getMessage(), exception); } }
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); } } }
/** * Removes all of the preferences (key-value associations) in this * preference node with no effect on any descendants * of this node. */ @SuppressWarnings("unused") private static <P extends Preferences> void shallowClearPreferences(P preferenceNode) { try { preferenceNode.clear(); } catch (BackingStoreException e) { Log.error(e.getMessage()); } }
/** * @return true if this is the first time loading language files (probably on install) */ static private boolean isThisTheFirstTimeLoadingLanguageFiles() { // Did the language file disappear? Offer the language dialog. try { if (doesLanguagePreferenceExist()) { return false; } } catch (BackingStoreException e) { Log.error(e.getMessage()); } return true; }
@Override public boolean nodeExists(final String... nodes) { try { return this.preferences.nodeExists(new PathFactory().create(nodes)); } catch (final BackingStoreException exception) { logger.log(ILevel.DEBUG, exception.getMessage()); logger.log(ILevel.ALL, exception.getMessage(), exception); return false; } }
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); } }
void store() { final Preferences preferences = Config.instance().preferences(); preferences.putBoolean(WWWorldViewToolView.useFlatEarth, useFlatEarthCheckBox.isSelected()); try { preferences.flush(); } catch (BackingStoreException e) { SnapApp.getDefault().getLogger().severe(e.getMessage()); } }
void store() { final Preferences preferences = Config.instance("s2tbx").load().preferences(); preferences.put(S2CacheUtils.SENTINEL_2_CACHE_MAX_TIME, box.getSelectedItem().toString()); try { preferences.flush(); } catch (BackingStoreException e) { SnapApp.getDefault().getLogger().severe(e.getMessage()); } }
/** * @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()); } }
/** * 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()); } }
/** * Called if SNAP shuts down. The method is not supposed to be called by clients directly. * <p> * Overrides should call {@code super.onStop()} in a final step unless they know what they are doing. */ public void onStop() { engine.stop(); disposeProducts(); try { getPreferences().flush(); } catch (BackingStoreException e) { getLogger().log(Level.SEVERE, e.getMessage(), e); } }
/** * @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()); } }
@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()); } } } }