}
public static void changeDirLink(IFolder dirlinkFolder, IContainer target) {
IFile dirlink = dirlinkFolder.getFile(WGUtils.DIRLINK_FILE);
String linkTarget = computeDirLinkTarget(dirlinkFolder, target);
SAXReader saxReader = new SAXReader();
try {
File dirlinkFile = new File(dirlink.getLocationURI().getPath());
Document document = saxReader.read(dirlinkFile);
Element ele = (Element)document.selectSingleNode("/dirlink/path"); //TODO use statics
ele.addAttribute("location", linkTarget); //TODO use statics
XMLWriter output = new XMLWriter(new FileWriter(dirlinkFile));
try {
output.write( document );
} finally {
try {
output.close();
} catch (IOException e) {
}
}
} catch (DocumentException e) {
Activator.getDefault().logError("Can not parse xmlfile " + dirlink.getLocation(), e);
} catch (IOException e) {
Activator.getDefault().logError("Can not read/write file " + dirlink.getLocation(), e);
}
}