Community
Participate
Working Groups
In base GEF, ctrl-drag creates a Clone request. The equivalent GMF request is "Duplicate." DragEditPartsTrackerEx subclasses the GEF DragEditPartsTracker but removes the "clone" functionality. It should interprete the cloen as a duplicate request. I've create an anonymous subclass here that allows me to create duplicate requests which works. One last thing that is lacking is that the new edit parts are not positioned at the destination. This code can be used as a base to implement this functionality in the DragEditPartsTrackerEx class itself. (This code snippet is defined in my ShapeNodeEditPart subclass) public DragTracker getDragTracker(Request request) { return new DragEditPartsTrackerEx(this) { protected void addSourceCommands(boolean isMove, CompoundCommand command) { Iterator iter = getOperationSet().iterator(); ChangeBoundsRequest request = (ChangeBoundsRequest)getTargetRequest(); DuplicateRequest dupRequest = null; if (isCloneActive()) { dupRequest = new DuplicateRequest(); dupRequest.setEditParts( request.getEditParts() ); dupRequest.setExtendedData( request.getExtendedData() ); } else { request.setType(isMove ? REQ_MOVE : RequestConstants.REQ_DRAG); } while (iter.hasNext()) { EditPart editPart = (EditPart) iter.next(); if (dupRequest!=null) { command.add(editPart.getCommand(dupRequest)); } else { command.add(editPart.getCommand(request)); } } request.setType(RequestConstants.REQ_DROP); } }; } A few issues you might expierence: First DuplicateRequest is internal. Second, superclasses of DragEditPartsTracker expect the target request to be of type ChangeBoundsRequest, (like #updateTargetRequest())but the ContainerEditPolicy expects the request of type "Duplicate" to be of type "DuplicateRequest." Hence why you see me creating a temporary DuplicateRequest and sending it to the editpart.
adding api keyword
Moving to M6. Min: perhaps you could contribute a patch for this?
Descoped from M6.
- Ctrl + drag shapes on a diagram will now perform a duplicate command.
[GMF Restructure] Bug 319140 : product GMF and component Runtime Diagram was the original product and component for this bug