Lines 152-185
Link Here
|
152 |
} |
152 |
} |
153 |
|
153 |
|
154 |
public void removeUserLibrary(String libName) { |
154 |
public void removeUserLibrary(String libName) { |
155 |
IEclipsePreferences instancePreferences = JavaModelManager.getJavaModelManager().getInstancePreferences(); |
155 |
synchronized (this.userLibraries) { |
156 |
String propertyName = CP_USERLIBRARY_PREFERENCES_PREFIX+libName; |
156 |
IEclipsePreferences instancePreferences = JavaModelManager.getJavaModelManager().getInstancePreferences(); |
157 |
instancePreferences.remove(propertyName); |
157 |
String propertyName = CP_USERLIBRARY_PREFERENCES_PREFIX+libName; |
158 |
try { |
158 |
instancePreferences.remove(propertyName); |
159 |
instancePreferences.flush(); |
159 |
try { |
160 |
} catch (BackingStoreException e) { |
160 |
instancePreferences.flush(); |
161 |
Util.log(e, "Exception while removing user library " + libName); //$NON-NLS-1$ |
161 |
} catch (BackingStoreException e) { |
|
|
162 |
Util.log(e, "Exception while removing user library " + libName); //$NON-NLS-1$ |
163 |
} |
162 |
} |
164 |
} |
163 |
// No need to lock this.userLibraries since SetContainerOperation uses ISchedulingRule now. |
165 |
// this.userLibraries was updated during the PreferenceChangeEvent (see preferenceChange(...)) |
164 |
} |
166 |
} |
165 |
|
167 |
|
166 |
public void setUserLibrary(String libName, IClasspathEntry[] entries, boolean isSystemLibrary) { |
168 |
public void setUserLibrary(String libName, IClasspathEntry[] entries, boolean isSystemLibrary) { |
167 |
IEclipsePreferences instancePreferences = JavaModelManager.getJavaModelManager().getInstancePreferences(); |
169 |
synchronized (this.userLibraries) { |
168 |
String propertyName = CP_USERLIBRARY_PREFERENCES_PREFIX + libName; |
170 |
IEclipsePreferences instancePreferences = JavaModelManager.getJavaModelManager().getInstancePreferences(); |
169 |
try { |
171 |
String propertyName = CP_USERLIBRARY_PREFERENCES_PREFIX+libName; |
170 |
String propertyValue = UserLibrary.serialize(entries, isSystemLibrary); |
172 |
try { |
171 |
instancePreferences.put(propertyName, propertyValue); // sends out a PreferenceChangeEvent (see |
173 |
String propertyValue = UserLibrary.serialize(entries, isSystemLibrary); |
172 |
// preferenceChange(...)) |
174 |
instancePreferences.put(propertyName, propertyValue); // sends out a PreferenceChangeEvent (see preferenceChange(...)) |
173 |
} catch (IOException e) { |
175 |
} catch (IOException e) { |
174 |
Util.log(e, "Exception while serializing user library " + libName); //$NON-NLS-1$ |
176 |
Util.log(e, "Exception while serializing user library " + libName); //$NON-NLS-1$ |
175 |
return; |
177 |
return; |
|
|
178 |
} |
179 |
try { |
180 |
instancePreferences.flush(); |
181 |
} catch (BackingStoreException e) { |
182 |
Util.log(e, "Exception while saving user library " + libName); //$NON-NLS-1$ |
183 |
} |
176 |
} |
184 |
} |
177 |
try { |
185 |
// this.userLibraries was updated during the PreferenceChangeEvent (see preferenceChange(...)) |
178 |
instancePreferences.flush(); |
|
|
179 |
} catch (BackingStoreException e) { |
180 |
Util.log(e, "Exception while saving user library " + libName); //$NON-NLS-1$ |
181 |
} |
182 |
// No need to lock this.userLibraries since SetContainerOperation uses ISchedulingRule now. |
183 |
} |
186 |
} |
184 |
|
187 |
|
185 |
} |
188 |
} |