Properties newProps = new Properties();
IClasspathEntry[] newEntries = containerSuggestion.getClasspathEntries();
for (int i = 0; i < newEntries.length; i++) {
IClasspathEntry entry = newEntries[i];
if (IClasspathEntry.CPE_LIBRARY == entry.getEntryKind()) {
String path = entry.getPath().toPortableString();
if (entry.getSourceAttachmentPath() != null) {
newProps.put(path + SRC_SUFFIX, entry.getSourceAttachmentPath()
.toPortableString());
}
if (entry.getSourceAttachmentRootPath() != null) {
newProps.put(path + SRCROOT_SUFFIX, entry.getSourceAttachmentRootPath()
.toPortableString());
}
String javadocUrl = getJavadocLocation(entry);
if (javadocUrl != null) {
newProps.put(path + DOC_SUFFIX, javadocUrl);
}
}
}
IvyClasspathContainerImpl ivycp = (IvyClasspathContainerImpl) IvyClasspathContainerHelper
.getContainer(containerPath, project);
if (ivycp == null) {
IvyDEMessage
.error("The IvyDE container could not be found. Aborting updating attachements.");
// something wrong happened, give up
return;
}
IClasspathEntry[] existingEntries = ivycp.getClasspathEntries();
for (int i = 0; i < existingEntries.length; i++) {
IClasspathEntry entry = existingEntries[i];
if (IClasspathEntry.CPE_LIBRARY == entry.getEntryKind()) {
String path = entry.getPath().toPortableString();
String value = (String) prop.get(path + SRC_SUFFIX);
if (value != null && entry.getSourceAttachmentPath() != null
&& value.equals(entry.getSourceAttachmentPath().toPortableString())) {
newProps.remove(path + SRC_SUFFIX);
}
value = (String) prop.get(path + SRCROOT_SUFFIX);
if (value != null && entry.getSourceAttachmentRootPath() != null
&& value.equals(entry.getSourceAttachmentRootPath().toPortableString())) {
newProps.remove(path + SRCROOT_SUFFIX);
}
}
}