private Command createAlignmentCommand() { final AlignmentRequest request = new AlignmentRequest(RequestConstants.REQ_ALIGN); request.setAlignmentRectangle(calculateAlignmentRectangle(request)); request.setAlignment(alignment); final List editparts = getOperationSet(request); if (editparts.size() < 2) return null; final CompoundCommand command = new CompoundCommand(); command.setDebugLabel(getText()); for (int i = 0; i < editparts.size(); i++) { final EditPart editpart = (EditPart) editparts.get(i); command.add(editpart.getCommand(request)); } return command; }
private Command createAlignmentCommand() { AlignmentRequest request = new AlignmentRequest( RequestConstants.REQ_ALIGN); request.setAlignmentRectangle(calculateAlignmentRectangle(request)); request.setAlignment(alignment); List editparts = getOperationSet(request); if (editparts.size() < 2) return null; CompoundCommand command = new CompoundCommand(); command.setDebugLabel(getText()); for (int i = 0; i < editparts.size(); i++) { EditPart editpart = (EditPart) editparts.get(i); command.add(editpart.getCommand(request)); } return command; }
@Override protected Object getConstraintFor(ChangeBoundsRequest request, GraphicalEditPart child) { if (request instanceof AlignmentRequest) { return super.getConstraintFor(request, child); } final Rectangle rect = (Rectangle) super.getConstraintFor(request, child); final Rectangle cons = getCurrentConstraintFor(child); final int newTreePosition = TreeLayoutUtil.getNewTreeNodePosition( request.getLocation(), TreeLayoutUtil.getSiblings((IGraphicalEditPart) child)); if (cons instanceof TreeLayoutConstraint) { final TreeLayoutConstraint treeLayoutConstraint = (TreeLayoutConstraint) cons; return new TreeLayoutConstraint(rect, treeLayoutConstraint.isRoot(), newTreePosition); } return new TreeLayoutConstraint(rect, false, newTreePosition); }
private Command createAlignmentCommand() { final AlignmentRequest request = new AlignmentRequest(RequestConstants.REQ_ALIGN); request.setAlignmentRectangle(calculateAlignmentRectangle(request)); request.setAlignment(alignment); final List<?> editparts = getOperationSet(request); if (editparts.size() < 2) return null; final CompoundCommand command = new CompoundCommand(); command.setDebugLabel(getText()); for (int i = 0; i < editparts.size(); i++) { final EditPart editpart = (EditPart) editparts.get(i); command.add(editpart.getCommand(request)); } return command; }
@Override public Command getCommand(Request request) { Object type = request.getType(); if (!canMove()) { return null; } if (getHost()==null || getHost().getParent() == null) { // SPF-9135 NPE: GEF 3.6 superclass will try to access getHost().getParent().getCommand(req) return null; } if (REQ_MOVE.equals(type) && isDragAllowed()) return getMoveCommand((ChangeBoundsRequest)request); if (REQ_MOVE_INITIATED.equals(type)) return forwardToParent((ChangeBoundsRequest)request, REQ_MOVE_CHILDREN_INITIATED); if (REQ_MOVE_COMPLETED.equals(type)) return forwardToParent((ChangeBoundsRequest)request, REQ_MOVE_CHILDREN_COMPLETED); if (REQ_ORPHAN.equals(type)) return getOrphanCommand(request); if (REQ_ALIGN.equals(type)) return getAlignCommand((AlignmentRequest)request); return null; }
/** * Factors out RESIZE and ALIGN requests, otherwise calls <code>super</code> * . * * @see org.eclipse.gef.EditPolicy#getCommand(Request) */ public Command getCommand(Request request) { if (REQ_RESIZE_CHILDREN.equals(request.getType())) return getResizeChildrenCommand((ChangeBoundsRequest) request); if (REQ_ALIGN_CHILDREN.equals(request.getType())) return getAlignChildrenCommand((AlignmentRequest) request); return super.getCommand(request); }
/** * @see org.eclipse.gef.EditPolicy#getCommand(org.eclipse.gef.Request) */ public Command getCommand(Request request) { Object type = request.getType(); if (REQ_MOVE.equals(type) && isDragAllowed()) return getMoveCommand((ChangeBoundsRequest) request); if (REQ_ORPHAN.equals(type)) return getOrphanCommand(request); if (REQ_ALIGN.equals(type)) return getAlignCommand((AlignmentRequest) request); return null; }
/** * Returns the command contribution to an alignment request * * @param request * the alignment request * @return the contribution to the alignment */ protected Command getAlignCommand(AlignmentRequest request) { AlignmentRequest req = new AlignmentRequest(REQ_ALIGN_CHILDREN); req.setEditParts(getHost()); req.setAlignment(request.getAlignment()); req.setAlignmentRectangle(request.getAlignmentRectangle()); return getHost().getParent().getCommand(req); }
/** * Returns the command to align a group of children. By default, this is * treated the same as a resize, and * {@link #getResizeChildrenCommand(ChangeBoundsRequest)} is returned. * * @param request * the AligmentRequest * @return the command to perform alignment */ protected Command getAlignChildrenCommand(AlignmentRequest request) { return getResizeChildrenCommand(request); }