Kotlin UI DSL: deprecate EMPTY_LABEL constant

GitOrigin-RevId: c8c2d264a49fba7c7d22f53f4224c47f8d0447d8
This commit is contained in:
Pavel Porvatov
2022-10-05 01:23:41 +02:00
committed by intellij-monorepo-bot
parent e1a8b6e942
commit 20aa8fbf0a
14 changed files with 18 additions and 29 deletions

View File

@@ -103,7 +103,7 @@ abstract class CommonStarterInitialStep(
if (wizardContext.isCreatingNewProject) {
// Git should not be enabled for single module
row(EMPTY_LABEL) {
row("") {
checkBox(UIBundle.message("label.project.wizard.new.project.git.checkbox"))
.bindSelected(gitProperty)
}.bottomGap(BottomGap.SMALL)

View File

@@ -47,7 +47,7 @@ abstract class LanguageRuntimeConfigurable(private val config: LanguageRuntimeCo
targetVolumeContributions[volumeDescriptor] = it
val component = it.createComponent()
it.resetFrom(volumeDescriptor)
row(EMPTY_LABEL) {
row("") {
cell(component)
.horizontalAlign(HorizontalAlign.FILL)
}

View File

@@ -2,7 +2,6 @@
package com.intellij.ide.util.projectWizard
import com.intellij.ui.dsl.builder.BottomGap
import com.intellij.ui.dsl.builder.EMPTY_LABEL
import com.intellij.ui.dsl.builder.Panel
import com.intellij.ui.dsl.gridLayout.HorizontalAlign
import javax.swing.JComponent
@@ -21,7 +20,7 @@ class PanelBuilderSettingsStep(private val wizardContext: WizardContext, val bui
override fun addSettingsComponent(component: JComponent) {
with(builder) {
row(EMPTY_LABEL) {
row("") {
cell(component).horizontalAlign(HorizontalAlign.FILL)
}.bottomGap(BottomGap.SMALL)
}

View File

@@ -9,7 +9,6 @@ import com.intellij.openapi.project.Project
import com.intellij.ui.UIBundle
import com.intellij.ui.components.JBCheckBox
import com.intellij.ui.components.dialog
import com.intellij.ui.dsl.builder.EMPTY_LABEL
import com.intellij.ui.dsl.builder.panel
import com.intellij.ui.dsl.gridLayout.HorizontalAlign
import com.intellij.util.io.encodeUrlQueryParameter
@@ -42,7 +41,7 @@ fun askJBAccountCredentials(parent: Component, project: Project?, authFailed: Bo
cell(passwordField)
.horizontalAlign(HorizontalAlign.FILL)
}
row(EMPTY_LABEL) {
row("") {
rememberCheckBox = checkBox(UIBundle.message("auth.remember.cb"))
.applyToComponent { isSelected = remember }
.component

View File

@@ -10,7 +10,6 @@ import com.intellij.openapi.ui.ComponentValidator
import com.intellij.openapi.ui.DialogPanel
import com.intellij.openapi.ui.DialogWrapper
import com.intellij.openapi.util.Pair
import com.intellij.ui.dsl.builder.EMPTY_LABEL
import com.intellij.ui.dsl.builder.panel
import com.intellij.ui.dsl.gridLayout.Gaps
import com.intellij.ui.dsl.gridLayout.HorizontalAlign
@@ -63,7 +62,7 @@ internal class AddActionDialog(private val customActionsSchema: CustomActionsSch
.horizontalAlign(HorizontalAlign.FILL)
.customize(Gaps.EMPTY)
}
row(EMPTY_LABEL) {
row("") {
label(IdeBundle.message("browse.custom.icon.hint"))
.applyToComponent {
font = JBUI.Fonts.smallFont()

View File

@@ -10,7 +10,6 @@ import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.LocalFileSystem
import com.intellij.ui.UIBundle
import com.intellij.ui.dsl.builder.BottomGap
import com.intellij.ui.dsl.builder.EMPTY_LABEL
import com.intellij.ui.dsl.builder.Panel
import com.intellij.ui.dsl.builder.bindSelected
import java.nio.file.Path
@@ -31,7 +30,7 @@ class GitNewProjectWizardStep(
override fun setupUI(builder: Panel) {
if (gitRepositoryInitializer != null) {
with(builder) {
row(EMPTY_LABEL) {
row("") {
checkBox(UIBundle.message("label.project.wizard.new.project.git.checkbox"))
.bindSelected(gitProperty)
}.bottomGap(BottomGap.SMALL)

View File

@@ -21,7 +21,7 @@ abstract class CommentNewProjectWizardStep(parent: NewProjectWizardStep) : Abstr
with(builder) {
val row = when (isFullWidth) {
true -> row(init = ::setupCommentUi)
else -> row(EMPTY_LABEL, init = ::setupCommentUi)
else -> row("", init = ::setupCommentUi)
}
row.bottomGap(BottomGap.SMALL)
}

View File

@@ -75,13 +75,13 @@ fun demoTips(parentDisposable: Disposable): DialogPanel {
.rowComment("Last textField occupies only one column like the previous textField")
}
group("Use Panel.row(EMPTY_LABEL) if label is empty") {
group("""Use Panel.row("") if label is empty""") {
row("Row 1:") {
textField()
}
row(EMPTY_LABEL) {
row("") {
textField()
}.rowComment("""Don't use row(""), because it creates unnecessary label component in layout""")
}
}
group("Use Cell.widthGroup to use the same width") {
row {

View File

@@ -16,7 +16,8 @@ import javax.swing.JLabel
/**
* Empty label parameter for [Panel.row] method in case label is omitted.
*/
val EMPTY_LABEL = String()
@Deprecated("Use \"\" instead of this constant")
val EMPTY_LABEL = ""
@ApiStatus.NonExtendable
interface Panel : CellBase<Panel> {
@@ -49,7 +50,7 @@ interface Panel : CellBase<Panel> {
/**
* Adds row with [RowLayout.LABEL_ALIGNED] layout and [label]. The label can contain mnemonic and is assigned
* to the first component in the row via [JLabel.labelFor] property.
* Do not use row(""), because it creates unnecessary label component in layout, use [EMPTY_LABEL] instead.
* Use row("") if label is empty
*/
fun row(@Nls label: String, init: Row.() -> Unit): Row

View File

@@ -36,7 +36,7 @@ internal class PanelImpl(private val dialogPanelConfig: DialogPanelConfig,
private var enabled = true
override fun row(label: String, init: Row.() -> Unit): RowImpl {
if (label === EMPTY_LABEL) {
if (label.isEmpty()) {
val result = RowImpl(dialogPanelConfig, panelContext, this, RowLayout.LABEL_ALIGNED)
result.cell()
result.init()
@@ -44,10 +44,6 @@ internal class PanelImpl(private val dialogPanelConfig: DialogPanelConfig,
return result
}
else {
if (label.isEmpty()) {
warn("Row is created with empty label")
}
return row(Label(label), init)
}
}

View File

@@ -19,7 +19,6 @@ import com.intellij.ui.components.JBCheckBox
import com.intellij.ui.components.JBTextField
import com.intellij.ui.components.dialog
import com.intellij.ui.dsl.builder.Cell
import com.intellij.ui.dsl.builder.EMPTY_LABEL
import com.intellij.ui.dsl.builder.columns
import com.intellij.ui.dsl.builder.panel
import com.intellij.ui.layout.*
@@ -54,7 +53,7 @@ class NewThemeAction : AnAction() {
.columns(30)
.addValidationRule(DevKitThemesBundle.message("new.theme.dialog.name.empty")) { name.component.text.isBlank() }
}
row(EMPTY_LABEL) {
row("") {
isDark = checkBox(DevKitThemesBundle.message("new.theme.dialog.is.dark.checkbox.text")).applyToComponent { isSelected = true }
}
}

View File

@@ -14,7 +14,6 @@ import com.intellij.openapi.util.NlsSafe
import com.intellij.ui.UIBundle
import com.intellij.ui.components.*
import com.intellij.ui.components.panels.Wrapper
import com.intellij.ui.dsl.builder.EMPTY_LABEL
import com.intellij.ui.dsl.builder.Panel
import com.intellij.ui.dsl.builder.bind
import com.intellij.ui.dsl.builder.panel
@@ -90,7 +89,7 @@ class GitHttpLoginDialog @JvmOverloads constructor(project: Project,
private fun Panel.buildCredentialsPanel() {
row(GitBundle.message("login.dialog.username.label")) { cell(usernameField).horizontalAlign(HorizontalAlign.FILL) }
row(GitBundle.message("login.dialog.password.label")) { cell(passwordField).horizontalAlign(HorizontalAlign.FILL) }
row(EMPTY_LABEL) { cell(rememberCheckbox) }
row("") { cell(rememberCheckbox) }
}
override fun doOKAction() {

View File

@@ -8,7 +8,6 @@ import com.intellij.openapi.util.NlsSafe
import com.intellij.ui.components.JBCheckBox
import com.intellij.ui.components.JBTextArea
import com.intellij.ui.components.JBTextField
import com.intellij.ui.dsl.builder.EMPTY_LABEL
import com.intellij.ui.dsl.builder.RowLayout
import com.intellij.ui.dsl.builder.panel
import com.intellij.ui.dsl.gridLayout.HorizontalAlign
@@ -65,7 +64,7 @@ class GithubCreateGistDialog(
.verticalAlign(VerticalAlign.FILL)
}.layout(RowLayout.LABEL_ALIGNED).resizableRow()
row(EMPTY_LABEL) {
row("") {
cell(secretCheckBox)
cell(browserCheckBox)
cell(copyLinkCheckBox)

View File

@@ -23,7 +23,6 @@ import com.intellij.ui.components.JBPanel
import com.intellij.ui.components.labels.LinkLabel
import com.intellij.ui.components.panels.HorizontalLayout
import com.intellij.ui.components.panels.VerticalLayout
import com.intellij.ui.dsl.builder.EMPTY_LABEL
import com.intellij.ui.dsl.builder.Panel
import com.intellij.ui.scale.JBUIScale.scale
import com.intellij.util.ui.JBEmptyBorder
@@ -125,7 +124,7 @@ internal class CloneDialogLoginPanel(private val account: GithubAccount?) :
}
private fun Panel.buttonPanel() =
row(EMPTY_LABEL) {
row("") {
cell(loginButton)
cell(backLink)
}