Bug 124034 - DragEditPartsTrackerEx should create DuplicateRequests since suberclass creates Clone requests
Summary: DragEditPartsTrackerEx should create DuplicateRequests since suberclass creat...
Status: RESOLVED FIXED
Alias: None
Product: GMF-Runtime
Classification: Modeling
Component: General (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal
Target Milestone: ---   Edit
Assignee: Cherie Revells CLA
QA Contact:
URL:
Whiteboard:
Keywords: api
Depends on:
Blocks:
 
Reported: 2006-01-16 16:02 EST by Min Idzelis CLA
Modified: 2010-07-19 12:25 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Min Idzelis CLA 2006-01-16 16:02:16 EST
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.
Comment 1 Steven R. Shaw CLA 2006-02-22 09:28:19 EST
adding api keyword
Comment 2 Steven R. Shaw CLA 2006-03-01 11:07:06 EST
Moving to M6.  Min: perhaps you could contribute a patch for this?
Comment 3 Steven R. Shaw CLA 2006-03-09 14:59:39 EST
Descoped from M6.
Comment 4 Cherie Revells CLA 2006-04-18 11:28:33 EDT
- Ctrl + drag shapes on a diagram will now perform a duplicate command.
Comment 5 Eclipse Webmaster CLA 2010-07-19 12:25:47 EDT
[GMF Restructure] Bug 319140 : product GMF and component
Runtime Diagram was the original product and component for this bug