/** * @see * org.eclipse.gef.editpolicies.ContainerEditPolicy#getAddCommand(org.eclipse.gef.requests.GroupRequest) */ protected Command getAddCommand(GroupRequest request) { CompoundCommand cmd = new CompoundCommand(); for (int i = 0; i < request.getEditParts().size(); i++) { AddAndAssignSourceCommand add = new AddAndAssignSourceCommand(); add.setParent((StructuredActivity) getHost().getParent().getModel()); add.setSource((Activity) getHost().getModel()); add.setChild(((Activity) ((EditPart) request.getEditParts().get(i)).getModel())); cmd.add(add); } return cmd; }
/** * Returns a command for graphical delete (with local conditions also deleted). * * @see org.eclipse.gef.EditPolicy#getCommand(Request) * @return the command or null */ @Override public Command getCommand(Request request) { if (RequestConstants.REQ_DELETE.equals(request.getType())) { if (request instanceof GroupRequest) { // List of parts from the request is not up to date. Consider the host only. List<?> parts = Collections.singletonList(getHost()); ((GroupRequest) request).setEditParts(getHost()); // inspect the list of parts to add linked local conditions List<EditPart> partsToAdd = getListOfLinkedLocalConditionsParts(parts); ((GroupRequest) request).getEditParts().addAll(partsToAdd); return getDeleteCommand((GroupRequest) request); } } return null; }