Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3856142
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:53:04+00:00 2026-05-19T17:53:04+00:00

After long investigations and reading this question I still didn’t get a good solution

  • 0

After long investigations and reading this question I still didn’t get a “good” solution for my problem.

I have a Gef editor and I want to let the users drag and drop figures (== model objects) form this editor to an other custom view available in my perspective.

Adding a DragSource with my own drag transfer on my GEF editor figure canvas allows that. But as a side effect, and I don’t want this side effect, this disable the possibility to move the figures INSIDE the editor using drag and drop.

After investigations I found this post on eclipse forums, but the solution is not acceptable for me. Thus I investigated deeper and came to the following pure SWT snippet that shows that MouseMove events (the ones used by gef to support dragging INSIDE the editor) are no more fired once a drag source has been added:

import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DragSource;
import org.eclipse.swt.dnd.DragSourceEvent;
import org.eclipse.swt.dnd.DragSourceListener;
import org.eclipse.swt.dnd.FileTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.MouseMoveListener;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

    public class SwtTest {
        public static void main(String[] args) {
            final Display display = new Display();
            final Shell shell = new Shell(display);
            shell.addMouseListener(new MouseListener() {
                public void mouseUp(MouseEvent e) {
                    System.out.println("mouseUp");
                }

                public void mouseDown(MouseEvent e) {
                    System.out.println("mouseDown");
                }

                public void mouseDoubleClick(MouseEvent e) {
                    System.out.println("mouseDoubleClick");
                }
            });
            shell.addMouseMoveListener(new MouseMoveListener() {

                @Override
                public void mouseMove(MouseEvent e) {
                    System.out.println("Mouse move");
                }
            });
            DragSourceListener dragListener = new DragSourceListener() {

                public void dragFinished(DragSourceEvent event) {
                    System.out.println("dragFinished");

                }

                public void dragSetData(DragSourceEvent event) {
                    System.out.println("dragSetData");

                }

                public void dragStart(DragSourceEvent event) {
                    System.out.println("dragStart");
                }
            };

            DragSource dragSource = new DragSource(shell, DND.DROP_COPY | DND.DROP_MOVE);
            dragSource.addDragListener(dragListener);
            dragSource.setTransfer(new Transfer[] { FileTransfer.getInstance() });

            shell.pack();
            shell.open();
            while (!shell.isDisposed()) {
                if (!display.readAndDispatch())
                    display.sleep();
            }
            display.dispose();
        }
    }

I guess this is the normal behavior fro man SWT point of view. Do you confirm ?

Moreover, I am really looking for a solution to this issue other that the one proposed on Eclipse forum consisting in activating my DragSource only if a given condition is met such as Shift is pressed (this is done in a DragSourceListener.dragStart method by setting event.doit to false)

Any help, suggestions and comments are welcome.

Thanks in advance,

Manu

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T17:53:05+00:00Added an answer on May 19, 2026 at 5:53 pm

    Most likely you want to extend normal GEF drag and drop to contain also Image drag support.

    When you drag items inside GEF editor you can drag them as Figures (actually it is bit more complex, it is using Request-Command pattern). But when your drag goes over the editor borders you need to be able to provide ie. Image out of this data.

    SWT Provides support for multiple different Drag Data Transfers like this:

    dragSource.setTransfer(new Transfer[] { FileTransfer.getInstance(), ImageTransfer.getInstance() });
    

    So I believe that you want to find a way in GEF DragTracker to also include this ImageTransfer to the OS Drag. DragTrackers are GEF way of handling drag, and are returned in EditPart’s function getDragTracker()

    I am not totally sure how that can be done, but extending own DragTracker that is also able to provide also OS level Image should do the trick.

    Case is quite similar to copy pasting, and in basic GMF editor it is possible to copy paste items as images outside the editor to any tool that is accepting images.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might not be a programming question but I am posting it after long
I have a very tricky problem and after long searching (google, stackoverflow, ...) i
After a long exhausting search, I have found no answer to my question anywhere.
After doing a long search on stackoverflow i didn't find any one talked about
After looking around (for not terribly long I have to admit) I wonder if
After long search with no luck, finally I have decided to ask here. I
I received this message after long time of using the same application without programming
After long time of searching I have to give up and ask. Is it
After the long-winded discussion at Write this Scala Matrix multiplication in Haskell , I
After a long long while I had to do some frontend, and I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.