use of de.pdark.decentxml.Node in project sling by apache.
the class JcrNode method delete.
public void delete() {
if (parent == null) {
// then I dont know how to delete
return;
}
parent.children.remove(this);
if (resource != null) {
IWorkspaceRunnable r = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
resource.delete(true, monitor);
if (dirSibling != null) {
dirSibling.getResource().delete(true, monitor);
}
}
};
try {
ResourcesPlugin.getWorkspace().run(r, null);
} catch (CoreException e) {
Activator.getDefault().getPluginLogger().error("Error renaming resource (" + resource + "): " + e, e);
}
}
if (domElement != null) {
Element parentNode = domElement.getParentElement();
domElement.remove();
if (parentNode != null) {
List<Node> allChildNodes = parentNode.getNodes();
boolean nonTextChild = false;
for (Iterator<Node> it = allChildNodes.iterator(); it.hasNext(); ) {
Node node = it.next();
if (node.getType() != Type.TEXT) {
nonTextChild = true;
}
}
if (!nonTextChild) {
for (Iterator<Node> it = allChildNodes.iterator(); it.hasNext(); ) {
Node node = it.next();
it.remove();
}
if (!parentNode.hasNodes()) {
parentNode.setCompactEmpty(true);
}
}
}
}
if (underlying != null) {
underlying.save();
}
}
Aggregations