Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 137398 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/core/internal/utils/Messages.java (-1 / +1 lines)
Lines 105-111 Link Here
105
	public static String preferences_deleteException;
105
	public static String preferences_deleteException;
106
	public static String preferences_loadException;
106
	public static String preferences_loadException;
107
	public static String preferences_operationCanceled;
107
	public static String preferences_operationCanceled;
108
	public static String preferences_removeNodeException;
108
	public static String preferences_clearNodeException;
109
	public static String preferences_saveProblems;
109
	public static String preferences_saveProblems;
110
	public static String preferences_syncException;
110
	public static String preferences_syncException;
111
111
(-)src/org/eclipse/core/internal/utils/messages.properties (-1 / +1 lines)
Lines 101-107 Link Here
101
preferences_deleteException=Exception deleting file: {0}.
101
preferences_deleteException=Exception deleting file: {0}.
102
preferences_loadException=Exception loading preferences from: {0}.
102
preferences_loadException=Exception loading preferences from: {0}.
103
preferences_operationCanceled=Operation canceled.
103
preferences_operationCanceled=Operation canceled.
104
preferences_removeNodeException=Exception while removing preference node: {0}.
104
preferences_clearNodeException=Exception while clearing preference node: {0}.
105
preferences_saveProblems=Exception occurred while saving project preferences: {0}.
105
preferences_saveProblems=Exception occurred while saving project preferences: {0}.
106
preferences_syncException=Exception occurred while synchronizing node: {0}.
106
preferences_syncException=Exception occurred while synchronizing node: {0}.
107
107
(-)src/org/eclipse/core/internal/resources/ProjectPreferences.java (-16 / +21 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2006 IBM Corporation and others.
2
 * Copyright (c) 2004, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 107-120 Link Here
107
			// ignore
107
			// ignore
108
		}
108
		}
109
109
110
		// if the node was loaded we need to clear the values and remove
110
		// clear the preferences
111
		// its reference from the parent (don't save it though)
111
		nodeDeleted(projectNode.node(qualifier));
112
		// otherwise just remove the reference from the parent
113
		String childPath = projectNode.absolutePath() + IPath.SEPARATOR + qualifier;
114
		if (projectNode.isAlreadyLoaded(childPath))
115
			removeNode(projectNode.node(qualifier));
116
		else
117
			projectNode.removeNode(qualifier);
118
112
119
		// notifies the CharsetManager if needed
113
		// notifies the CharsetManager if needed
120
		if (qualifier.equals(ResourcesPlugin.PI_RESOURCES))
114
		if (qualifier.equals(ResourcesPlugin.PI_RESOURCES))
Lines 136-143 Link Here
136
		Preferences projectNode = root.node(ProjectScope.SCOPE).node(project);
130
		Preferences projectNode = root.node(ProjectScope.SCOPE).node(project);
137
		// check if we need to notify the charset manager
131
		// check if we need to notify the charset manager
138
		boolean hasResourcesSettings = getFile(folder, ResourcesPlugin.PI_RESOURCES).exists();
132
		boolean hasResourcesSettings = getFile(folder, ResourcesPlugin.PI_RESOURCES).exists();
139
		// remove the preferences
133
		// clear the preferences
140
		removeNode(projectNode);
134
		nodeDeleted(projectNode);
141
		// notifies the CharsetManager 		
135
		// notifies the CharsetManager 		
142
		if (hasResourcesSettings)
136
		if (hasResourcesSettings)
143
			preferencesChanged(folder.getProject());
137
			preferencesChanged(folder.getProject());
Lines 155-162 Link Here
155
		Preferences projectNode = root.node(ProjectScope.SCOPE).node(project.getName());
149
		Preferences projectNode = root.node(ProjectScope.SCOPE).node(project.getName());
156
		// check if we need to notify the charset manager
150
		// check if we need to notify the charset manager
157
		boolean hasResourcesSettings = getFile(project, ResourcesPlugin.PI_RESOURCES).exists();
151
		boolean hasResourcesSettings = getFile(project, ResourcesPlugin.PI_RESOURCES).exists();
158
		// remove the preferences
152
		// clear the preferences
159
		removeNode(projectNode);
153
		nodeDeleted(projectNode);
160
		// notifies the CharsetManager 		
154
		// notifies the CharsetManager 		
161
		if (hasResourcesSettings)
155
		if (hasResourcesSettings)
162
			preferencesChanged(project);
156
			preferencesChanged(project);
Lines 241-252 Link Here
241
			node.isReading = oldIsReading;
235
			node.isReading = oldIsReading;
242
		}
236
		}
243
	}
237
	}
238
	
239
	private static void clearAll(Preferences node) throws BackingStoreException {
240
		node.clear();
241
		String[] names = node.childrenNames();
242
		for (int i = 0; i < names.length; i++) {
243
			clearAll(node.node(names[i]));
244
		}
245
	}
244
246
245
	static void removeNode(Preferences node) throws CoreException {
247
	static void nodeDeleted(Preferences node) throws CoreException {
246
		String message = NLS.bind(Messages.preferences_removeNodeException, node.absolutePath());
248
 		// if the underlying properties file was deleted, clear the values and remove
249
		// it from the list of loaded classes
250
		// keep the node as it might still be referenced
247
		try {
251
		try {
248
			node.removeNode();
252
			clearAll(node);
249
		} catch (BackingStoreException e) {
253
		} catch (BackingStoreException e) {
254
			String message = NLS.bind(Messages.preferences_clearNodeException, node.absolutePath());
250
			IStatus status = new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, IStatus.ERROR, message, e);
255
			IStatus status = new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, IStatus.ERROR, message, e);
251
			throw new CoreException(status);
256
			throw new CoreException(status);
252
		}
257
		}

Return to bug 137398