Adding Native Drag Support to Editor [message #549824] |
Wed, 28 July 2010 07:07  |
Eclipse User |
|
|
|
Hi everyone,
when using the code below, the edit parts cannot be moved around inside the editor anymore. I am not using any 'DRAG_DROP_ROLE' edit policy. From what I've learned so far, the drag and drop is required to drag an edit part into a different control.
How do I enable dragging (to other controls) and moving (inside the editor) at the same time?
Best regards,
Erich
private void enableDrag() {
class EditPartDragSourceListener implements TransferDragSourceListener {
@Override
public void dragStart(DragSourceEvent event) {
}
// Dragging the ID of the model element is fine.
@Override
public void dragSetData(DragSourceEvent event) {
EditPart ep = getSelectedEditPart();
if (ep != null) {
ModelElement me = getModelElement(ep);
final String transferData = getIdFromModelElement(me);
event.data = transferData;
}
}
@Override
public void dragFinished(DragSourceEvent event) {
}
@Override
public Transfer getTransfer() {
return TextTransfer.getInstance();
}
}
DragSource source = new DragSource(getDiagramGraphicalViewer().getControl(), DND.DROP_MOVE | DND.DROP_COPY);
source.setTransfer(new Transfer[] { TextTransfer.getInstance() });
getDiagramGraphicalViewer().addDragSourceListener(new EditPartDragSourceListener());
}
|
|
|
Re: Adding Native Drag Support to Editor [message #551314 is a reply to message #549824] |
Thu, 05 August 2010 21:41  |
Eclipse User |
|
|
|
As it turned out, when i want to drag from the editor to another view, i have to add the drag listener directly to the graphical viewer this way:
getDiagramGraphicalViewer().addDragSourceListener(new TransferDragSourceListener() {...});
After doing that, it's not possible to move around nodes unless i implement a drop listener.
Best regards
Erich
|
|
|
Powered by
FUDForum. Page generated in 0.03126 seconds