use of org.eclipse.gmf.runtime.emf.commands.core.commands.RepositionEObjectCommand in project statecharts by Yakindu.
the class CompartmentLayoutEditPolicy method createMoveChildCommand.
@Override
@SuppressWarnings("rawtypes")
protected Command createMoveChildCommand(EditPart child, EditPart after) {
int newIndex;
int displacement;
int childIndex = getHost().getChildren().indexOf(child);
int afterIndex = getHost().getChildren().indexOf(after);
if (afterIndex == -1) {
newIndex = getHost().getChildren().size() - 1;
displacement = newIndex - childIndex;
} else {
newIndex = afterIndex;
displacement = afterIndex - childIndex;
if (childIndex <= afterIndex) {
newIndex--;
displacement--;
}
}
TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
RepositionEObjectCommand command = new CompartmentRepositionEObjectCommand(child, editingDomain, "", (EList) ((View) child.getParent().getModel()).getElement().eGet(feature), ((View) child.getModel()).getElement(), displacement, newIndex);
eraseLayoutTargetFeedback(null);
return new ICommandProxy(command);
}
Aggregations