|
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 keep the node as it might still be referenced |
| 247 |
try { |
250 |
try { |
| 248 |
node.removeNode(); |
251 |
clearAll(node); |
| 249 |
} catch (BackingStoreException e) { |
252 |
} catch (BackingStoreException e) { |
|
|
253 |
String message = NLS.bind(Messages.preferences_clearNodeException, node.absolutePath()); |
| 250 |
IStatus status = new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, IStatus.ERROR, message, e); |
254 |
IStatus status = new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, IStatus.ERROR, message, e); |
| 251 |
throw new CoreException(status); |
255 |
throw new CoreException(status); |
| 252 |
} |
256 |
} |