}
}
}
private void handleChildRemoval(final PsiElement pParent, final PsiElement pChild) {
final XmlTag parent = PsiTreeUtil.getParentOfType(pParent,
XmlTag.class,
false);
if (parent == null)
return;
//
//if the removed tag was the container tag, fire global change event
//
final XmlTag containerTag = containerPath.getTag();
if (containerTag == null) {
if (pChild instanceof XmlTag) {
final XmlTag tag = (XmlTag) pChild;
final String[] path = PsiUtils.getPathAndConcat(parent, tag.getName());
if (path.equals(containerPath.getPathTokens()))
fireRowsChangedEvent();
}
return;
}
//
//if the removed child was a text node, simply find which property it belonged to
//
if (pChild instanceof XmlText) {
final XmlTag[] rowTags = containerTag.findSubTags(rowTagName);
for (int i = 0; i < rowTags.length; i++) {
rowPath.setRow(i);
if (PsiTreeUtil.isAncestor(rowPath.getTag(), pChild, false)) {
final String property = mapper.findPropertyForElement(pChild);
if (property != null)
fireRowChangedEvent(i, property);
}
}
}
//
//if the removed child is a tag, check if it is a row tag or a property tag
//
else if (pChild instanceof XmlTag) {
rowPath.setRow(null);
final XmlTag tag = (XmlTag) pChild;
final String[] path = PsiUtils.getPathAndConcat(parent, tag.getName());
//if the removed tag is a registered property tag
final String propertyName = mapper.findPropertyByPath(path);
if (propertyName != null) {
final int row = findRowForElement(parent);
fireRowChangedEvent(row, propertyName);
}
//if the removed tag is a row tag
else if (rowTagName.equals(tag.getName())) {
//TODO: inspect event's offset to determine row number
//fireRowRemovedEvent(rowByOffset);
fireRowsChangedEvent();
}