use of org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart in project statecharts by Yakindu.
the class BarResizeEditPolicy method getResizeCommand.
@Override
protected Command getResizeCommand(final ChangeBoundsRequest request) {
GraphicalEditPart editPart = (IGraphicalEditPart) getHost();
Rectangle locationAndSize = new PrecisionRectangle(editPart.getFigure().getBounds());
editPart.getFigure().translateToAbsolute(locationAndSize);
final Rectangle origRequestedBounds = request.getTransformedRectangle(locationAndSize);
final Rectangle modified = origRequestedBounds.getCopy();
checkAndPrepareConstraint(request, modified);
// final Dimension sizeDelta = request.getSizeDelta();
Dimension newDelta = new Dimension(modified.width - locationAndSize.width, modified.height - locationAndSize.height);
// ((IGraphicalEditPart) getHost()).getFigure()
// .translateToAbsolute(newDelta);
request.setSizeDelta(newDelta);
final Point moveDelta = request.getMoveDelta();
request.setMoveDelta(new Point(moveDelta.x - origRequestedBounds.x + modified.x, moveDelta.y - origRequestedBounds.y + modified.y));
return super.getResizeCommand(request);
}
use of org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart in project statecharts by Yakindu.
the class InitializeTreeNodeAnnotationsCommand method annotateElements.
private CompositeTransactionalCommand annotateElements(List<IGraphicalEditPart> elements) {
final CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), "AnnotateChildren");
cmd.add(new SetTreeNodesPositionAnnotationCommand(getEditingDomain(), TreeLayoutUtil.getViews(elements)));
for (final IGraphicalEditPart editPart : elements) {
final List<IGraphicalEditPart> children = TreeLayoutUtil.getOrderedTreeChildren(editPart);
if (!children.isEmpty()) {
cmd.add(annotateElements(children));
}
}
return cmd;
}
use of org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart in project statecharts by Yakindu.
the class UpdateAnnotationsOnReorientRelationshipCommand method doExecuteWithResult.
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
// Update annotations of old connection end;
final IGraphicalEditPart oldEnd = UIUtils.getEditPart(request.getOldRelationshipEnd());
if (oldEnd != null) {
final List<IGraphicalEditPart> treeChildren = TreeLayoutUtil.getOrderedTreeChildren(oldEnd);
treeChildren.remove(sourceEditPart);
TreeLayoutUtil.setTreeNodesPositionAnnotation(TreeLayoutUtil.getViews(treeChildren));
}
// Update annotations of new connection end;
final IGraphicalEditPart newEnd = UIUtils.getEditPart(request.getNewRelationshipEnd());
if (newEnd != null) {
final List<IGraphicalEditPart> treeChildren = TreeLayoutUtil.getOrderedTreeChildren(newEnd);
treeChildren.add(sourceEditPart);
TreeLayoutUtil.setTreeNodesPositionAnnotation(TreeLayoutUtil.getViews(treeChildren));
// Update parentAnnotation to new end
TreeLayoutUtil.setTreeNodeParentAnnotation(sourceEditPart.getNotationView(), newEnd.getNotationView());
}
return CommandResult.newOKCommandResult();
}
use of org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart in project statecharts by Yakindu.
the class EnlargeContainerEditPolicy method showChildrenFeedback.
@SuppressWarnings("unchecked")
protected /**
* containerFeedbackBounds as absolute
*
* @param containerEditPart
* @param containerFigure
* @param containerFeedbackBounds
*/
void showChildrenFeedback(final IGraphicalEditPart containerEditPart, final IFigure containerFigure, final Rectangle containerFeedbackBounds, ChangeBoundsRequest request) {
Rectangle originalBounds = getOriginalBounds(containerFigure);
Point moveDelta = new Point(containerFeedbackBounds.width - originalBounds.width, containerFeedbackBounds.height - originalBounds.height);
List<IGraphicalEditPart> children = containerEditPart.getParent().getChildren();
for (IGraphicalEditPart childPart : children) {
if (request.getEditParts().contains(childPart)) {
continue;
}
if (childPart == containerEditPart)
continue;
showChildFeedback(childPart, moveDelta, containerFeedbackBounds);
}
}
use of org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart in project statecharts by Yakindu.
the class EnlargeContainerEditPolicy method collectContainerHierachy.
protected List<IGraphicalEditPart> collectContainerHierachy() {
List<IGraphicalEditPart> result = new ArrayList<IGraphicalEditPart>();
IGraphicalEditPart containerEditPart = (IGraphicalEditPart) getHost();
while (containerEditPart != null) {
containerEditPart = getContainer(containerEditPart);
if (containerEditPart != null)
result.add(containerEditPart);
}
return result;
}
Aggregations