switch (constraint.getOnIndex()) {
case -2:
for (Window window : SwingUtil.getTopContainers()) {
if (window instanceof ContentWindow) {
ContentWindow contentWindow = (ContentWindow) window;
if (contentWindow.containsDockable(constraint.getOnContent())) {
// remove content
removeContent(content);
contentWindow.addDockable(content,
content.getComponent(),
null,
constraint.getOnPosition());
break;
}
}
}
break;
default:
for (Window window : SwingUtil.getTopContainers()) {
if (window instanceof ContentWindow) {
ContentWindow contentWindow = (ContentWindow) window;
if (contentWindow.containsDockable(constraint.getOnContent())) {
// remove content
removeContent(content);
contentWindow.addDockable(content,
content.getComponent(),
constraint.getOnContent(),
constraint.getOnPosition());
break;
}
}
}
}
} else {
ContentUI contentUI = getContentUI(content);
Rectangle inBounds = toolWindowManager.getBoundsToScreen(content.getComponent().getBounds(),
content.getComponent().getParent());
// remove content
removeContent(content);
// Setup dialog
Frame parentFrame = (toolWindowManager.getWindowAncestor() instanceof Frame) ? (Frame) toolWindowManager.getWindowAncestor() : null;
Window dialog;
if (contentUI.isAddToTaskBarWhenDetached()) {
dialog = new ContentFrame(
content, contentUI,
parentFrame, inBounds);
} else {
dialog = new ContentDialog(
content, contentUI,
parentFrame, inBounds);
}
dialog.addWindowFocusListener(new ContentDialogFocusListener(content));
dialog.toFront();
dialog.setVisible(true);
componentInFocusRequest = findAndRequestFocus(dialog);
}
} finally {
valueAdjusting = false;
}
} else {
ContentWindow window = (ContentWindow) SwingUtilities.windowForComponent(content.getComponent());
window.removeDockable(content);
if (window.getDockableCount() <= 0) {
window.setVisible(false);
window.dispose();
}
contentValueAdjusting = true;
try {
int index = 0;