[toolwindow] IJPL-59194 Add registry property to control when tabs reordering in any tool window is enabled

To be able to easily disable the feature in case of big issues.

GitOrigin-RevId: e4e6bac0c04ceaa84e307084d214bdfa553fb519
This commit is contained in:
Konstantin Hudyakov
2025-10-14 20:21:34 +00:00
committed by intellij-monorepo-bot
parent 0413b1b442
commit cd10dad029
2 changed files with 10 additions and 3 deletions
@@ -55,6 +55,7 @@ internal class ToolWindowInnerDragHelper(parent: Disposable, val pane: JComponen
val decorator = InternalDecoratorImpl.findTopLevelDecorator(child)
val editorSupport = getEditorSupport(decorator)
if (decorator != null &&
(canReorderTabs() || decorator.toolWindow.canSplitTabs()) &&
child is ContentTabLabel &&
(child.parent is ToolWindowContentUi.TabPanel ||
Registry.`is`("debugger.new.tool.window.layout.dnd", false) && child.parent is SingleContentLayout.TabAdapter) &&
@@ -74,7 +75,7 @@ internal class ToolWindowInnerDragHelper(parent: Disposable, val pane: JComponen
return when (curLocation) {
is DropLocation.ToolWindow -> {
val component = curLocation.decorator
val canDrop = currentDropIndex != -1 || curLocation.decorator.toolWindow.canSplitTabs()
val canDrop = currentDropIndex != -1 && canReorderTabs() || curLocation.decorator.toolWindow.canSplitTabs()
component.contains(point.getPoint(component)) && canDrop
}
is DropLocation.Editor -> {
@@ -374,7 +375,7 @@ internal class ToolWindowInnerDragHelper(parent: Disposable, val pane: JComponen
val content = myDraggingTab?.content
curDropLocation = when {
decorator != null && decorator == sourceDecorator -> {
decorator != null && decorator == sourceDecorator && canReorderTabs() -> {
// Drop into the same tool window decorator - always allowed.
DropLocation.ToolWindow(decorator)
}
@@ -407,7 +408,7 @@ internal class ToolWindowInnerDragHelper(parent: Disposable, val pane: JComponen
private fun highlightToolWindowDropArea(decorator: InternalDecoratorImpl, point: RelativePoint) {
currentDropIndex = getTabIndex(point)
if (currentDropIndex != -1) {
if (currentDropIndex != -1 && (canReorderTabs() || decorator.toolWindow.canSplitTabs())) {
decorator.setDropInfoIndex(currentDropIndex, dragImageView!!.size.width)
currentDropSide = -1
highlighter.bounds = Rectangle()
@@ -451,6 +452,10 @@ internal class ToolWindowInnerDragHelper(parent: Disposable, val pane: JComponen
else null
}
private fun canReorderTabs(): Boolean {
return Registry.`is`("ide.allow.tool.window.tabs.reorder", false)
}
private sealed interface DropLocation {
data class ToolWindow(val decorator: InternalDecoratorImpl) : DropLocation
data class Editor(val window: EditorWindow) : DropLocation
@@ -129,6 +129,8 @@ ide.new.tool.window.start.drag.deadzone=100
ide.new.tool.window.start.drag.deadzone.description=Minimal distance from pressed point to start drag (and thus to avoid mistaken one)
ide.switcher.tool.window.list=true
ide.switcher.tool.window.list.description=Shows a list of tool windows in the Switcher popup
ide.allow.tool.window.tabs.reorder=true
ide.allow.tool.window.tabs.reorder.description=Whether reordering tool window tabs using drag and drop is allowed
ide.tool.window.prevent.move.resize.timeout=100
ide.tool.window.prevent.move.resize.timeout.description=Time interval (in ms) after showing a detached (floating or windowed) tool window during which\
OS/JBR-induced moves and resizes will be prevented. Set to a negative value to disable this functionality