Skip to content

Commit c72f989

Browse files
feat: Improve about plugin dialog
1 parent ef97020 commit c72f989

9 files changed

Lines changed: 138 additions & 89 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
- All encoding/decoding, escaping/unescaping and text transformation tools now also support reading from and writing to files.
1818
- New "Escape Sequence" tool for escaping/unescaping line breaks, tabs, backslashes, and single/double quotes.
19+
- New "JSON Handling" settings that allow very fine-grained control over the features for reading and writing JSON in all tools. This makes it possible to handle certain non-standard JSON features, such as comments.
1920
- Added a setting to control the number of decimal places in the "Color Picker" tool.
2021

2122
### Changed

build.gradle.kts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -158,24 +158,6 @@ changelog {
158158
groups.set(listOf("Added", "Changed", "Removed", "Fixed"))
159159
}
160160

161-
val writeChangelogToFileTask =
162-
tasks.register("writeChangelogToFile") {
163-
val generatedResourcesDir = layout.buildDirectory.dir("generated-resources/changelog").get()
164-
outputs.dir(generatedResourcesDir)
165-
166-
doLast {
167-
val renderResult =
168-
changelog.instance.get().releasedItems.joinToString("\n") {
169-
changelog.renderItem(it, Changelog.OutputType.HTML)
170-
}
171-
val baseDir = generatedResourcesDir.dir("dev/turingcomplete/intellijdevelopertoolsplugin")
172-
file(baseDir).mkdirs()
173-
file(baseDir.file("changelog.html")).writeText(renderResult)
174-
}
175-
}
176-
177-
sourceSets { main { resources { srcDir(writeChangelogToFileTask) } } }
178-
179161
tasks {
180162
named("publishPlugin") {
181163
dependsOn("check")

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryErro
44
pluginId=dev.turingcomplete.intellijdevelopertoolsplugins
55
pluginGroup=dev.turingcomplete
66
pluginVersion=7.0.0
7+
pluginName=Developer Tools
78
pluginSinceBuild=243
89
platform=IC
910
# LATEST-EAP-SNAPSHOT

modules/common/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ val generatePluginProperties by
3434
"""
3535
pluginId=${project.property("pluginId")}
3636
pluginVersion=${project.property("pluginVersion")}
37+
pluginName=${project.property("pluginName")}
3738
"""
3839
.trimIndent()
3940
)

modules/common/src/main/kotlin/dev/turingcomplete/intellijdevelopertoolsplugin/common/PluginInfo.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ object PluginInfo {
1414
val pluginVersion: PluginVersion by lazy {
1515
pluginProperties.getProperty("pluginVersion").toPluginVersion()
1616
}
17+
val pluginName: String by lazy { pluginProperties.getProperty("pluginName") }
1718

1819
// -- Initialization ------------------------------------------------------ //
1920
// -- Exported Methods ---------------------------------------------------- //

modules/tools/ui/build.gradle.kts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
import org.jetbrains.changelog.Changelog
2+
13
plugins {
24
`java-test-fixtures`
5+
alias(libs.plugins.changelog)
36
}
47

58
dependencies {
@@ -41,3 +44,32 @@ dependencies {
4144
testFixturesApi(project(":common"))
4245
testFixturesApi(project(":settings"))
4346
}
47+
48+
changelog {
49+
path.set(rootProject.file("CHANGELOG.md").path)
50+
}
51+
52+
val writeChangelogToFileTask =
53+
tasks.register("writeChangelogToFile") {
54+
val generatedResourcesDir = layout.buildDirectory.dir("generated-resources/changelog").get()
55+
outputs.dir(generatedResourcesDir)
56+
57+
doLast {
58+
val renderResult =
59+
changelog.instance.get().releasedItems.joinToString("\n") {
60+
changelog.renderItem(it, Changelog.OutputType.HTML)
61+
}
62+
val baseDir = generatedResourcesDir.dir("dev/turingcomplete/intellijdevelopertoolsplugin")
63+
file(baseDir).mkdirs()
64+
file(baseDir.file("changelog.html")).writeText(renderResult)
65+
}
66+
}
67+
68+
sourceSets { main { resources { srcDir(writeChangelogToFileTask.map { it.outputs.files }) } } }
69+
70+
tasks.withType(org.jetbrains.changelog.tasks.InitializeChangelogTask::class).configureEach {
71+
enabled = false
72+
}
73+
tasks.withType(org.jetbrains.changelog.tasks.PatchChangelogTask::class).configureEach {
74+
enabled = false
75+
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
package dev.turingcomplete.intellijdevelopertoolsplugin.tool.ui.frame
2+
3+
import com.intellij.openapi.project.Project
4+
import com.intellij.openapi.ui.DialogWrapper
5+
import com.intellij.ui.ScrollPaneFactory
6+
import com.intellij.ui.components.JBTabbedPane
7+
import com.intellij.ui.dsl.builder.Align
8+
import com.intellij.ui.dsl.builder.BottomGap
9+
import com.intellij.ui.dsl.builder.RightGap
10+
import com.intellij.ui.dsl.builder.TopGap
11+
import com.intellij.ui.dsl.builder.panel
12+
import com.intellij.util.ui.JBEmptyBorder
13+
import dev.turingcomplete.intellijdevelopertoolsplugin.common.PluginInfo
14+
import java.awt.Dimension
15+
import javax.swing.Action
16+
import javax.swing.JComponent
17+
18+
class AboutPluginDialog(project: Project?, parentComponent: JComponent) :
19+
DialogWrapper(project, parentComponent, true, IdeModalityType.IDE) {
20+
// -- Properties ---------------------------------------------------------- //
21+
// -- Initialization ------------------------------------------------------ //
22+
23+
init {
24+
title = "${PluginInfo.pluginName} - About Plugin"
25+
isModal = true
26+
init()
27+
}
28+
29+
// -- Exported Methods ---------------------------------------------------- //
30+
31+
override fun createCenterPanel(): JComponent {
32+
val panel = panel {
33+
row {
34+
val tabs =
35+
mapOf("About" to createAboutPluginComponent(), "Changelog" to createChangelogComponent())
36+
37+
cell(
38+
JBTabbedPane().apply {
39+
tabs.forEach { (title, component) ->
40+
// Create scroll panes with specific preferred size
41+
val scrollPane = ScrollPaneFactory.createScrollPane(component, true)
42+
scrollPane.preferredSize = Dimension(650, 500)
43+
addTab(title, scrollPane)
44+
}
45+
}
46+
)
47+
.align(Align.FILL)
48+
}
49+
}
50+
51+
// Set preferred size on the entire panel
52+
panel.preferredSize = Dimension(650, 500)
53+
return panel
54+
}
55+
56+
override fun createActions(): Array<Action> = arrayOf(myOKAction)
57+
58+
// -- Private Methods ----------------------------------------------------- //
59+
60+
private fun createAboutPluginComponent(): JComponent =
61+
panel {
62+
row { text("<b>Thanks for using the ${PluginInfo.pluginName} plugin! ❤</b>") }
63+
.bottomGap(BottomGap.NONE)
64+
row { text("Version: ${PluginInfo.pluginVersion}") }.bottomGap(BottomGap.MEDIUM)
65+
66+
row {
67+
text(
68+
"Spotted a bug or thought of a new feature? <a href='https://github.com/marcelkliemannel/intellij-developer-tools-plugin/issues'>Please create an issue on GitHub.</a>"
69+
)
70+
.gap(RightGap.SMALL)
71+
}
72+
.bottomGap(BottomGap.NONE)
73+
row {
74+
comment(
75+
"(The plugin is intended for all JetBrains IDEs and will therefore not be extended with features that target a specific programming language or framework.)"
76+
)
77+
}
78+
.topGap(TopGap.NONE)
79+
}
80+
.apply { this.border = JBEmptyBorder(12, 0, 0, 0) }
81+
82+
private fun createChangelogComponent(): JComponent = panel {
83+
row {
84+
text(
85+
AboutPluginDialog::class.java.getResource(CHANGELOG_HTML_FILE)?.readText()
86+
?: "Couldn't find 'What's New' text"
87+
)
88+
}
89+
}
90+
91+
// -- Inner Type ---------------------------------------------------------- //
92+
// -- Companion Object ---------------------------------------------------- //
93+
94+
companion object {
95+
96+
private const val CHANGELOG_HTML_FILE =
97+
"/dev/turingcomplete/intellijdevelopertoolsplugin/changelog.html"
98+
}
99+
}

modules/tools/ui/src/main/kotlin/dev/turingcomplete/intellijdevelopertoolsplugin/tool/ui/frame/ChangelogDialog.kt

Lines changed: 0 additions & 68 deletions
This file was deleted.

modules/tools/ui/src/main/kotlin/dev/turingcomplete/intellijdevelopertoolsplugin/tool/ui/frame/menu/ToolsMenuTree.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import dev.turingcomplete.intellijdevelopertoolsplugin.tool.ui.base.DeveloperUiT
3333
import dev.turingcomplete.intellijdevelopertoolsplugin.tool.ui.base.DeveloperUiToolFactory
3434
import dev.turingcomplete.intellijdevelopertoolsplugin.tool.ui.base.DeveloperUiToolFactoryEp
3535
import dev.turingcomplete.intellijdevelopertoolsplugin.tool.ui.base.DeveloperUiToolGroup
36-
import dev.turingcomplete.intellijdevelopertoolsplugin.tool.ui.frame.ChangelogDialog
36+
import dev.turingcomplete.intellijdevelopertoolsplugin.tool.ui.frame.AboutPluginDialog
3737
import dev.turingcomplete.intellijdevelopertoolsplugin.tool.ui.frame.instance.OpenSettingsAction
3838
import javax.swing.JComponent
3939
import javax.swing.JPanel
@@ -195,14 +195,14 @@ class ToolsMenuTree(
195195
}
196196

197197
private fun createWhatsNewLink(parentComponent: JComponent) =
198-
HyperlinkLabel("What's new").apply {
198+
HyperlinkLabel("About").apply {
199199
icon = AllIcons.Actions.IntentionBulbGrey
200200
addHyperlinkListener(
201201
object : HyperlinkAdapter() {
202202

203203
override fun hyperlinkActivated(e: HyperlinkEvent) {
204204
ApplicationManager.getApplication().invokeLater {
205-
ChangelogDialog(project, parentComponent).show()
205+
AboutPluginDialog(project, parentComponent).show()
206206
}
207207
}
208208
}

0 commit comments

Comments
 (0)