Skip to content

Commit

Permalink
Add character count to changelog UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Wavesonics committed Feb 1, 2024
1 parent d37ec2b commit 80c90cd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions buildSrc/src/main/java/changelog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import java.awt.event.WindowEvent
import java.io.File
import java.util.concurrent.CountDownLatch
import javax.swing.*
import javax.swing.event.DocumentEvent
import javax.swing.event.DocumentListener

fun writeSemvar(oldSemVar: String, newSemVar: SemVar, versionFile: File) {
val versions = versionFile.readText()
Expand Down Expand Up @@ -36,6 +38,14 @@ data class ReleaseInfo(
val changeLog: String,
)

class OnChangeListener(
val onChange: (e: DocumentEvent?) -> Unit
) : DocumentListener {
override fun insertUpdate(e: DocumentEvent?) = onChange(e)
override fun removeUpdate(e: DocumentEvent?) = onChange(e)
override fun changedUpdate(e: DocumentEvent?) = onChange(e)
}

fun configureRelease(currentSemVarStr: String): ReleaseInfo? {
var result: ReleaseInfo? = null

Expand Down Expand Up @@ -104,11 +114,21 @@ fun configureRelease(currentSemVarStr: String): ReleaseInfo? {

val commitButton = JButton("Commit Changes")

val characterCount = JLabel("Characters: 0")

panel.add(JLabel("Change Log:"))
val changeLog = JTextArea().apply {
setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10))
lineWrap = true
wrapStyleWord = true
}

changeLog.document.addDocumentListener(OnChangeListener { e ->
characterCount.text = "Characters: ${changeLog.document.length}"
})

panel.add(changeLog)
panel.add(characterCount)
panel.add(commitButton)

commitButton.addActionListener {
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/java/versioncode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ data class SemVar(
val minor: Int,
val patch: Int,
) {
val MAX_BUILDNUM = 10_000
private val MAX_BUILDNUM = 10_000

fun createVersion(
isRelease: Boolean,
Expand Down

0 comments on commit 80c90cd

Please sign in to comment.