Skip to content

Commit 0ccf143

Browse files
authored
Merge pull request #474 from FWDekker/deps-and-popup
Deps and popup
2 parents c402aff + 5700fc9 commit 0ccf143

File tree

15 files changed

+125
-85
lines changed

15 files changed

+125
-85
lines changed

build.gradle.kts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import io.gitlab.arturbosch.detekt.Detekt
12
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
23
import org.gradle.api.tasks.testing.logging.TestLogEvent
34
import org.jetbrains.changelog.Changelog
5+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
46
import java.net.URL
57
import java.time.Year
68

@@ -10,18 +12,18 @@ fun properties(key: String) = project.findProperty(key).toString()
1012
/// Plugins
1113
plugins {
1214
// Compilation
13-
id("org.jetbrains.kotlin.jvm") version "1.8.22" // See also `gradle.properties`
14-
id("org.jetbrains.intellij") version "1.14.2"
15+
id("org.jetbrains.kotlin.jvm") version "1.9.10" // Use latest version, ignoring `gradle.properties`
16+
id("org.jetbrains.intellij") version "1.15.0"
1517

1618
// Tests/coverage
17-
id("org.jetbrains.kotlinx.kover") version "0.7.2"
19+
id("org.jetbrains.kotlinx.kover") version "0.7.3"
1820

1921
// Static analysis
20-
id("io.gitlab.arturbosch.detekt") version "1.23.0" // See also `gradle.properties`
22+
id("io.gitlab.arturbosch.detekt") version "1.23.1" // See also `gradle.properties`
2123

2224
// Documentation
23-
id("org.jetbrains.changelog") version "2.1.0"
24-
id("org.jetbrains.dokka") version "1.8.20"
25+
id("org.jetbrains.changelog") version "2.2.0"
26+
id("org.jetbrains.dokka") version "1.9.0"
2527
}
2628

2729

