Skip to content

Commit

Permalink
tweaking summary to recognise no answers
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddenton committed Sep 1, 2024
1 parent ce7c0c1 commit 1d13059
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/main/kotlin/org/http4k/intellij/step/SummaryView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import org.http4k.intellij.wizard.Answer.Step
import org.http4k.intellij.wizard.Answer.Text
import java.awt.Color
import java.awt.Dimension
import javax.swing.BorderFactory
import javax.swing.BorderFactory.createCompoundBorder
import javax.swing.BorderFactory.createEmptyBorder
import javax.swing.BorderFactory.createLineBorder
import javax.swing.Box
import javax.swing.BoxLayout
Expand All @@ -15,7 +15,8 @@ import javax.swing.JPanel

fun SummaryView(answers: List<Answer>) = JPanel().apply {
layout = BoxLayout(this, Y_AXIS)
add("Summary".label().header())
border = createEmptyBorder(15, 15, 15, 15)
add("http4k Project Wizard Summary".label().header())
answers.filterIsInstance<Step>()
.map(::toSectionPanel)
.forEach(::add)
Expand All @@ -31,8 +32,8 @@ private fun toSectionPanel(section: Answer) = JPanel().apply {
maximumSize = Dimension(600, Int.MAX_VALUE)

border = createCompoundBorder(
BorderFactory.createEmptyBorder(10, 10, 10, 10),
createCompoundBorder(createLineBorder(Color.GRAY, 1), BorderFactory.createEmptyBorder(20, 20, 20, 20))
createEmptyBorder(10, 10, 10, 10),
createCompoundBorder(createLineBorder(Color.GRAY, 1), createEmptyBorder(20, 20, 20, 20))
)
add(section.label.label().header())
add(Box.createVerticalStrut(10))
Expand All @@ -51,7 +52,10 @@ private fun toSectionPanel(section: Answer) = JPanel().apply {
}

is Step -> {
add(it.label.substringBefore(".").label().bold())
add((when {
it.label.contains(".") -> it.label.substringBefore(".") + ":"
else -> it.label
}).label().bold())
add(Box.createVerticalStrut(3))
add((it.answers.map { it.label }.takeIf { it.isNotEmpty() }
?: listOf("None")).joinToString(", ").label())
Expand Down

0 comments on commit 1d13059

Please sign in to comment.