if (targetDesktop == null) { //2006/09/11
// deny drag gesture when desktops aren't compatible
if (underMouseNullDesktop != null) { // we've found a dock drop receiver
// we send a really simple event
DockDragEvent event = new DockDragEvent(desktop, dragSource, e);
((DockDropReceiver) underMouseNullDesktop).processDockableDrag(event);
}
// finished
shapePainterStrategy.showStopDragCursor();
setDropShape(null, shapePainterStrategy);
return;
} else if (targetDesktop.getContext() != desktop.getContext()) { //2006/09/11
// deny drag gesture when desktops aren't compatible
shapePainterStrategy.showStopDragCursor();
setDropShape(null, shapePainterStrategy);
return;
}
int dx = dragPoint.x - startDragPoint.x;
int dy = dragPoint.y - startDragPoint.y;
if (Math.abs(dx) < 20 && Math.abs(dy) < 10) {
// deny drag gesture when too near from start point 2005/11/15
shapePainterStrategy.showStopDragCursor();
setDropShape(null, shapePainterStrategy);
return;
}
// 2005/11/08 support for full height/width docking
DockingPanel dp = targetDesktop.getDockingPanel();
Insets i = targetDesktop.getDockingPanelInsets();
Rectangle deskBounds = new Rectangle(i.left, i.top,
targetDesktop.getWidth() - i.left - i.right, targetDesktop.getHeight() - i.top - i.bottom);
Rectangle innerBounds = new Rectangle(deskBounds);
innerBounds.x += 5;
innerBounds.y += 5;
innerBounds.width -= 10;
innerBounds.height -= 10;
if (deskBounds.contains(dragPoint) && !innerBounds.contains(dragPoint) && underMouse != null && targetDesktop.isAncestorOf(underMouse)) {
// at less than 5 pixels from a border, promote DockingPanel as the receiver
underMouse = dp;
}
// go up the hierarchy until we find a component that can receive a drop
while (underMouse != null && underMouse != targetDesktop &&
!(underMouse instanceof DockDropReceiver)) {
underMouse = underMouse.getParent();
}
umInfo.underMouse = underMouse; // resync
if (underMouse == null) {// || isAncestorOf(dockableDragSource.getDockableContainer(), underMouse)){
// it's not possible to drop a parent on one of its children
// so we're goind to try and detach it
if (underMouse instanceof DockDropReceiver) {
// but we still have to use the reference on drop receiver to display a floating drag shape
this.dropReceiver = (DockDropReceiver) underMouse;
}
DragProcess process = new DragProcess(dockableDragSource, umInfo);
if (process.canDockableBeDetached() && process.checkAndDetachDockable(shapePainterStrategy)) {
// this method manages the detachement
} else {
// refused (vetoed)
shapePainterStrategy.showStopDragCursor();
setDropShape(null, shapePainterStrategy);
}
} else if (underMouse instanceof DockDropReceiver && e.isControlDown()) { //2005/11/08 HOT SWAP FUNCTION
processHotSwap(underMouse, dragged, shapePainterStrategy, false);
} else if (underMouse instanceof DockDropReceiver) {
// loop if it returns null
DragProcess process = new DragProcess(dockableDragSource, umInfo);
DockDragEvent event = process.findAcceptableEvent(e);
// will it cause a state change ?
// a state change occur when switching between CLOSED, HIDDEN, and DOCKED
// in this context, the drag event can only be generated by a hidden dockable
// (if there is a way to drag its button) or an already docked dockable (no state change)
if (event.isDragAccepted() && process.isDockingActionAccepted()) {
shapePainterStrategy.showDragCursor();
setDropShape(event.getDropShape(), shapePainterStrategy);
} else if (process.canDockableBeDetached() && process.checkAndDetachDockable(shapePainterStrategy)) {
// detach done by the "if"
} else {
event.rejectDrag(); // vetoed by listeners
shapePainterStrategy.showStopDragCursor();
setDropShape(null, shapePainterStrategy);
}
} else {// not above a drop receiver, might be detachable
DragProcess process = new DragProcess(dockableDragSource, umInfo);