Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Drag & Drop
Drag & Drop [message #248073] Fri, 03 April 2009 22:25
Eric Jain is currently offline Eric JainFriend
Messages: 266
Registered: July 2009
Senior Member
I'd like to be able to drag a GraphicalEditPart to another one and have
this result in certain properties of the model of the former being copied
to the model of later. This ought to be simple as no new objects are
created and nothing is moved, but it's different from the examples I've
come across so far.

So far I have the following code that lets me drag a selected
GraphicalEditPart to other drop targets such as an existing TableViewer
(set up with tableViewer.addDropSupport()):

graphicalViewer.addDragSourceListener(new TransferDragSourceListener() {

@Override
public void dragStart(DragSourceEvent event) {
event.doit = true;
}

@Override
public void dragSetData(DragSourceEvent event) {
if
(LocalSelectionTransfer.getTransfer().isSupportedType(event. dataType)) {

LocalSelectionTransfer.getTransfer().setSelection(graphicalV iewer.getSelection());
}
}

@Override
public Transfer getTransfer() {
return LocalSelectionTransfer.getTransfer();
}
});

But how do I make a GraphicalEditPart a drop target? I've registered a
TransferDropTargetListener that creates a custom "UpdateRequest", but that
alone doesn't seem to do the trick...

graphicalViewer.addDropTargetListener(new
AbstractTransferDropTargetListener(graphicalViewer,
LocalSelectionTransfer.getTransfer())) {

@Override
protected Request createTargetRequest() {
return new UpdateRequest();
}

@Override
protected void updateTargetRequest() {
Object target = graphicalViewer.findObjectAt(getDropLocation());
((UpdateRequest) getTargetRequest()).setTarget(target);
}
};

It seems I might also have to register a custom "EditPolicy" via
GraphicalEditPart.installEditPolicy, but using what Policy key?
Previous Topic:[Announce] GEF 3.5.0 I200904031502 is available
Next Topic:Problem with polyline connection
Goto Forum:
  


Current Time: Fri Apr 19 18:59:03 GMT 2024

Powered by FUDForum. Page generated in 0.02861 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top