public void drop(DropTargetDropEvent dtde) {
setHighlight1Cell(null);
try {
// initializations common to all flavors
final Transferable transferable = dtde.getTransferable();
final Point p = dtde.getLocation();
final TreePath path = getPathForLocation(p.x, p.y);
if (path == null) {
dtde.rejectDrop();
return;
}
final GroupTreeNode target = (GroupTreeNode) path
.getLastPathComponent();
// check supported flavors
if (transferable.isDataFlavorSupported(GroupTreeNode.flavor)) {
GroupTreeNode source = (GroupTreeNode) transferable
.getTransferData(GroupTreeNode.flavor);
if (source == target) {
dtde.rejectDrop(); // ignore this
return;
}
if (source.isNodeDescendant(target)) {
dtde.rejectDrop();
return;
}
Enumeration<TreePath> expandedPaths = groupSelector.getExpandedPaths();
UndoableMoveGroup undo = new UndoableMoveGroup(groupSelector,
groupSelector.getGroupTreeRoot(), source, target,
target.getChildCount());
target.add(source);
dtde.getDropTargetContext().dropComplete(true);
// update selection/expansion state
groupSelector.revalidateGroups(new TreePath[] { new TreePath(
source.getPath()) }, refreshPaths(expandedPaths));
groupSelector.concludeMoveGroup(undo, source);
} else if (transferable
.isDataFlavorSupported(TransferableEntrySelection.flavorInternal)) {
final AbstractGroup group = target.getGroup();
if (!group.supportsAdd()) {
// this should never happen, because the same condition
// is checked in dragOver already
dtde.rejectDrop();
return;
}
final TransferableEntrySelection selection = (TransferableEntrySelection) transferable
.getTransferData(TransferableEntrySelection.flavorInternal);
final BibtexEntry[] entries = selection.getSelection();
int assignedEntries = 0;
for (int i = 0; i < entries.length; ++i) {
if (!target.getGroup().contains(entries[i]))