站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc 5.5.1

DragAndDropHandler (NetBeans Palette API) - NetBeans API Javadoc 5.5.1

org.netbeans.spi.palette/1 1.6.10

org.netbeans.spi.palette
Class DragAndDropHandler

java.lang.Object
  extended by org.netbeans.spi.palette.DragAndDropHandler

public abstract class DragAndDropHandler
extends Object

An abstract class implemented by palette clients to implement drag and drop of new items into the palette window and to customize the default Transferable instance of items being dragged from the palette window to editor area.

Client's can support multiple DataFlavors that may help to enable/disable the drop when dragging an item over different editor area parts that allow only certain item types to be dropped into them.


Constructor Summary
DragAndDropHandler()
           
 
Method Summary
 boolean canDrop(Lookup targetCategory, DataFlavor[] flavors, int dndAction)
           
 boolean canReorderCategories(Lookup paletteRoot)
           
abstract  void customize(ExTransferable t, Lookup item)
          Add your own custom DataFlavor as need to suppor drag-over a different parts of editor area.
 boolean doDrop(Lookup targetCategory, Transferable item, int dndAction, int dropIndex)
          Perform the drop operation and add the dragged item into the given category.
 boolean moveCategory(Lookup category, int moveToIndex)
          Move the given category to a new position.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DragAndDropHandler

public DragAndDropHandler()
Method Detail

customize

public abstract void customize(ExTransferable t,
                               Lookup item)
Add your own custom DataFlavor as need to suppor drag-over a different parts of editor area.

Parameters:
t - Item's default Transferable.
item - Palette item's Lookup.

canDrop

public boolean canDrop(Lookup targetCategory,
                       DataFlavor[] flavors,
                       int dndAction)
Parameters:
targetCategory - Lookup of the category under the drop cursor.
flavors - Supported DataFlavors.
dndAction - Drop action type.
Returns:
True if the given category can accept the item being dragged.

doDrop

public boolean doDrop(Lookup targetCategory,
                      Transferable item,
                      int dndAction,
                      int dropIndex)
Perform the drop operation and add the dragged item into the given category.

Parameters:
targetCategory - Lookup of the category that accepts the drop.
item - Transferable holding the item being dragged.
dndAction - Drag'n'drop action type.
dropIndex - Zero-based position where the dragged item should be dropped.
Returns:
True if the drop has been successful, false otherwise.

canReorderCategories

public boolean canReorderCategories(Lookup paletteRoot)
Parameters:
paletteRoot - Lookup of palette's root node.
Returns:
True if it is possible to reorder categories by drag and drop operations.

moveCategory

public boolean moveCategory(Lookup category,
                            int moveToIndex)
Move the given category to a new position.

Parameters:
category - The lookup of category that is being dragged.
moveToIndex - Zero-based index to palette's root children Nodes where the category should move to.
Returns:
True if the move operation was successful.

org.netbeans.spi.palette/1 1.6.10

Built on March 26 2007.  |  Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.