private IExportedPreferences convertFromProperties(Properties properties) { IExportedPreferences result = ExportedPreferences.newRoot(); for (Iterator i = properties.keySet().iterator(); i.hasNext();) { String path = (String) i.next(); String value = properties.getProperty(path); if (path.charAt(0) == EXPORT_ROOT_PREFIX) { ExportedPreferences current = (ExportedPreferences) result.node(path.substring(1)); current.setExportRoot(); } else if (path.charAt(0) == BUNDLE_VERSION_PREFIX) { ExportedPreferences current = (ExportedPreferences) result.node(InstanceScope.SCOPE).node(path.substring(1)); current.setVersion(value); } else { String[] decoded = EclipsePreferences.decodePath(path); path = decoded[0] == null ? EMPTY_STRING : decoded[0]; ExportedPreferences current = (ExportedPreferences) result.node(path); String key = decoded[1]; current.put(key, value); } } if (EclipsePreferences.DEBUG_PREFERENCE_GENERAL) PrefsMessages.message("Converted preferences file to IExportedPreferences tree: " + ((ExportedPreferences) result).toDeepDebugString()); //$NON-NLS-1$ return result; }
input = new BufferedInputStream(new FileInputStream(path.toFile())); IExportedPreferences prefs = readPreferences(input); prefs.accept(visitor); } catch (FileNotFoundException e) {
private IExportedPreferences convertFromProperties(Properties properties) { IExportedPreferences result = ExportedPreferences.newRoot(); for (Entry<?, ?> entry : properties.entrySet()) { String path = (String) entry.getKey(); String value = (String) entry.getValue(); if (path.charAt(0) == EXPORT_ROOT_PREFIX) { ExportedPreferences current = (ExportedPreferences) result.node(path.substring(1)); current.setExportRoot(); } else if (path.charAt(0) == BUNDLE_VERSION_PREFIX) { ExportedPreferences current = (ExportedPreferences) result.node(InstanceScope.SCOPE).node(path.substring(1)); current.setVersion(value); } else { String[] decoded = EclipsePreferences.decodePath(path); path = decoded[0] == null ? EMPTY_STRING : decoded[0]; ExportedPreferences current = (ExportedPreferences) result.node(path); String key = decoded[1]; current.put(key, value); } } if (EclipsePreferences.DEBUG_PREFERENCE_GENERAL) PrefsMessages.message("Converted preferences file to IExportedPreferences tree: " + ((ExportedPreferences) result).toDeepDebugString()); //$NON-NLS-1$ return result; }
input = new BufferedInputStream(new FileInputStream(path.toFile())); IExportedPreferences prefs = readPreferences(input); prefs.accept(visitor); } catch (FileNotFoundException e) {
private IEclipsePreferences trimTree(IEclipsePreferences tree, IPreferenceFilter filter) throws BackingStoreException { IEclipsePreferences result = (IEclipsePreferences) ExportedPreferences.newRoot().node(tree.absolutePath()); String[] scopes = filter.getScopes(); if (scopes == null)
private IEclipsePreferences trimTree(IEclipsePreferences tree, IPreferenceFilter filter) throws BackingStoreException { IEclipsePreferences result = (IEclipsePreferences) ExportedPreferences.newRoot().node(tree.absolutePath()); String[] scopes = filter.getScopes(); if (scopes == null)
private static void read(ProjectPreferences node, IFile file) throws BackingStoreException, CoreException { if (file == null || !file.exists()) { if (Policy.DEBUG_PREFERENCES) Policy.debug("Unable to determine preference file or file does not exist for node: " + node.absolutePath()); //$NON-NLS-1$ return; } Properties fromDisk = loadProperties(file); // no work to do if (fromDisk.isEmpty()) return; // create a new node to store the preferences in. IExportedPreferences myNode = (IExportedPreferences) ExportedPreferences.newRoot().node(node.absolutePath()); convertFromProperties((EclipsePreferences) myNode, fromDisk, false); //flag that we are currently reading, to avoid unnecessary writing boolean oldIsReading = node.isReading; node.isReading = true; try { Platform.getPreferencesService().applyPreferences(myNode); } finally { node.isReading = oldIsReading; } }
private static void read(ProjectPreferences node, IFile file) throws BackingStoreException, CoreException { if (file == null || !file.exists()) { if (Policy.DEBUG_PREFERENCES) Policy.debug("Unable to determine preference file or file does not exist for node: " + node.absolutePath()); //$NON-NLS-1$ return; } Properties fromDisk = loadProperties(file); // no work to do if (fromDisk.isEmpty()) return; // create a new node to store the preferences in. IExportedPreferences myNode = (IExportedPreferences) ExportedPreferences.newRoot().node(node.absolutePath()); convertFromProperties((EclipsePreferences) myNode, fromDisk, false); //flag that we are currently reading, to avoid unnecessary writing boolean oldIsReading = node.isReading; node.isReading = true; try { Platform.getPreferencesService().applyPreferences(myNode); } finally { node.isReading = oldIsReading; } }
private static void read(ProjectPreferences node, IFile file) throws BackingStoreException, CoreException { if (file == null || !file.exists()) { if (Policy.DEBUG_PREFERENCES) Policy.debug("Unable to determine preference file or file does not exist for node: " + node.absolutePath()); //$NON-NLS-1$ return; } Properties fromDisk = loadProperties(file); // no work to do if (fromDisk.isEmpty()) return; // create a new node to store the preferences in. IExportedPreferences myNode = (IExportedPreferences) ExportedPreferences.newRoot().node(node.absolutePath()); convertFromProperties((EclipsePreferences) myNode, fromDisk, false); //flag that we are currently reading, to avoid unnecessary writing boolean oldIsReading = node.isReading; node.isReading = true; try { Platform.getPreferencesService().applyPreferences(myNode); } finally { node.isReading = oldIsReading; } }