Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[gef-dev] Drag & Drop problem.

Hello.
I'm trying to build custom Editor plugin for Eclipse. I manage get throught doc for GEF and fiew web sites with examples. I tried to set up some simple editor with one element moving on an graphical editor page.(Simple Drag and Drop without any action taken). In doc is an information that I shouldnt Use /AbstractTransferDragSourceListener/ from *org.eclipse.gef.dnd.AbstractTransferDragSourceListener *package and instead of it I should use
the interface from jFace package /TransferDragSourceListener.
/I've created simple class

ElementsDragSourceListener.java
/*
package dnd;

import org.eclipse.jface.util.TransferDragSourceListener;
import org.eclipse.swt.dnd.DragSourceEvent;
import org.eclipse.swt.dnd.Transfer;

public class ElementsDragSourceListener implements TransferDragSourceListener
   {

   public Transfer getTransfer()
       {
       return null;
       }

   public void dragStart(DragSourceEvent event)
       {
       }

   public void dragSetData(DragSourceEvent event)
       {
       event.data = event.getSource().toString();
       }

   public void dragFinished(DragSourceEvent event)
       {
       }

   }
/*/

/and added it to ElementEditPart in createFigure() Method:
protected IFigure createFigure()
       {
       IFigure f = new MenuViewElement();
       getViewer().addDragSourceListener(new ElementsDragSourceListener());
       return f;
       }

When I run project I got my element on page and when I start to drag it I got :
*
Unhandled event loop exception
Reason:
java.lang.NullPointerException

*and element is not Dragging around :(

Can anyone please point me to new GOOD direction???

Greg


Back to the top