org.salespointframework.desktop.dnd
Interface DnDComponent

All Known Implementing Classes:
JAbstractTable, JCatalogListView, JCatalogTable, JCountingStockListView, JCountingStockTable, JDataBasketListView, JDataBasketTable, JListView, JLogTable, JModelFilter.JDroppableInstructionField, JStoringStockListView, JStoringStockTable, JUserListView, JUserTable

public interface DnDComponent

To use drag'n drop on FormSheet the component has to implement this interface and needs to register itself via FormSheet.registerDnDComponent(DnDComponent)

Since:
4.0
Author:
Thomas Kissinger

Method Summary
 boolean acceptDropPartner(java.awt.Component c)
          true, if the component accepts this component a drop target.
 boolean allowDrag(java.awt.Point point)
          if true, drag is allowed at this point
 boolean allowDrop(java.lang.Object item, int count)
          if true, drop is allowed for this component
 void finishDragOperation(java.lang.Object item, int count, java.awt.Component receiver)
          finish the drag'n drop operation
 java.awt.Component getBoundingComponent()
          get component which defines the range of this component. e.g. a JScrollPane
 DnDMotionComponent getDnDMotionComponent(java.lang.Object item, int count)
          get the component which is displayed during drag'n drop operation on FormSheet.getDragLayer()
 java.lang.Object getDragItem(java.awt.Point point)
          get the item at this point, what will be transfered.
 int getDragItemIndex(java.awt.Point point)
          index of item at this point.
 java.awt.Component getDragSourceComponent()
          Component which contains the drag items
 boolean getMoreDragItems(java.awt.Point point, java.lang.Object item, int count, int additionalCount)
          user requests more items.
 void paintHightlightEffect(java.awt.Graphics2D g, java.awt.Rectangle bounds, java.awt.Component cmp)
          paint drag'n drop highlight effect. drawing takes place on some layer above the standard layer, so the effect can be drawn beyond components bounds
 void startDragOperation(java.awt.Point p)
          start a drag operation at this point.
 void takeDragItem(java.lang.Object item, int count)
          component should take the transferred item with given count
 

Method Detail

allowDrop

boolean allowDrop(java.lang.Object item,
                  int count)
if true, drop is allowed for this component

Parameters:
item - item that requests to be dropped
count - number of this items
Returns:
true, if drop allowed

allowDrag

boolean allowDrag(java.awt.Point point)
if true, drag is allowed at this point

Parameters:
point - mouse point in this components coordinate system
Returns:
true, if drag allowed

startDragOperation

void startDragOperation(java.awt.Point p)
start a drag operation at this point. allowDrag(Point) is called before and returned true

Parameters:
p - mouse point in this components coordinate system

finishDragOperation

void finishDragOperation(java.lang.Object item,
                         int count,
                         java.awt.Component receiver)
finish the drag'n drop operation

Parameters:
item - item that has been dragged
count - number of this items
receiver - component which will receive this items

getDragItem

java.lang.Object getDragItem(java.awt.Point point)
get the item at this point, what will be transfered.

Parameters:
point - mouse point in this components coordinate system
Returns:
the transfer object

getDragItemIndex

int getDragItemIndex(java.awt.Point point)
index of item at this point.

Parameters:
point - mouse point in this components coordinate system
Returns:
index or -1

getMoreDragItems

boolean getMoreDragItems(java.awt.Point point,
                         java.lang.Object item,
                         int count,
                         int additionalCount)
user requests more items.

Parameters:
point - mouse point in this components coordinate system
item - currently transferred item
count - current number of items
additionalCount - requested number of items
Returns:
true, if allowed

acceptDropPartner

boolean acceptDropPartner(java.awt.Component c)
true, if the component accepts this component a drop target.

Parameters:
c - component
Returns:
true, if allowed

getDnDMotionComponent

DnDMotionComponent getDnDMotionComponent(java.lang.Object item,
                                         int count)
get the component which is displayed during drag'n drop operation on FormSheet.getDragLayer()

Parameters:
item - item that is transferred
count - number of transferred items
Returns:

takeDragItem

void takeDragItem(java.lang.Object item,
                  int count)
component should take the transferred item with given count

Parameters:
item - transferred item
count - transferred item count

getBoundingComponent

java.awt.Component getBoundingComponent()
get component which defines the range of this component. e.g. a JScrollPane

Returns:

getDragSourceComponent

java.awt.Component getDragSourceComponent()
Component which contains the drag items

Returns:

paintHightlightEffect

void paintHightlightEffect(java.awt.Graphics2D g,
                           java.awt.Rectangle bounds,
                           java.awt.Component cmp)
paint drag'n drop highlight effect. drawing takes place on some layer above the standard layer, so the effect can be drawn beyond components bounds

Parameters:
g - Graphics context which is NOT in components coordinate system
bounds - bounds of highlight component
cmp - highlight component