mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
DS-2586 Adjust the width of the output automatically after a resize of the tool window
If editor is located inside a scroll pane, listen to its size changes instead of editor component changes GitOrigin-RevId: 3c4ee8d792049451cc3392646e78470d42bc554a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f6c073c486
commit
46e6d1491f
@@ -11,6 +11,7 @@ import java.awt.event.HierarchyEvent
|
||||
import java.lang.ref.WeakReference
|
||||
import javax.swing.JComponent
|
||||
import javax.swing.JPanel
|
||||
import javax.swing.JScrollPane
|
||||
import javax.swing.SwingUtilities
|
||||
import javax.swing.plaf.PanelUI
|
||||
|
||||
@@ -83,6 +84,7 @@ fun registerEditorSizeWatcher(
|
||||
updateHandler: () -> Unit,
|
||||
) {
|
||||
var editorComponent: EditorComponentImpl? = null
|
||||
var scrollComponent: JScrollPane? = null
|
||||
|
||||
updateHandler()
|
||||
|
||||
@@ -97,9 +99,13 @@ fun registerEditorSizeWatcher(
|
||||
.filterIsInstance<EditorComponentImpl>()
|
||||
.firstOrNull()
|
||||
if (editorComponent !== newEditor) {
|
||||
editorComponent?.removeComponentListener(editorResizeListener)
|
||||
(scrollComponent ?: editorComponent)?.removeComponentListener(editorResizeListener)
|
||||
editorComponent = newEditor
|
||||
editorComponent?.addComponentListener(editorResizeListener)
|
||||
// if editor is located inside a scroll pane, we should listen to its size instead of editor component
|
||||
scrollComponent = generateSequence(editorComponent?.parent) { it.parent }
|
||||
.filterIsInstance<JScrollPane>()
|
||||
.firstOrNull()
|
||||
(scrollComponent ?: editorComponent)?.addComponentListener(editorResizeListener)
|
||||
updateHandler()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user