Drag & Drop [message #152565] |
Fri, 28 September 2007 11:40  |
Eclipse User |
|
|
|
Hi,
I am implementing drag&drop in my generated diagram. The steps I perform are
the following:
1. I override initializeGraphicalViewer() in my editor like this:
protected void initializeGraphicalViewer() {
super.initializeGraphicalViewer();
getDiagramGraphicalViewer().addDropTargetListener(new
DiagramDropTargetListener(getGraphicalViewer()) {
...
});
2. In my XxxEditPart (where I wish to be able to perform the drop), I added
additional EditPolicy like this:
protected void createDefaultEditPolicies() {
...
installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy()
{
@Override
protected Command getDropObjectsCommand(DropObjectsRequest request) {
Command command = super.getDropObjectsCommand(request);
if (command == null) {
return new Command() {...};
}
return command;
}
});
Is this correct, am I missing something?
The DropTargetListener from point 1 is not called at all. The Command from
point 2 is executed, but there is some very strange diagram behavior - when
I drag something over the diagram, the whole diagram (and the outline) gets
grayed... something like "select all", if there were such thing. I do not
perform any custom rendering or so... so i guess something with the
drag&drop implementation is not correct.
Could you help me with this matter?
|
|
|
Re: Drag & Drop [message #152732 is a reply to message #152565] |
Mon, 01 October 2007 08:46  |
Eclipse User |
|
|
|
Ok, I have some insights, gained through debugging:
1. When dragging, the DiagramDropTargetListener's getObjectsBeingDropped()
method is called and I retrun a list containing EObjects, as described in
http://wiki.eclipse.org/index.php/GMF_Archived_Newsgroup_Q&a mp;A#How_can_I_implement_drag-n-drop_in_my_diagram.3F
2. When dragging, I noticed, that the mouse pointer is constantly a sign,
not allowing a drop -> during the debugging in the
DiagramDropTargetListener's isEnabled method, I finally ended up in a method
in DragDropEditPolicy with the following implementation:
protected Command getDropElementCommand(EObject element, DropObjectsRequest
request) {
return null;
}
The EObject is correct and the request is ok...
In the Q&A stands, that when returning EObjects, there is no need of
extending the DragDropEditPolicy class, but this approach seems not to work?
Am I missing something here?
Is there some other mechanism allowing D&D implementation?
|
|
|
Powered by
FUDForum. Page generated in 0.09354 seconds