Skip to content

Commit 7056e47

Browse files
committed
Add headers and reset button when editing release body
1 parent ed475e4 commit 7056e47

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

buildSrc/src/main/kotlin/net/kautler/publishing.gradle.kts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import wooga.gradle.github.publish.tasks.GithubPublish
2727
import java.awt.GraphicsEnvironment.isHeadless
2828
import java.util.concurrent.CompletableFuture
2929
import javax.naming.ConfigurationException
30+
import javax.swing.JButton
3031
import javax.swing.JFrame
3132
import javax.swing.JOptionPane.DEFAULT_OPTION
3233
import javax.swing.JOptionPane.OK_OPTION
@@ -263,18 +264,33 @@ val releaseBody by lazy(NONE) {
263264
val result = CompletableFuture<String>()
264265

265266
SwingUtilities.invokeLater {
266-
val textArea = JTextArea(releaseBody)
267+
val initialReleaseBody = """
268+
# Highlights
269+
-
270+
271+
# Details
272+
273+
""".trimIndent() + releaseBody
274+
275+
val textArea = JTextArea(initialReleaseBody)
267276

268277
val parentFrame = JFrame().apply {
269278
isUndecorated = true
270279
setLocationRelativeTo(null)
271280
isVisible = true
272281
}
273282

283+
val resetButton = JButton("Reset").apply {
284+
addActionListener {
285+
textArea.text = initialReleaseBody
286+
}
287+
}
288+
274289
result.complete(try {
275290
when (showOptionDialog(
276291
parentFrame, JScrollPane(textArea), "Release Body",
277-
DEFAULT_OPTION, QUESTION_MESSAGE, null, null, null
292+
DEFAULT_OPTION, QUESTION_MESSAGE, null,
293+
arrayOf("OK", resetButton), null
278294
)) {
279295
OK_OPTION -> textArea.text!!
280296
else -> releaseBody

0 commit comments

Comments
 (0)