mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
UI DSL: Support for turning off default grow behavior of scroll panes
GitOrigin-RevId: bc3c8a680906e5748b6ad6b1be1bfeb291da00f9
This commit is contained in:
committed by
intellij-monorepo-bot
parent
775802f98c
commit
7dd4862fb1
@@ -120,6 +120,15 @@ fun <T : JCheckBox> CellBuilder<T>.actsAsLabel(): CellBuilder<T> {
|
||||
return this
|
||||
}
|
||||
|
||||
internal interface ScrollPaneCellBuilder {
|
||||
fun noGrowY()
|
||||
}
|
||||
|
||||
fun <T : JScrollPane> CellBuilder<T>.noGrowY(): CellBuilder<T> {
|
||||
(this as ScrollPaneCellBuilder).noGrowY()
|
||||
return this
|
||||
}
|
||||
|
||||
fun <T : JTextField> CellBuilder<T>.withTextBinding(modelBinding: PropertyBinding<String>): CellBuilder<T> {
|
||||
return withBinding(JTextField::getText, JTextField::setText, modelBinding)
|
||||
}
|
||||
@@ -393,8 +402,8 @@ abstract class Cell : BaseBuilder {
|
||||
panel(*constraints)
|
||||
}
|
||||
|
||||
fun scrollPane(component: Component, vararg constraints: CCFlags) {
|
||||
JBScrollPane(component)(*constraints)
|
||||
fun scrollPane(component: Component, vararg constraints: CCFlags): CellBuilder<JScrollPane> {
|
||||
return JBScrollPane(component)(*constraints)
|
||||
}
|
||||
|
||||
abstract operator fun <T : JComponent> T.invoke(
|
||||
|
||||
@@ -9,8 +9,8 @@ import com.intellij.openapi.ui.panel.ComponentPanelBuilder
|
||||
import com.intellij.ui.HideableTitledSeparator
|
||||
import com.intellij.ui.SeparatorComponent
|
||||
import com.intellij.ui.TitledSeparator
|
||||
import com.intellij.ui.components.DialogPanel
|
||||
import com.intellij.ui.UIBundle
|
||||
import com.intellij.ui.components.DialogPanel
|
||||
import com.intellij.ui.components.Label
|
||||
import com.intellij.ui.layout.*
|
||||
import com.intellij.util.SmartList
|
||||
@@ -418,7 +418,7 @@ class CellBuilderImpl<T : JComponent> internal constructor(
|
||||
private val builder: MigLayoutBuilder,
|
||||
private val row: MigLayoutRow,
|
||||
override val component: T
|
||||
) : CellBuilder<T>, CheckboxCellBuilder {
|
||||
) : CellBuilder<T>, CheckboxCellBuilder, ScrollPaneCellBuilder {
|
||||
override fun comment(text: String, maxLineLength: Int): CellBuilder<T> {
|
||||
row.addCommentRow(component, text, maxLineLength)
|
||||
return this
|
||||
@@ -467,6 +467,13 @@ class CellBuilderImpl<T : JComponent> internal constructor(
|
||||
override fun actsAsLabel() {
|
||||
builder.updateComponentConstraints(component) { spanX = 1 }
|
||||
}
|
||||
|
||||
override fun noGrowY() {
|
||||
builder.updateComponentConstraints(component) {
|
||||
growY(0.0f)
|
||||
pushY(0.0f)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getCommentLeftInset(component: JComponent): Int {
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
layoutConstraints:
|
||||
fillX: true
|
||||
gridGapX:
|
||||
min: &id001 {horizontal: true, unit: 0, value: 0.0}
|
||||
preferred: *id001
|
||||
gridGapY:
|
||||
min: &id002 {horizontal: false, value: 10.0}
|
||||
preferred: *id002
|
||||
hideMode: 2
|
||||
insets:
|
||||
- {horizontal: false, unit: 0, value: 0.0}
|
||||
- {horizontal: true, unit: 0, value: 0.0}
|
||||
- {horizontal: false, unit: 0, value: 0.0}
|
||||
- {horizontal: true, unit: 0, value: 0.0}
|
||||
rowConstraints:
|
||||
constraints:
|
||||
- align: &id003 {horizontal: false, unit: -1, value: 0.0}
|
||||
- align: *id003
|
||||
count: 2
|
||||
columnConstraints:
|
||||
constraints:
|
||||
- {}
|
||||
componentConstrains:
|
||||
'JBScrollPane #0':
|
||||
horizontal: {grow: 100.0}
|
||||
pushY: 100.0
|
||||
spanX: INF
|
||||
vertical: {grow: 100.0}
|
||||
wrap: true
|
||||
'JBScrollPane #1':
|
||||
horizontal: {grow: 100.0}
|
||||
pushY: 0.0
|
||||
spanX: INF
|
||||
vertical: {grow: 0.0}
|
||||
wrap: true
|
||||
@@ -8,6 +8,7 @@ import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.TestName
|
||||
import javax.swing.JPanel
|
||||
import javax.swing.JTable
|
||||
|
||||
/**
|
||||
* Set `test.update.snapshots=true` to automatically update snapshots if need.
|
||||
@@ -82,5 +83,19 @@ abstract class UiDslTest {
|
||||
doTest { titledRow() }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun scrollPaneNoGrow() {
|
||||
doTest {
|
||||
panel {
|
||||
row {
|
||||
scrollPane(JTable())
|
||||
}
|
||||
row {
|
||||
scrollPane(JTable()).noGrowY()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract fun doTest(panelCreator: () -> JPanel)
|
||||
}
|
||||
Reference in New Issue
Block a user