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.
Modifier | Constructor and Description |
---|---|
|
DragAndDropHandler() |
protected |
DragAndDropHandler(boolean textDnDEnabled)
Subclass this class and use this c'tor with
true parameter to support text drag and drop
into the palette to create new custom code clips. |
Modifier and Type | Method and Description |
---|---|
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.
|
public DragAndDropHandler()
protected DragAndDropHandler(boolean textDnDEnabled)
true
parameter to support text drag and drop
into the palette to create new custom code clips. Subclassed instance must be then provided
to PaletteFactory
when creating PaletteController
.textDnDEnabled
- True to allow text to be dropped into the palette window.public abstract void customize(ExTransferable t, Lookup item)
t
- Item's default Transferable.item
- Palette item's Lookup.public boolean canDrop(Lookup targetCategory, DataFlavor[] flavors, int dndAction)
targetCategory
- Lookup of the category under the drop cursor.flavors
- Supported DataFlavors.dndAction
- Drop action type.public boolean doDrop(Lookup targetCategory, Transferable item, int dndAction, int dropIndex)
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.public boolean canReorderCategories(Lookup paletteRoot)
paletteRoot
- Lookup of palette's root node.public boolean moveCategory(Lookup category, int moveToIndex)
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.