poojagowda
poojagowda

Reputation: 15

initializing multiple drop support for the same view

How to use two different drop support in one view itself with different transfer types?

    int srcOps = DND.DROP_MOVE | DND.DROP_COPY;
    Transfer[] dragDropTransfers = new Transfer[] { myTransferType1.getInstance() };
    this.getTreeViewer().addDragSupport(srcOps, dragDropTransfers, new OverviewDragSourceAdapter(this));
    this.getTreeViewer().addDropSupport(srcOps, dragDropTransfers, new OverviewDropAdapter(this));
    dragDropTransfers = new Transfer[] { myTransferType2.getInstance() };
    this.getTreeViewer().addDropSupport(srcOps, dragDropTransfers, new AddDropAdapter(this));

It gives org.eclipse.swt.SWTError: Cannot initialize Drop.

Upvotes: 0

Views: 252

Answers (1)

greg-449
greg-449

Reputation: 111142

Internally addDropSupport uses DropTarget. The JavaDoc for DropTarget says:

ERROR_CANNOT_INIT_DROP - unable to initiate drop target; this will occur if more than one drop target is created for a control or if the operating system will not allow the creation of the drop target

So you cannot use multiple calls to addDropSupport. You will have to write a single DropTargetListener

Upvotes: 1

Related Questions