protected void changeModel(XPDLElementChangeInfo info) {
try {
if (info.getAction() == XPDLElementChangeInfo.INSERTED) {
if (info.getChangedElement() instanceof XMLCollection) {
XMLCollection col = (XMLCollection) info.getChangedElement();
List lst = info.getChangedSubElements();
for (int i = 0; i < lst.size(); i++) {
col.add((XMLElement) lst.get(i));
}
}
} else if (info.getAction() == XPDLElementChangeInfo.REMOVED) {
if (info.getChangedElement() instanceof XMLCollection) {
XMLCollection col = (XMLCollection) info.getChangedElement();
List lst = info.getChangedSubElements();
for (int i = 0; i < lst.size(); i++) {
col.remove((XMLElement) lst.get(i));
}
}
} else if (info.getAction() == XPDLElementChangeInfo.UPDATED) {
XMLElement el = info.getChangedElement();
if (el instanceof XMLComplexChoice) {
((XMLComplexChoice) el).setChoosen((XMLElement) info.getNewValue());
} else {
el.setValue(info.getNewValue().toString());
}
} else if (info.getAction() == XPDLElementChangeInfo.REPOSITIONED) {
XMLCollection col = (XMLCollection) info.getChangedElement();
List lst = info.getChangedSubElements();
List newPositions = (List) info.getNewValue();
for (int i = 0; i < lst.size(); i++) {
col.reposition((XMLElement) lst.get(i), ((Integer) newPositions.get(i)).intValue());
}
}
} catch (Exception e) {
//ignore