Lines 1282-1348
Link Here
|
1282 |
*/ |
1282 |
*/ |
1283 |
public void preferenceChange(IEclipsePreferences.PreferenceChangeEvent event) { |
1283 |
public void preferenceChange(IEclipsePreferences.PreferenceChangeEvent event) { |
1284 |
String propertyName = event.getKey(); |
1284 |
String propertyName = event.getKey(); |
1285 |
if (propertyName.startsWith(CP_VARIABLE_PREFERENCES_PREFIX)) { |
1285 |
if (propertyName.startsWith(JavaCore.PLUGIN_ID)) { |
1286 |
String varName = propertyName.substring(CP_VARIABLE_PREFERENCES_PREFIX.length()); |
1286 |
if (propertyName.startsWith(CP_VARIABLE_PREFERENCES_PREFIX)) { |
1287 |
JavaModelManager manager = getJavaModelManager(); |
1287 |
String varName = propertyName.substring(CP_VARIABLE_PREFERENCES_PREFIX.length()); |
1288 |
if (manager.variablesWithInitializer.contains(varName)) { |
1288 |
JavaModelManager manager = getJavaModelManager(); |
1289 |
// revert preference value as we will not apply it to JavaCore classpath variable |
1289 |
if (manager.variablesWithInitializer.contains(varName)) { |
1290 |
String oldValue = (String) event.getOldValue(); |
1290 |
// revert preference value as we will not apply it to JavaCore classpath variable |
1291 |
if (oldValue == null) { |
1291 |
String oldValue = (String) event.getOldValue(); |
1292 |
// unexpected old value => remove variable from set |
1292 |
if (oldValue == null) { |
1293 |
manager.variablesWithInitializer.remove(varName); |
1293 |
// unexpected old value => remove variable from set |
1294 |
} else { |
1294 |
manager.variablesWithInitializer.remove(varName); |
1295 |
manager.getInstancePreferences().put(varName, oldValue); |
1295 |
} else { |
1296 |
} |
1296 |
manager.getInstancePreferences().put(varName, oldValue); |
1297 |
} else { |
1297 |
} |
1298 |
String newValue = (String)event.getNewValue(); |
1298 |
} else { |
1299 |
IPath newPath; |
1299 |
String newValue = (String)event.getNewValue(); |
1300 |
if (newValue != null && !(newValue = newValue.trim()).equals(CP_ENTRY_IGNORE)) { |
1300 |
IPath newPath; |
1301 |
newPath = new Path(newValue); |
1301 |
if (newValue != null && !(newValue = newValue.trim()).equals(CP_ENTRY_IGNORE)) { |
1302 |
} else { |
1302 |
newPath = new Path(newValue); |
1303 |
newPath = null; |
1303 |
} else { |
1304 |
} |
1304 |
newPath = null; |
1305 |
try { |
1305 |
} |
1306 |
SetVariablesOperation operation = new SetVariablesOperation(new String[] {varName}, new IPath[] {newPath}, false/*don't update preferences*/); |
1306 |
try { |
1307 |
operation.runOperation(null/*no progress available*/); |
1307 |
SetVariablesOperation operation = new SetVariablesOperation(new String[] {varName}, new IPath[] {newPath}, false/*don't update preferences*/); |
1308 |
} catch (JavaModelException e) { |
1308 |
operation.runOperation(null/*no progress available*/); |
1309 |
Util.log(e, "Could not set classpath variable " + varName + " to " + newPath); //$NON-NLS-1$ //$NON-NLS-2$ |
1309 |
} catch (JavaModelException e) { |
1310 |
} |
1310 |
Util.log(e, "Could not set classpath variable " + varName + " to " + newPath); //$NON-NLS-1$ //$NON-NLS-2$ |
1311 |
} |
1311 |
} |
1312 |
} else if (propertyName.startsWith(CP_CONTAINER_PREFERENCES_PREFIX)) { |
1312 |
} |
1313 |
recreatePersistedContainer(propertyName, (String)event.getNewValue(), false); |
1313 |
} else if (propertyName.startsWith(CP_CONTAINER_PREFERENCES_PREFIX)) { |
1314 |
} else if (propertyName.equals(JavaCore.CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER) || |
1314 |
recreatePersistedContainer(propertyName, (String)event.getNewValue(), false); |
1315 |
propertyName.equals(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER) || |
1315 |
} else if (propertyName.equals(JavaCore.CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER) || |
1316 |
propertyName.equals(JavaCore.CORE_JAVA_BUILD_DUPLICATE_RESOURCE) || |
1316 |
propertyName.equals(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER) || |
1317 |
propertyName.equals(JavaCore.CORE_JAVA_BUILD_RECREATE_MODIFIED_CLASS_FILES_IN_OUTPUT_FOLDER) || |
1317 |
propertyName.equals(JavaCore.CORE_JAVA_BUILD_DUPLICATE_RESOURCE) || |
1318 |
propertyName.equals(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH) || |
1318 |
propertyName.equals(JavaCore.CORE_JAVA_BUILD_RECREATE_MODIFIED_CLASS_FILES_IN_OUTPUT_FOLDER) || |
1319 |
propertyName.equals(JavaCore.CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS) || |
1319 |
propertyName.equals(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH) || |
1320 |
propertyName.equals(JavaCore.CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS) || |
1320 |
propertyName.equals(JavaCore.CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS) || |
1321 |
propertyName.equals(JavaCore.CORE_INCOMPLETE_CLASSPATH) || |
1321 |
propertyName.equals(JavaCore.CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS) || |
1322 |
propertyName.equals(JavaCore.CORE_CIRCULAR_CLASSPATH) || |
1322 |
propertyName.equals(JavaCore.CORE_INCOMPLETE_CLASSPATH) || |
1323 |
propertyName.equals(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL)) { |
1323 |
propertyName.equals(JavaCore.CORE_CIRCULAR_CLASSPATH) || |
1324 |
JavaModelManager manager = JavaModelManager.getJavaModelManager(); |
1324 |
propertyName.equals(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL)) { |
1325 |
IJavaModel model = manager.getJavaModel(); |
1325 |
JavaModelManager manager = JavaModelManager.getJavaModelManager(); |
1326 |
IJavaProject[] projects; |
1326 |
IJavaModel model = manager.getJavaModel(); |
1327 |
try { |
1327 |
IJavaProject[] projects; |
1328 |
projects = model.getJavaProjects(); |
1328 |
try { |
1329 |
for (int i = 0, pl = projects.length; i < pl; i++) { |
1329 |
projects = model.getJavaProjects(); |
1330 |
JavaProject javaProject = (JavaProject) projects[i]; |
1330 |
for (int i = 0, pl = projects.length; i < pl; i++) { |
1331 |
manager.deltaState.addClasspathValidation(javaProject); |
1331 |
JavaProject javaProject = (JavaProject) projects[i]; |
1332 |
try { |
1332 |
manager.deltaState.addClasspathValidation(javaProject); |
1333 |
// need to touch the project to force validation by DeltaProcessor |
1333 |
try { |
1334 |
javaProject.getProject().touch(null); |
1334 |
// need to touch the project to force validation by DeltaProcessor |
1335 |
} catch (CoreException e) { |
1335 |
javaProject.getProject().touch(null); |
1336 |
// skip |
1336 |
} catch (CoreException e) { |
1337 |
} |
1337 |
// skip |
|
|
1338 |
} |
1339 |
} |
1340 |
} catch (JavaModelException e) { |
1341 |
// skip |
1338 |
} |
1342 |
} |
1339 |
} catch (JavaModelException e) { |
1343 |
} else if (propertyName.startsWith(CP_USERLIBRARY_PREFERENCES_PREFIX)) { |
1340 |
// skip |
1344 |
String libName = propertyName.substring(CP_USERLIBRARY_PREFERENCES_PREFIX.length()); |
|
|
1345 |
UserLibraryManager manager = JavaModelManager.getUserLibraryManager(); |
1346 |
manager.updateUserLibrary(libName, (String)event.getNewValue()); |
1347 |
} |
1348 |
} |
1349 |
// Reset all project caches (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=233568 ) |
1350 |
try { |
1351 |
IJavaProject[] projects = JavaModelManager.getJavaModelManager().getJavaModel().getJavaProjects(); |
1352 |
for (int i = 0, length = projects.length; i < length; i++) { |
1353 |
((JavaProject) projects[i]).resetCaches(); |
1341 |
} |
1354 |
} |
1342 |
} else if (propertyName.startsWith(CP_USERLIBRARY_PREFERENCES_PREFIX)) { |
1355 |
} catch (JavaModelException e) { |
1343 |
String libName = propertyName.substring(CP_USERLIBRARY_PREFERENCES_PREFIX.length()); |
1356 |
// cannot retrieve Java projects |
1344 |
UserLibraryManager manager = JavaModelManager.getUserLibraryManager(); |
|
|
1345 |
manager.updateUserLibrary(libName, (String)event.getNewValue()); |
1346 |
} |
1357 |
} |
1347 |
} |
1358 |
} |
1348 |
} |
1359 |
} |