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 8747645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:23:27+00:00 2026-06-13T12:23:27+00:00

In my Eclipse RCP application I have a TreeViewer that is a drop target

  • 0

In my Eclipse RCP application I have a TreeViewer that is a drop target for files, it works fine in most circumstances, however when I try and drag files stored on a CD ROM from windows explorer to the node the icon that indicates drops are allowed doesn’t change and dropping does nothing.

Since people seemed confused about my question here’s a more detailed explanation:

When executing the code below (supplied by Baz), I am able to drag files and drop them on to the text box, when I drag a file from most locations on my machine, the window appears like this ->

Working Drag

The cursor indicates that I can drop, and when I release the mouse the drop(DropTargetEvent event) method is invoked.

Now when I do the same thing, but take a file from explorer that is on a DVD in my optical drive then it looks like this:

enter image description here

Indicating that the drop is not allowed, and when I release the mouse the drop(DropTargetEvent event) method is NOT invoked.

It’s also worth noting that I am able to drop the same DVD files in to a folder in the eclipse navigator, indicating that this isn’t a machine specific issue, there must be something different in the eclipse trees that allows it but I can’t see it.

package widgets;

import java.util.Arrays;

import org.eclipse.swt.SWT;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DropTarget;
import org.eclipse.swt.dnd.DropTargetAdapter;
import org.eclipse.swt.dnd.DropTargetEvent;
import org.eclipse.swt.dnd.FileTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.part.PluginTransfer;

public class SourceTest {
    public static void main(String[] args) {
        final Display display = new Display();
        Shell shell = new Shell(display);
        shell.setLayout(new GridLayout(1,false));

        final Text text = new Text(shell, SWT.BORDER);
        text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));

        DropTarget dt = new DropTarget(text, DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK);
        dt.setTransfer(new Transfer[] { FileTransfer.getInstance(), PluginTransfer.getInstance() });
        dt.addDropListener(new DropTargetAdapter() {
            public void drop(DropTargetEvent event) {
                String fileList[] = null;
                FileTransfer ft = FileTransfer.getInstance();
                if (ft.isSupportedType(event.currentDataType)) {
                    fileList = (String[]) event.data;
                }
                System.out.println(Arrays.toString(fileList));
            }
        });

        shell.setSize(300, 100);
        shell.open();

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

}
  • 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-06-13T12:23:28+00:00Added an answer on June 13, 2026 at 12:23 pm

    It appears that not all of the DND operations possible are supported when coming from a CDROM device. Therefore you need to implement a couple of more methods on the DropTargetAdapter in order to modify the Drop operation while in progress to narrow down the operations that will actually be performed so that the OS doesn’t prevent the drop.

    I took your example and just made the small change to the DropTargetAdapter

        @Override
        public void dropAccept( DropTargetEvent event )
        {
            Object object = FileTransfer.getInstance().nativeToJava( event.currentDataType );
            if( object instanceof String[] )
            {
                String[] strs = (String[]) object;
                System.out.println("dropAccept " + strs[0]);
                event.detail = DND.DROP_COPY;
            }
            event.detail = DND.DROP_COPY;
        }
        @Override
        public void dragEnter( DropTargetEvent event )
        {
            event.detail = DND.DROP_COPY;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an eclipse rcp application. This application will try to load class files
I have an Eclipse RCP application that will launch properly after a clean install
I have an Eclipse RCP application that I'd like to make available to end
I'm developing an Eclipse RCP application. I have been told that the UI part
I have an rcp eclipse application and from that application, using a context menu
I have a plug-in to an Eclipse RCP application that has a view. After
I am working on an Eclipse RCP-based application, and we have decided that we
I have an eclipse RCP application that uses and Editor Area. I have a
i have an eclipse rcp application that, from time to time, may have multiple
I have an Eclipse RCP based Application, in which I have a menu of

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.