/*
* Paraphrase: change (or rather "add to another") parent command
*/
@Override
protected Command createAddCommand(EditPart child, Object constraint) {
ElementRecordAddCommand command = null;
log.trace("Create Add Command " + child);
if (child instanceof ElementRecordPart) {
LayoutElementRecord parent = (LayoutElementRecord) getHost()
.getModel();
if (child.getModel() instanceof SVGPolylineRecord) {
parent = LayoutUtils.translateToAndGetRoot(
(Translatable) constraint, parent);
} else {
parent = LayoutUtils.translateAndGetParent(
(Translatable) constraint, parent);
}
// if parent is same than just change the layout
if (parent.equals(((ElementRecordPart) child).getElementRecord()
.getParent())) {
return createChangeConstraintCommand(child, constraint);
}
command = new ElementRecordAddCommand();
command.setElementModel(child.getModel());
command.setParent(parent);
command.setLayout((Rectangle) constraint);
}
return command;
}