Kuldeep Singh
Kuldeep Singh

Reputation: 208

DragSourceListener never called while dragging and dropping file inside eclipse project explorer

I am working on eclipse plugin that will allow a java bean to be dragged onto jsp file then on the drop event some code generators will be called.

I'm attempting to use the extension point "org.eclipse.ui.dropActions" but drag and drop listeners never get called .Is there any way to attach drag and drop listener to IFile object.

Am I on the right track with the DropActionDelegate?

Code:

DragListener

class DragListener implements DragSourceListener {

  @Override
  public void dragFinished(DragSourceEvent event) {     
    System.out.println("Finish");
  }

  @Override
  public void dragSetData(DragSourceEvent event) {  
    PluginTransferData p;

    p = new PluginTransferData  (
      "dream_action", // must be id of registered drop action
      "some_data".getBytes() // may be of arbitrary type
    );
    event.data = p;
  }

  @Override
  public void dragStart(DragSourceEvent event) {
    // TODO Auto-generated method stub
    System.out.println("Start");    
  }
} 

DropActionDelegate

class DropActionDelegate implements IDropActionDelegate {   
  @Override
  public boolean run(Object source, Object target) {
    String Data= (String) target; 
    return true; 
  }
}

Plugin.xml

<extension point="org.eclipse.ui.dropActions"> 
  <action 
    id="dream_action" 
    class="newdreamfileplugin.wizards.DropActionDelegate"> 
  </action> 
</extension>

Thanks.

Upvotes: 4

Views: 513

Answers (1)

Kuldeep Singh
Kuldeep Singh

Reputation: 208

Solved it.Finally i created my own navigator using org.eclipse.ui.navigator.navigatorContent extension which have a property dropAssistant.

Upvotes: 2

Related Questions