/** * Complete the given composite command with RegionContainer specific resize commands: the * commands to report the RegionContainer resize on its regions. */ @Override protected void completeResizeCommand( CompositeTransactionalCommand ctc, ChangeBoundsRequest request) { if (request.getEditParts().size() > 1 && !request.isConstrainedResize()) { ctc.add(UnexecutableCommand.INSTANCE); return; } Collection<ChangeBoundsRequest> siblingRequests = getConstrainedRegionRequests(request); if (!siblingRequests.isEmpty()) { for (ChangeBoundsRequest siblingRequest : siblingRequests) { if (siblingRequest.getEditParts() != null) { for (IGraphicalEditPart constrainedPart : Iterables.filter(siblingRequest.getEditParts(), IGraphicalEditPart.class)) { Command constrainedCommand = constrainedPart.getCommand(siblingRequest); if (constrainedCommand == null) { ctc.add(UnexecutableCommand.INSTANCE); } else { ctc.add(new CommandProxy(constrainedCommand)); } } } } } else if (!(request.isConstrainedMove() || request.isConstrainedResize())) { // Deactivate the manual resize of RegionContainer when there are no // regions. ctc.add(UnexecutableCommand.INSTANCE); } // Adjust border nodes and edges. ctc.add(new ChildrenAdjustmentCommand((IGraphicalEditPart) getHost(), request, true, false)); }
/** * Override to return the <code>Command</code> to perform an {@link RequestConstants#REQ_CLONE * CLONE}. By default, <code>null</code> is returned. * * @param request the Clone Request * @return A command to perform the Clone. */ protected Command getCloneCommand(ChangeBoundsRequest request) { CloneCommand clone = new CloneCommand(); clone.setParent((LogicDiagram) getHost().getModel()); Iterator i = request.getEditParts().iterator(); GraphicalEditPart currPart = null; while (i.hasNext()) { currPart = (GraphicalEditPart) i.next(); clone.addPart( (LogicSubpart) currPart.getModel(), (Rectangle) getConstraintFor(request, currPart)); } // Attach to horizontal guide, if one is given Integer guidePos = (Integer) request.getExtendedData().get(SnapToGuides.KEY_HORIZONTAL_GUIDE); if (guidePos != null) { int hAlignment = ((Integer) request.getExtendedData().get(SnapToGuides.KEY_HORIZONTAL_ANCHOR)).intValue(); clone.setGuide(findGuideAt(guidePos.intValue(), true), hAlignment, true); } // Attach to vertical guide, if one is given guidePos = (Integer) request.getExtendedData().get(SnapToGuides.KEY_VERTICAL_GUIDE); if (guidePos != null) { int vAlignment = ((Integer) request.getExtendedData().get(SnapToGuides.KEY_VERTICAL_ANCHOR)).intValue(); clone.setGuide(findGuideAt(guidePos.intValue(), false), vAlignment, false); } return clone; }
@Override protected Command getAddCommand(Request req) { ChangeBoundsRequest request = (ChangeBoundsRequest) req; List editParts = request.getEditParts(); CompoundCommand command = new CompoundCommand(); for (int i = 0; i < editParts.size(); i++) { EditPart child = (EditPart) editParts.get(i); command.add(createAddCommand(child)); } return command.unwrap(); }
@SuppressWarnings("unchecked") @Override protected Command getCloneCommand(final ChangeBoundsRequest request) { final ArrayList<EObject> copies = new ArrayList<EObject>(); for (final EditPart editPart : (List<EditPart>) request.getEditParts()) { final EObject copy = EcoreUtil.copy((EObject) editPart.getModel()); setConstraint(copy, (Rectangle) getConstraintForClone((GraphicalEditPart) editPart, request)); copies.add(copy); } final String copyString = ClipboardUtil.copyElementsToString(copies, null, new NullProgressMonitor()); final PasteCommand pasteCommand = new PasteCommand((EObject) getHost().getModel(), copyString); return pasteCommand; }