Component docked = port.getDockedComponent();
// if we're not a split port, then there is no concept of 'outer
// regions'.
// jump up a level to find the parent split port
if (!(docked instanceof JSplitPane)) {
DockingPort superPort = DockingManager
.getDockingPort((Component) port);
return findDockable(superPort, self, region, startRegion);
}
Component sibling = port.getComponent(region);
if (sibling == self) {
if (!(self instanceof JSplitPane)) {
DockingPort superPort = DockingManager
.getDockingPort((Component) port);
return findDockable(superPort, self, region, startRegion);
}
return null;
}
if (sibling instanceof JSplitPane) {
// go one level deeper
DockingPort subPort = DockingManager.getDockingPort(sibling);
Component other = port.getComponent(DockingUtility
.flipRegion(region));
String subRegion = findSubRegion((JSplitPane) sibling, other,
region, startRegion);
return findDockable(subPort, self, subRegion, startRegion);
}
// if we have no direct sibling in the specified region, the jump
// up a level.
if (sibling == null) {
DockingPort superPort = DockingManager
.getDockingPort((Component) port);
self = port.getDockedComponent();
return findDockable(superPort, self, region, startRegion);
}