[Kotlin UI DSL] Hidden deprecated API

GitOrigin-RevId: ae6adb989e0b588b895d60bed800f6ddb7c134d5
This commit is contained in:
Pavel Porvatov
2024-02-20 20:27:05 +01:00
committed by intellij-monorepo-bot
parent 9ace4caf73
commit 3a57ed8c90
6 changed files with 38 additions and 36 deletions

View File

@@ -36,7 +36,7 @@ fun textFieldWithBrowseTargetButton(row: Row,
targetBrowserHints)
textFieldWithBrowseButton.addActionListener(browser)
textFieldWithBrowseButton.text = property.get()
return row.component(textFieldWithBrowseButton).withBinding(TextFieldWithBrowseButton::getText,
return row.component(textFieldWithBrowseButton).withBindingInt(TextFieldWithBrowseButton::getText,
TextFieldWithBrowseButton::setText,
property)
}

View File

@@ -82,7 +82,7 @@ inline fun <reified T : Any> KMutableProperty0<T>.toBinding(): PropertyBinding<T
}
@ApiStatus.ScheduledForRemoval
@Deprecated("Use Kotlin UI DSL Version 2")
@Deprecated("Use Kotlin UI DSL Version 2", level = DeprecationLevel.HIDDEN)
inline fun <reified T : Any> KMutableProperty0<T?>.toNullableBinding(defaultValue: T): PropertyBinding<T> {
return PropertyBinding({ get() ?: defaultValue }, { set(it) })
}
@@ -153,7 +153,7 @@ interface CellBuilder<out T : JComponent> {
fun applyIfEnabled(): CellBuilder<T>
@ApiStatus.ScheduledForRemoval
@Deprecated("Use Kotlin UI DSL Version 2")
@Deprecated("Use Kotlin UI DSL Version 2", level = DeprecationLevel.HIDDEN)
fun <V> withBinding(
componentGet: (T) -> V,
componentSet: (T, V) -> Unit,
@@ -165,6 +165,20 @@ interface CellBuilder<out T : JComponent> {
return this
}
@ApiStatus.ScheduledForRemoval
@ApiStatus.Internal
@Deprecated("Use Kotlin UI DSL Version 2")
fun <V> withBindingInt(
componentGet: (T) -> V,
componentSet: (T, V) -> Unit,
modelBinding: PropertyBinding<V>
): CellBuilder<T> {
onApply { if (shouldSaveOnApply()) modelBinding.set(componentGet(component)) }
onReset { componentSet(component, modelBinding.get()) }
onIsModified { shouldSaveOnApply() && componentGet(component) != modelBinding.get() }
return this
}
@ApiStatus.ScheduledForRemoval
@Deprecated("Use Kotlin UI DSL Version 2")
fun withGraphProperty(property: GraphProperty<*>): CellBuilder<T>
@@ -174,7 +188,7 @@ interface CellBuilder<out T : JComponent> {
fun enabled(isEnabled: Boolean)
@ApiStatus.ScheduledForRemoval
@Deprecated("Use Kotlin UI DSL Version 2")
@Deprecated("Use Kotlin UI DSL Version 2", level = DeprecationLevel.HIDDEN)
fun enableIf(predicate: ComponentPredicate): CellBuilder<T>
@ApiStatus.ScheduledForRemoval
@@ -207,18 +221,18 @@ fun <T : JComponent> CellBuilder<T>.applyToComponent(task: T.() -> Unit): CellBu
@ApiStatus.ScheduledForRemoval
@Deprecated("Use Kotlin UI DSL Version 2")
fun <T : JTextComponent> CellBuilder<T>.withTextBinding(modelBinding: PropertyBinding<String>): CellBuilder<T> {
return withBinding(JTextComponent::getText, JTextComponent::setText, modelBinding)
return withBindingInt(JTextComponent::getText, JTextComponent::setText, modelBinding)
}
@ApiStatus.ScheduledForRemoval
@Deprecated("Use Kotlin UI DSL Version 2")
fun <T : AbstractButton> CellBuilder<T>.withSelectedBinding(modelBinding: PropertyBinding<Boolean>): CellBuilder<T> {
return withBinding(AbstractButton::isSelected, AbstractButton::setSelected, modelBinding)
return withBindingInt(AbstractButton::isSelected, AbstractButton::setSelected, modelBinding)
}
@get:Deprecated("Use Kotlin UI DSL Version 2")
@get:Deprecated("Use Kotlin UI DSL Version 2", level = DeprecationLevel.HIDDEN)
@get:ApiStatus.ScheduledForRemoval
@Deprecated("Use Kotlin UI DSL Version 2")
@Deprecated("Use Kotlin UI DSL Version 2", level = DeprecationLevel.HIDDEN)
val CellBuilder<AbstractButton>.selected: ComponentPredicate
get() = component.selected
@@ -233,7 +247,7 @@ abstract class Cell : BaseBuilder {
* Grow weight will only be compared against the weights for the same cell.
*/
@ApiStatus.ScheduledForRemoval
@Deprecated("Use Kotlin UI DSL Version 2")
@Deprecated("Use Kotlin UI DSL Version 2", level = DeprecationLevel.HIDDEN)
val growX: CCFlags = CCFlags.growX
@ApiStatus.ScheduledForRemoval
@@ -296,7 +310,7 @@ abstract class Cell : BaseBuilder {
}
@ApiStatus.ScheduledForRemoval
@Deprecated("Use Kotlin UI DSL Version 2")
@Deprecated("Use Kotlin UI DSL Version 2", level = DeprecationLevel.HIDDEN)
fun button(@Button text: String, actionListener: (event: ActionEvent) -> Unit): CellBuilder<JButton> {
val button = JButton(BundleBase.replaceMnemonicAmpersand(text))
button.addActionListener(actionListener)
@@ -304,7 +318,7 @@ abstract class Cell : BaseBuilder {
}
@ApiStatus.ScheduledForRemoval
@Deprecated("Use Kotlin UI DSL Version 2")
@Deprecated("Use Kotlin UI DSL Version 2", level = DeprecationLevel.HIDDEN)
inline fun checkBox(@Checkbox text: String,
isSelected: Boolean = false,
@DetailedDescription comment: String? = null,
@@ -356,7 +370,7 @@ abstract class Cell : BaseBuilder {
}
@ApiStatus.ScheduledForRemoval
@Deprecated("Use Kotlin UI DSL Version 2")
@Deprecated("Use Kotlin UI DSL Version 2", level = DeprecationLevel.HIDDEN)
fun <T> comboBox(model: ComboBoxModel<T>,
getter: () -> T?,
setter: (T?) -> Unit,
@@ -374,7 +388,7 @@ abstract class Cell : BaseBuilder {
this.renderer = renderer ?: SimpleListCellRenderer.create("") { it.toString() }
selectedItem = modelBinding.get()
}
.withBinding(
.withBindingInt(
{ component -> component.selectedItem as T? },
{ component, value -> component.setSelectedItem(value) },
modelBinding
@@ -382,7 +396,7 @@ abstract class Cell : BaseBuilder {
}
@ApiStatus.ScheduledForRemoval
@Deprecated("Use Kotlin UI DSL Version 2")
@Deprecated("Use Kotlin UI DSL Version 2", level = DeprecationLevel.HIDDEN)
inline fun <reified T : Any> comboBox(
model: ComboBoxModel<T>,
prop: KMutableProperty0<T>,
@@ -418,19 +432,11 @@ abstract class Cell : BaseBuilder {
.withTextBinding(binding)
}
@Deprecated("Use Kotlin UI DSL Version 2")
private fun scrollableTextArea(binding: PropertyBinding<String>, rows: Int? = null): CellBuilder<JBTextArea> {
val textArea = JBTextArea(binding.get(), rows ?: 0, 0)
val scrollPane = JBScrollPane(textArea)
return component(textArea, scrollPane)
.withTextBinding(binding)
}
@ApiStatus.ScheduledForRemoval
@Deprecated("Use Kotlin UI DSL Version 2", level = DeprecationLevel.HIDDEN)
fun spinner(getter: () -> Int, setter: (Int) -> Unit, minValue: Int, maxValue: Int, step: Int = 1): CellBuilder<JBIntSpinner> {
val spinner = JBIntSpinner(getter(), minValue, maxValue, step)
return component(spinner).withBinding(JBIntSpinner::getNumber, JBIntSpinner::setNumber, PropertyBinding(getter, setter))
return component(spinner).withBindingInt(JBIntSpinner::getNumber, JBIntSpinner::setNumber, PropertyBinding(getter, setter))
}
@ApiStatus.ScheduledForRemoval
@@ -487,7 +493,7 @@ class InnerCell(val cell: Cell) : Cell() {
}
@ApiStatus.ScheduledForRemoval
@Deprecated("Use simplified method com.intellij.ui.dsl.builder.UtilsKt.listCellRenderer instead")
@Deprecated("Use com.intellij.ui.dsl.listCellRenderer.BuilderKt.textListCellRenderer/listCellRenderer instead", level = DeprecationLevel.HIDDEN)
fun <T> listCellRenderer(renderer: SimpleListCellRenderer<T?>.(value: T, index: Int, isSelected: Boolean) -> Unit): SimpleListCellRenderer<T?> {
return object : SimpleListCellRenderer<T?>() {
override fun customize(list: JList<out T?>, value: T?, index: Int, selected: Boolean, hasFocus: Boolean) {

View File

@@ -15,11 +15,12 @@ open class LayoutBuilder @PublishedApi internal constructor(@PublishedApi intern
@ApiStatus.ScheduledForRemoval
@Deprecated("Use Kotlin UI DSL Version 2")
@Deprecated("Use Kotlin UI DSL Version 2", level = DeprecationLevel.HIDDEN)
class RowBuilderWithButtonGroupProperty<T : Any>
@PublishedApi
@ApiStatus.ScheduledForRemoval
@Deprecated("Use Kotlin UI DSL Version 2")
@Deprecated("Use Kotlin UI DSL Version 2", level = DeprecationLevel.HIDDEN)
internal constructor(private val builder: RowBuilder, private val prop: PropertyBinding<T>) : RowBuilder by builder

View File

@@ -42,7 +42,7 @@ interface RowBuilder : BaseBuilder {
}
@ApiStatus.ScheduledForRemoval
@Deprecated("Use Kotlin UI DSL Version 2")
@Deprecated("Use Kotlin UI DSL Version 2", level = DeprecationLevel.HIDDEN)
fun titledRow(@NlsContexts.BorderTitle title: String, init: Row.() -> Unit): Row
/**

View File

@@ -248,11 +248,11 @@ internal class MigLayoutRow(private val parent: MigLayoutRow?,
}
override fun titledRow(@NlsContexts.Separator title: String, init: Row.() -> Unit): Row {
return createBlockRow(title, true, init)
return createBlockRow(title, init)
}
private fun createBlockRow(@NlsContexts.Separator title: String?, isSeparated: Boolean, init: Row.() -> Unit): Row {
val parentRow = createChildRow(indent = indent, title = title, isSeparated = isSeparated, incrementsIndent = isSeparated)
private fun createBlockRow(@NlsContexts.Separator title: String?, init: Row.() -> Unit): Row {
val parentRow = createChildRow(indent = indent, title = title, isSeparated = true, incrementsIndent = true)
parentRow.init()
val result = parentRow.createChildRow()
result.internalPlaceholder()
@@ -588,8 +588,3 @@ private val JComponent.origin: JComponent
else -> this
}
}
private fun Row.attachSubRowsEnabled(component: AbstractButton) {
subRowsEnabled = component.selected()
component.selected.addListener { subRowsEnabled = it }
}

View File

@@ -41,7 +41,7 @@ internal fun overrideFlags(cc: CC, flags: Array<out CCFlags>) {
@ApiStatus.ScheduledForRemoval
@Deprecated("Mig Layout is going to be removed, IDEA-306719")
internal class DefaultComponentConstraintCreator(private val spacing: SpacingConfiguration) {
internal class DefaultComponentConstraintCreator(spacing: SpacingConfiguration) {
private val shortTextSizeSpec = ConstraintParser.parseBoundSize("${spacing.shortTextWidth}px!", false, true)
private val mediumTextSizeSpec = ConstraintParser.parseBoundSize("${spacing.shortTextWidth}px::${spacing.maxShortTextWidth}px", false, true)