@@ -57,14 +59,14 @@ tasks {
5759
sourceCompatibility = properties("javaVersion")
5860
targetCompatibility = properties("javaVersion")
5961
}
60-
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
62+
withType<KotlinCompile> {
6163
kotlinOptions {
6264
jvmTarget = properties("javaVersion")
6365
apiVersion = properties("kotlinApiVersion")
6466
languageVersion = properties("kotlinVersion")
6567
}
6668
}
67-
withType<io.gitlab.arturbosch.detekt.Detekt> {
69+
withType<Detekt> {
6870
jvmTarget = properties("javaVersion")
6971
}
7072

@@ -136,7 +138,7 @@ tasks {
136138

137139
// Documentation
138140
dokkaHtml.configure {
139-
notCompatibleWithConfigurationCache("Not sure why")
141+
notCompatibleWithConfigurationCache("cf. https://github.com/Kotlin/dokka/issues/1217")
140142

141143
pluginsMapConfiguration.set(
142144
mapOf(

gradle.properties

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,43 @@ group=com.fwdekker
33
version=3.0.0-beta.3
44

55
# Compatibility
6-
# * If latest is 20xx.y, then support at least [20xx-1].[y+1]
7-
# e.g., if latest is 2020.3, support at least 2019.4 (aka 2020.1).
8-
# See also https://data.services.jetbrains.com/products?fields=name,releases.version,releases.build&code=IC,CL.
9-
# * For `intellijVersion`, use the oldest supported version, because that's what the plugin will be compiled against.
10-
pluginSinceBuild=222.0
11-
intellijVersion=2022.2
12-
pluginVerifierIdeVersions=IC-2022.2.5, IC-2022.3.3, IC-2023.1.3, CL-2022.2.5, CL-2022.3.3, CL-2023.1.4
6+
# * `pluginSinceBuild`:
7+
# If latest is 20xx.y, then support at least [20xx-1].[y+1]. For example, if latest is 2020.3, support at least
8+
# 2019.4 (aka 2020.1).
9+
# * `intellijVersion`:
10+
# Use the oldest supported version, because that's what the plugin will be compiled against.
11+
# * `pluginVerifierIdeVersions`:
12+
# For every supported version minor release, include both the IC and the CL release with the highest patch version
13+
# See also https://data.services.jetbrains.com/products?fields=name,releases.version,releases.build&code=IC,CL.
14+
pluginSinceBuild=223.0
15+
intellijVersion=2022.3
16+
pluginVerifierIdeVersions=IC-2022.3.3, IC-2023.1.5, IC-2023.2.2, CL-2022.3.3, CL-2023.1.5, CL-2023.2.2
1317

1418
# Targets
15-
# * Java
16-
# * Java version should be the one used by the oldest Randomness-supported version of IntelliJ, as listed in
17-
# https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html#intellij-platform-based-products-of-recent-ide-versions
19+
# * Java:
20+
# Java version should be the one used by the oldest Randomness-supported version of IntelliJ. See also
21+
# https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html#intellij-platform-based-products-of-recent-ide-versions.
1822
#
1923
# * Kotlin
2024
# * `kotlinVersion` is the same as `kotlinApiVersion`.
21-
# * Kotlin should also be updated in `plugins` block.
22-
# * Kotlin version should be bundled stdlib version of oldest supported IntelliJ version listed in
23-
# https://plugins.jetbrains.com/docs/intellij/using-kotlin.html#kotlin-standard-library
25+
# * Kotlin version should be bundled stdlib version of oldest supported IntelliJ version. See also
26+
# https://plugins.jetbrains.com/docs/intellij/using-kotlin.html#kotlin-standard-library.
2427
javaVersion=17
25-
kotlinVersion=1.6
26-
kotlinApiVersion=1.6
28+
kotlinVersion=1.7
29+
kotlinApiVersion=1.7
2730

2831
# Dependencies
2932
# * Detekt should also be updated in `plugins` block.
3033
# * RgxGen should also be updated in `StringSchemeEditor` link.
3134
assertjSwingVersion=3.17.1
3235
dateparserVersion=1.0.11
33-
detektVersion=1.23.0
36+
detektVersion=1.23.1
3437
emojiVersion=5.1.1
35-
junitVersion=5.9.3
36-
junitRunnerVersion=1.9.3
37-
kotestVersion=5.6.2
38+
junitVersion=5.10.0
39+
junitRunnerVersion=1.10.0
40+
kotestVersion=5.7.2
3841
rgxgenVersion=1.4
39-
uuidGeneratorVersion=3.3.0
42+
uuidGeneratorVersion=4.3.0
4043

4144
# Gradle
4245
org.gradle.caching=true

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
33
zipStoreBase=GRADLE_USER_HOME
44
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip

src/main/kotlin/com/fwdekker/randomness/PopupAction.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class PopupAction : AnAction(Icons.RANDOMNESS) {
106106
* @param event carries contextual information
107107
*/
108108
override fun getChildren(event: AnActionEvent?) =
109-
PersistentSettings.default.state.templates.map { TemplateGroupAction(it) }.toTypedArray<AnAction>() +
109+
Settings.DEFAULT.templates.map { TemplateGroupAction(it) }.toTypedArray<AnAction>() +
110110
Separator() +
111111
TemplateSettingsAction()
112112
}
@@ -121,7 +121,7 @@ class PopupAction : AnAction(Icons.RANDOMNESS) {
121121
* @param event carries contextual information
122122
*/
123123
override fun getChildren(event: AnActionEvent?) =
124-
PersistentSettings.default.state.templates.map { TemplateSettingsAction(it) }.toTypedArray<AnAction>() +
124+
Settings.DEFAULT.templates.map { TemplateSettingsAction(it) }.toTypedArray<AnAction>() +
125125
Separator() +
126126
TemplateSettingsAction()
127127
}

src/main/kotlin/com/fwdekker/randomness/State.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ abstract class State {
2525
* @see applyContext
2626
*/
2727
@get:Transient
28-
var context: Box<Settings> = Box({ PersistentSettings.default.state })
28+
var context: Box<Settings> = Box({ Settings.DEFAULT })
2929
protected set
3030

3131

src/main/kotlin/com/fwdekker/randomness/array/ArrayDecoratorEditor.kt

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,25 @@ import com.fwdekker.randomness.array.ArrayDecorator.Companion.MIN_MIN_COUNT
77
import com.fwdekker.randomness.array.ArrayDecorator.Companion.PRESET_AFFIX_DECORATOR_DESCRIPTORS
88
import com.fwdekker.randomness.array.ArrayDecorator.Companion.PRESET_SEPARATORS
99
import com.fwdekker.randomness.ui.JIntSpinner
10+
import com.fwdekker.randomness.ui.LiteralPredicate
1011
import com.fwdekker.randomness.ui.UIConstants
1112
import com.fwdekker.randomness.ui.bindCurrentText
1213
import com.fwdekker.randomness.ui.bindIntValue
1314
import com.fwdekker.randomness.ui.bindSpinners
14-
import com.fwdekker.randomness.ui.indentedRowRange
15+
import com.fwdekker.randomness.ui.decoratedRowRange
1516
import com.fwdekker.randomness.ui.isEditable
1617
import com.fwdekker.randomness.ui.loadMnemonic
1718
import com.fwdekker.randomness.ui.withFixedWidth
1819
import com.fwdekker.randomness.ui.withName
1920
import com.intellij.openapi.ui.ComboBox
2021
import com.intellij.ui.dsl.builder.BottomGap
2122
import com.intellij.ui.dsl.builder.Cell
22-
import com.intellij.ui.dsl.builder.TopGap
2323
import com.intellij.ui.dsl.builder.bindSelected
2424
import com.intellij.ui.dsl.builder.panel
2525
import com.intellij.ui.dsl.builder.selected
26+
import com.intellij.ui.layout.ComponentPredicate
2627
import com.intellij.ui.layout.and
28+
import com.intellij.ui.layout.or
2729
import com.intellij.ui.layout.selected
2830
import javax.swing.JCheckBox
2931

@@ -32,30 +34,29 @@ import javax.swing.JCheckBox
3234
* Component for editing an [ArrayDecorator].
3335
*
3436
* @param scheme the scheme to edit
35-
* @property embedded `true` if the editor is embedded, which means that no titled separator is shown at the top, and
36-
* the user cannot disable the array decorator; [apply] always enables the array decorator.
37+
* @property embedded `true` if the editor is embedded, which means that no titled separator is shown at the top,
38+
* components are additionally indented, and the user cannot disable the array decorator; does not affect the value of
39+
* [ArrayDecorator.enabled]
3740
*/
3841
class ArrayDecoratorEditor(
3942
scheme: ArrayDecorator,
4043
private val embedded: Boolean = false,
4144
) : SchemeEditor<ArrayDecorator>(scheme) {
4245
override val rootComponent = panel {
43-
separator(Bundle("array.title"))
44-
.topGap(TopGap.MEDIUM)
45-
.visible(!embedded)
46-
47-
indentedRowRange(indented = !embedded) {
46+
decoratedRowRange(title = if (!embedded) Bundle("array.title") else null, indent = !embedded) {
4847
lateinit var enabledCheckBox: Cell<JCheckBox>
48+
lateinit var isEnabled: ComponentPredicate
4949

5050
row {
5151
checkBox(Bundle("array.ui.enabled"))
5252
.loadMnemonic()
5353
.withName("arrayEnabled")
5454
.bindSelected(scheme::enabled)
5555
.also { enabledCheckBox = it }
56+
.also { isEnabled = enabledCheckBox.selected.or(LiteralPredicate(embedded)) }
5657
}.visible(!embedded)
5758

58-
indentedRowRange(indented = !embedded) {
59+
decoratedRowRange(indent = !embedded) {
5960
lateinit var minCountSpinner: JIntSpinner
6061
lateinit var maxCountSpinner: JIntSpinner
6162

@@ -86,7 +87,7 @@ class ArrayDecoratorEditor(
8687
.also { separatorEnabledCheckBox = it.component }
8788

8889
cell(ComboBox(PRESET_SEPARATORS))
89-
.enabledIf(enabledCheckBox.selected.and(separatorEnabledCheckBox.selected))
90+
.enabledIf(isEnabled.and(separatorEnabledCheckBox.selected))
9091
.isEditable(true)
9192
.withName("arraySeparator")
9293
.bindCurrentText(scheme::separator)
@@ -96,14 +97,14 @@ class ArrayDecoratorEditor(
9697
AffixDecoratorEditor(
9798
scheme.affixDecorator,
9899
PRESET_AFFIX_DECORATOR_DESCRIPTORS,
99-
enabledIf = enabledCheckBox.selected,
100+
enabledIf = isEnabled,
100101
enableMnemonic = false,
101102
namePrefix = "array",
102103
)
103104
.also { decoratorEditors += it }
104105
.let { cell(it.rootComponent) }
105106
}
106-
}.enabledIf(enabledCheckBox.selected)
107+
}.enabledIf(isEnabled)
107108
}
108109
}
109110

src/main/kotlin/com/fwdekker/randomness/string/StringSchemeEditor.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import com.fwdekker.randomness.ui.withName
1212
import com.fwdekker.randomness.ui.withSimpleRenderer
1313
import com.intellij.openapi.ui.ComboBox
1414
import com.intellij.ui.dsl.builder.BottomGap
15-
import com.intellij.ui.dsl.builder.EMPTY_LABEL
1615
import com.intellij.ui.dsl.builder.bindItem
1716
import com.intellij.ui.dsl.builder.bindSelected
1817
import com.intellij.ui.dsl.builder.bindText
@@ -38,14 +37,14 @@ class StringSchemeEditor(scheme: StringScheme = StringScheme()) : SchemeEditor<S
3837
browserLink(Bundle("string.ui.value.pattern_help"), Bundle("string.ui.value.pattern_help_url"))
3938
}
4039

41-
row(EMPTY_LABEL) {
40+
row("") {
4241
checkBox(Bundle("string.ui.value.is_regex_option"))
4342
.loadMnemonic()
4443
.withName("isRegex")
4544
.bindSelected(scheme::isRegex)
4645
}
4746

48-
row(EMPTY_LABEL) {
47+
row("") {
4948
checkBox(Bundle("string.ui.value.remove_look_alike"))
5049
.loadMnemonic()
5150
.withName("removeLookAlikeCharacters")

src/main/kotlin/com/fwdekker/randomness/template/TemplateActionLoader.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.fwdekker.randomness.template
22

3-
import com.fwdekker.randomness.PersistentSettings
3+
import com.fwdekker.randomness.Settings
44
import com.intellij.openapi.actionSystem.ActionManager
55
import com.intellij.openapi.actionSystem.impl.DynamicActionConfigurationCustomizer
66

@@ -11,17 +11,17 @@ import com.intellij.openapi.actionSystem.impl.DynamicActionConfigurationCustomiz
1111
* @property getTemplates Shorthand to return all the user's stored [Template]s.
1212
*/
1313
open class TemplateActionLoader(
14-
private val getTemplates: () -> List<Template> = { PersistentSettings.default.state.templates },
14+
private val getTemplates: () -> List<Template> = { Settings.DEFAULT.templates },
1515
) : DynamicActionConfigurationCustomizer {
1616
/**
17-
* Registers the actions for all [Template]s in the user's [PersistentSettings] using [actionManager].
17+
* Registers the actions for all [Template]s in the user's [Settings] using [actionManager].
1818
*/
1919
override fun registerActions(actionManager: ActionManager) {
2020
getTemplates().forEach { registerAction(actionManager, it) }
2121
}
2222

2323
/**
24-
* Unregisters the actions of all [Template]s in the user's [PersistentSettings] using [actionManager].
24+
* Unregisters the actions of all [Template]s in the user's [Settings] using [actionManager].
2525
*/
2626
override fun unregisterActions(actionManager: ActionManager) {
2727
getTemplates().forEach { unregisterAction(actionManager, it) }

src/main/kotlin/com/fwdekker/randomness/template/TemplateActions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class TemplateInsertAction(
162162
/**
163163
* Saves the [editor]'s state.
164164
*/
165-
override fun apply() = Unit
165+
override fun apply() = editor.apply()
166166

167167
/**
168168
* Returns [text].

0 commit comments

Comments
 (0)