/** Execution of the command */ @Override protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { View view = getView(); List<Edge> sourceList = ViewUtil.getSourceConnections(view); List<Edge> targetList = ViewUtil.getTargetConnections(view); for (Edge edge : sourceList) { IdentityAnchor anchor = (IdentityAnchor) edge.getSourceAnchor(); if (anchor != null) { anchor.setId(getNewIdStr(anchor)); } } for (Edge edge : targetList) { IdentityAnchor anchor = (IdentityAnchor) edge.getTargetAnchor(); if (anchor != null) { anchor.setId(getNewIdStr(anchor)); } } return CommandResult.newOKCommandResult(); }
/** * This operation checks if, after resizing the ShapeNodeEditPart, all links anchors will fit * inside the figure in case their positions are preserved * * @param shapeEP That shape being resized * @param sizeDelta The SizeDelta for the resize * @param preserveAxis The axisxxx * @return The new SizeDelta to preserve anchors' positions */ public static Dimension getSizeDeltaToFitAnchors( ShapeNodeEditPart shapeEP, Dimension sizeDelta, int preserveAxis) { Dimension newSizeDelta = new Dimension(sizeDelta); View view = (View) shapeEP.getModel(); Rectangle figureBounds = shapeEP.getFigure().getBounds(); List<Edge> sourceList = ViewUtil.getSourceConnections(view); List<Edge> targetList = ViewUtil.getTargetConnections(view); for (Edge edge : sourceList) { IdentityAnchor anchor = (IdentityAnchor) edge.getSourceAnchor(); modifySizeDeltaToFitAnchor(anchor, newSizeDelta, preserveAxis, figureBounds); } for (Edge edge : targetList) { IdentityAnchor anchor = (IdentityAnchor) edge.getTargetAnchor(); modifySizeDeltaToFitAnchor(anchor, newSizeDelta, preserveAxis, figureBounds); } return newSizeDelta; }
/* (non-Javadoc) * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#getModelSourceConnections() */ protected List getModelSourceConnections() { return ViewUtil.getSourceConnections(getEdge()); }