* @param targetParent
* The target parent group for the element.
* @return true when move was successful
*/
public boolean moveElement(String name, Object sourceParent, Object targetParent) {
Element sourceGroup = null;
Element targetGroup = null;
Element element = null;
if (sourceParent != null) {
sourceGroup = getGroup(sourceParent);
element = getElement(sourceParent, name);
}
if (targetParent != null) {
targetGroup = getGroup(targetParent);
}
if (sourceGroup == null || targetGroup == null) {
return false;
}
if (DOM.isOrHasChild(sourceGroup, element)) {
DOM.removeChild(sourceGroup, element);
String newId = DOM.assembleId(targetGroup.getId(), name);
elementToName.remove(element.getId());
elementToName.put(newId, name);
DOM.setElementAttribute(element, "id", newId);
DOM.appendChild(targetGroup, element);
return true;
}