Class DragAdapterAssistant


public class DragAdapterAssistant extends ResourceDragAdapterAssistant
Assist the CommonDragAdapter by providing new TransferTypes and the logic to handle setting up the transfer data. Clients must extend this class as part of the org.eclipse.ui.navigator.viewer/dragAssistant extension. By default, the Common Navigator supports LocalSelectionTransfer and PluginTransfer.
Author:
Christopher Mindus
  • Constructor Details

    • DragAdapterAssistant

      public DragAdapterAssistant()
      The Eclipse constructor.
  • Method Details

    • getSupportedTransferTypes

      public Transfer[] getSupportedTransferTypes()
      Extra TransferTypes allow the Navigator to generate different kinds of payloads for DND clients. By default, the CommonDragAdapter supports LocalSelectionTransfer and PluginTransfer.

      CommonDragAdapterAssistants can extend the available TransferTypes that a Common Navigator Viewer can generate. Clients should return the set of Transfer Types they support. When a drop event occurs, the available drag assistants will be searched for a enabled assistants for the DragSourceEvent. Only if the drop event occurs will setDragData(DragSourceEvent, IStructuredSelection)} be called. If the drop event is cancelled, setDragData(DragSourceEvent, IStructuredSelection)} will not be called.

      Overrides:
      getSupportedTransferTypes in class ResourceDragAdapterAssistant
      Returns:
      The added transfer types: PropertiesTransfer.
    • dragStart

      public void dragStart(DragSourceEvent event, IStructuredSelection selection)
      Allows the drag assistant indicate it wants to participate in the drag operation. This is called at DragSourceListener.dragStart(DragSourceEvent) time.
      Overrides:
      dragStart in class CommonDragAdapterAssistant
      Parameters:
      event - The event object should return doit=true if it wants to participate in the drag and set doit=false if it does not want to further participate.
      selection - The current selection from the viewer.
    • setDragData

      public boolean setDragData(DragSourceEvent event, IStructuredSelection selection)
      Set the value of the org.eclipse.swt.widgets.Event.data field using the given selection. Clients will only have an opportunity to set the drag data if they have returned a matching Transfer Type from getSupportedTransferTypes() for the DragSourceEvent#dataType.

      Clients will only have an opportunity to set the data when the drop event occurs. If the drop operation is cancelled, then this method will not be called.

      Overrides:
      setDragData in class ResourceDragAdapterAssistant
      Parameters:
      event - The event object should have its Event.data field set to a value that matches a supported TransferData type.
      selection - The current selection from the viewer.
      Returns:
      True if the data could be set; false otherwise.
    • dragFinished

      public void dragFinished(DragSourceEvent event, IStructuredSelection selection)
      Allows the drag assistant to do any necessary cleanup after the drop operation is done. This is called at DragSourceListener.dragFinished(DragSourceEvent) time. This is called on the same assistant that was called for the set data.
      Overrides:
      dragFinished in class CommonDragAdapterAssistant
      Parameters:
      event - The event object should have its Event.data field set to a value that matches a supported TransferData type.
      selection - The current selection from the viewer.