Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Drag and drop from View to GEF Editor
Drag and drop from View to GEF Editor [message #1243616] Tue, 11 February 2014 07:53
Markus Z is currently offline Markus ZFriend
Messages: 1
Registered: February 2014
Junior Member

I have a simple View with a TreeViewer representing POJOs. I need to drag the TreeItems from the view and drop them to a GEF editor (inside a multipage editor).

When I drag the item from the viewer to the editor area, the create request, handle drag and update request methods are called in the listener. but when I drop the item handleDrop/drop is NOT called.

what am i missing?

My View contains:
Transfer[] types = new Transfer[]{TextTransfer.getInstance()};
treeViewer.addDragSupport(DND.DROP_MOVE, types, new InstructionDragListener(treeViewer));

The DragListener looks like:
public class InstructionDragListener implements DragSourceListener {

    private Viewer viewer;

    public InstructionDragListener(Viewer viewer) {
        this.viewer = viewer;

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

    public void dragSetData(DragSourceEvent event) {
        IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
        Instruction ins=null;

        if (selection.getFirstElement() instanceof Instruction)
            ins = (Instruction) selection.getFirstElement(); ins.getID();

    public void dragFinished(DragSourceEvent event) {

The Editor is part of a MultiPageEditor and looks like:
public class MyGraphicalEditor extends GraphicalEditorWithFlyoutPalette {

    public static String ID = "MyEditorID";

    public MyGraphicalEditor() {
        setEditDomain(new DefaultEditDomain(this));

    protected void initializeGraphicalViewer() {

    protected void configureGraphicalViewer() {
        getGraphicalViewer().setEditPartFactory(new TestCaseEditPartFactory());

        getGraphicalViewer().addDropTargetListener(new MyTransferTargetDropListener(getGraphicalViewer()));

and the DropListener looks like:
public class MyTransferTargetDropLsitener extends AbstractTransferDropTargetListener {

    private MyTransferTagetDropFactory factory = new MyTransferTagetDropFactory();

    public MyTransferTargetDropLsitener(EditPartViewer viewer, Transfer xfer) {
        super(viewer, xfer);

    protected Request createTargetRequest() {
        System.out.println("CREATE REQUEST");
        CreateRequest request = new CreateRequest();
        return request;
    protected void handleDragOver() {
        System.out.println("HANDLE DRAG");

    protected void updateTargetRequest() {
        System.out.println("UPDATE REQUEST");

    protected void handleDrop() {
        System.out.println("DROP HANDLED");


    public void drop(DropTargetEvent event) {

thanks! Smile
Previous Topic:Problem With Draw2d Examples
Next Topic:error 404 for downloading Graphical Editing Framework (GEF)
Goto Forum:

Current Time: Sun Jun 24 00:02:10 GMT 2018

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

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

Back to the top