in org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyAttachmentManager.java [64:126]
public void updateAttachments(IJavaProject project, IPath containerPath,
IClasspathContainer containerSuggestion) {
IvyDEMessage.verbose("Updating attachments to the container " + containerPath);
Properties newProps = new Properties();
IClasspathEntry[] newEntries = containerSuggestion.getClasspathEntries();
for (IClasspathEntry entry : newEntries) {
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 attachments.");
// something wrong happened, give up
return;
}
for (IClasspathEntry entry : ivycp.getClasspathEntries()) {
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);
}
}
}
// copy the actually new overridden properties
prop.putAll(newProps);
// now update the ivyde container for real
ivycp.updateClasspathEntries(newEntries);
// store the global result
IvyDEMessage.verbose("Saving attachment properties");
try (FileOutputStream out = new FileOutputStream(containersAttachmentFile)) {
prop.store(out, "");
} catch (IOException ioe) {
IvyPlugin.logWarn("IvyDE attachment properties could not be saved", ioe);
}
}