0
votes

I need to create drag and drop for my app.

I have a tree in the left part of the window and empty editor area in the right part of the window. I want to drag an element from the tree and drop to the right part. Editor tab should opens after that.

Screenshot

What I have already done: I created the button to open editor of selected tree item and it works. When I drag item and drop it to the existed editor a new editor opens. But I can't to do the same when I don't have any editor (only empty editor area)

Please tell me what should I do or what should I specify like target for drop action. Thanks in advance!

1
imgur.com/IXDs6BH - this is screenshot of my app window - Mykola Muntian
I think it misses a bit of context so you can get an answer. A precise technical point would be welcome. - Moose

1 Answers

1
votes

In your RCP's worbench window advisor class you need to set up the editor area drag/drop transfer types and the drop adapter in the preWindowOpen method.

For example Eclipse itself uses:

public void preWindowOpen() {
    IWorkbenchWindowConfigurer configurer = getWindowConfigurer();

    configurer.addEditorAreaTransfer(EditorInputTransfer.getInstance());
    configurer.addEditorAreaTransfer(ResourceTransfer.getInstance());
    configurer.addEditorAreaTransfer(FileTransfer.getInstance());
    configurer.addEditorAreaTransfer(MarkerTransfer.getInstance());

    configurer.configureEditorAreaDropListener(new EditorAreaDropAdapter(
            configurer.getWindow()));

Note that EditorAreaDropAdapter is an internal class so you can't use it, you will have to write your own drop adapter. This is likely to end up calling IWorbenchPage.openEditor