mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
[python] Jupyter: StubComponent for CollapsingComponent will be created when it was needed. #PY-70765 Fixed
GitOrigin-RevId: 4f44fb827182156e34fd8ac944acaa133ed5aebb
This commit is contained in:
committed by
intellij-monorepo-bot
parent
1b8340b1bc
commit
e14ea09802
@@ -40,11 +40,21 @@ internal class CollapsingComponent(internal val editor: EditorImpl,
|
||||
}
|
||||
}
|
||||
|
||||
val mainComponent = child
|
||||
|
||||
private val stubComponent = lazy {
|
||||
val result = StubComponent(editor)
|
||||
add(result)
|
||||
result
|
||||
}
|
||||
|
||||
var isSeen: Boolean
|
||||
get() = mainComponent.isVisible
|
||||
set(value) {
|
||||
mainComponent.isVisible = value
|
||||
stubComponent.isVisible = !value
|
||||
if (stubComponent.isInitialized()) {
|
||||
stubComponent.value.isVisible = !value
|
||||
}
|
||||
|
||||
if (resizable) {
|
||||
if (value) {
|
||||
@@ -58,13 +68,16 @@ internal class CollapsingComponent(internal val editor: EditorImpl,
|
||||
}
|
||||
|
||||
if (!value) {
|
||||
(stubComponent as StubComponent).text = collapsedTextSupplier()
|
||||
stubComponent.value.text = collapsedTextSupplier()
|
||||
}
|
||||
}
|
||||
|
||||
val isWorthCollapsing: Boolean get() = !isSeen || mainComponent.height >= MIN_HEIGHT_TO_COLLAPSE
|
||||
|
||||
val hasBeenManuallyResized: Boolean get() = customHeight != -1
|
||||
|
||||
init {
|
||||
add(child)
|
||||
add(StubComponent(editor))
|
||||
border = if (resizable) ResizeHandlebarUpdater.invisibleResizeBorder else null
|
||||
isSeen = true
|
||||
}
|
||||
@@ -79,13 +92,6 @@ internal class CollapsingComponent(internal val editor: EditorImpl,
|
||||
super.remove(index)
|
||||
}
|
||||
|
||||
val mainComponent: JComponent get() = getComponent(0) as JComponent
|
||||
private val stubComponent: JComponent get() = getComponent(1) as JComponent
|
||||
|
||||
val isWorthCollapsing: Boolean get() = !isSeen || mainComponent.height >= MIN_HEIGHT_TO_COLLAPSE
|
||||
|
||||
val hasBeenManuallyResized: Boolean get() = customHeight != -1
|
||||
|
||||
fun resetCustomHeight() {
|
||||
customHeight = -1
|
||||
if (mainComponent.isValid) {
|
||||
@@ -95,7 +101,7 @@ internal class CollapsingComponent(internal val editor: EditorImpl,
|
||||
|
||||
override fun getPreferredSize(): Dimension {
|
||||
val result = when {
|
||||
!isSeen -> stubComponent.preferredSize
|
||||
!isSeen -> stubComponent.value.preferredSize
|
||||
customHeight >= 0 -> mainComponent.preferredSize.apply { height = customHeight }
|
||||
else -> mainComponent.preferredSize
|
||||
}
|
||||
@@ -107,7 +113,7 @@ internal class CollapsingComponent(internal val editor: EditorImpl,
|
||||
val (borderWidth, borderHeight) = insets.run { left + right to top + bottom }
|
||||
when {
|
||||
!isSeen ->
|
||||
stubComponent.setBounds(0, 0, width - borderWidth, height - borderHeight)
|
||||
stubComponent.value.setBounds(0, 0, width - borderWidth, height - borderHeight)
|
||||
|
||||
customHeight >= 0 ->
|
||||
mainComponent.setBounds(0, 0, width - borderWidth, customHeight - borderHeight)
|
||||
@@ -153,7 +159,7 @@ internal class CollapsingComponent(internal val editor: EditorImpl,
|
||||
|
||||
fun updateStubIfCollapsed() {
|
||||
if (!isSeen) {
|
||||
(stubComponent as StubComponent).text = collapsedTextSupplier()
|
||||
stubComponent.value.text = collapsedTextSupplier()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ import org.jetbrains.plugins.notebooks.visualization.ui.registerEditorSizeWatche
|
||||
import org.jetbrains.plugins.notebooks.visualization.ui.textEditingAreaWidth
|
||||
import java.awt.BorderLayout
|
||||
import java.awt.Dimension
|
||||
import java.awt.Insets
|
||||
import javax.swing.JPanel
|
||||
|
||||
internal class SurroundingComponent private constructor(private val innerComponent: InnerComponent) : JPanel(
|
||||
@@ -18,6 +17,7 @@ internal class SurroundingComponent private constructor(private val innerCompone
|
||||
private var presetWidth = 0
|
||||
|
||||
init {
|
||||
isOpaque = true
|
||||
border = IdeBorderFactory.createEmptyBorder(JBUI.insetsTop(10))
|
||||
add(innerComponent, BorderLayout.CENTER)
|
||||
}
|
||||
@@ -28,7 +28,6 @@ internal class SurroundingComponent private constructor(private val innerCompone
|
||||
|
||||
override fun updateUI() {
|
||||
super.updateUI()
|
||||
isOpaque = true
|
||||
background = getEditorBackground()
|
||||
}
|
||||
|
||||
@@ -42,10 +41,7 @@ internal class SurroundingComponent private constructor(private val innerCompone
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun create(
|
||||
editor: EditorImpl,
|
||||
innerComponent: InnerComponent,
|
||||
) = SurroundingComponent(innerComponent).also {
|
||||
fun create(editor: EditorImpl, innerComponent: InnerComponent) = SurroundingComponent(innerComponent).also {
|
||||
registerEditorSizeWatcher(it) {
|
||||
it.presetWidth = editor.textEditingAreaWidth
|
||||
if (it.presetWidth == 0 && GraphicsUtil.isRemoteEnvironment()) {
|
||||
|
||||
Reference in New Issue
Block a user