Skip to content

Commit

Permalink
Merge pull request #474 from FWDekker/deps-and-popup
Browse files Browse the repository at this point in the history
Deps and popup
  • Loading branch information
FWDekker authored Sep 22, 2023
2 parents c402aff + 5700fc9 commit 0ccf143
Show file tree
Hide file tree
Showing 15 changed files with 125 additions and 85 deletions.
20 changes: 11 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import io.gitlab.arturbosch.detekt.Detekt
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.changelog.Changelog
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.net.URL
import java.time.Year

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

// Tests/coverage
id("org.jetbrains.kotlinx.kover") version "0.7.2"
id("org.jetbrains.kotlinx.kover") version "0.7.3"

// Static analysis
id("io.gitlab.arturbosch.detekt") version "1.23.0" // See also `gradle.properties`
id("io.gitlab.arturbosch.detekt") version "1.23.1" // See also `gradle.properties`

// Documentation
id("org.jetbrains.changelog") version "2.1.0"
id("org.jetbrains.dokka") version "1.8.20"
id("org.jetbrains.changelog") version "2.2.0"
id("org.jetbrains.dokka") version "1.9.0"
}


Expand Down Expand Up @@ -57,14 +59,14 @@ tasks {
sourceCompatibility = properties("javaVersion")
targetCompatibility = properties("javaVersion")
}
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
withType<KotlinCompile> {
kotlinOptions {
jvmTarget = properties("javaVersion")
apiVersion = properties("kotlinApiVersion")
languageVersion = properties("kotlinVersion")
}
}
withType<io.gitlab.arturbosch.detekt.Detekt> {
withType<Detekt> {
jvmTarget = properties("javaVersion")
}

Expand Down Expand Up @@ -136,7 +138,7 @@ tasks {

// Documentation
dokkaHtml.configure {
notCompatibleWithConfigurationCache("Not sure why")
notCompatibleWithConfigurationCache("cf. https://github.com/Kotlin/dokka/issues/1217")

pluginsMapConfiguration.set(
mapOf(
Expand Down
43 changes: 23 additions & 20 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,43 @@ group=com.fwdekker
version=3.0.0-beta.3

# Compatibility
# * If latest is 20xx.y, then support at least [20xx-1].[y+1]
# e.g., if latest is 2020.3, support at least 2019.4 (aka 2020.1).
# See also https://data.services.jetbrains.com/products?fields=name,releases.version,releases.build&code=IC,CL.
# * For `intellijVersion`, use the oldest supported version, because that's what the plugin will be compiled against.
pluginSinceBuild=222.0
intellijVersion=2022.2
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
# * `pluginSinceBuild`:
# If latest is 20xx.y, then support at least [20xx-1].[y+1]. For example, if latest is 2020.3, support at least
# 2019.4 (aka 2020.1).
# * `intellijVersion`:
# Use the oldest supported version, because that's what the plugin will be compiled against.
# * `pluginVerifierIdeVersions`:
# For every supported version minor release, include both the IC and the CL release with the highest patch version
# See also https://data.services.jetbrains.com/products?fields=name,releases.version,releases.build&code=IC,CL.
pluginSinceBuild=223.0
intellijVersion=2022.3
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

# Targets
# * Java
# * Java version should be the one used by the oldest Randomness-supported version of IntelliJ, as listed in
# https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html#intellij-platform-based-products-of-recent-ide-versions
# * Java:
# Java version should be the one used by the oldest Randomness-supported version of IntelliJ. See also
# https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html#intellij-platform-based-products-of-recent-ide-versions.
#
# * Kotlin
# * `kotlinVersion` is the same as `kotlinApiVersion`.
# * Kotlin should also be updated in `plugins` block.
# * Kotlin version should be bundled stdlib version of oldest supported IntelliJ version listed in
# https://plugins.jetbrains.com/docs/intellij/using-kotlin.html#kotlin-standard-library
# * Kotlin version should be bundled stdlib version of oldest supported IntelliJ version. See also
# https://plugins.jetbrains.com/docs/intellij/using-kotlin.html#kotlin-standard-library.
javaVersion=17
kotlinVersion=1.6
kotlinApiVersion=1.6
kotlinVersion=1.7
kotlinApiVersion=1.7

# Dependencies
# * Detekt should also be updated in `plugins` block.
# * RgxGen should also be updated in `StringSchemeEditor` link.
assertjSwingVersion=3.17.1
dateparserVersion=1.0.11
detektVersion=1.23.0
detektVersion=1.23.1
emojiVersion=5.1.1
junitVersion=5.9.3
junitRunnerVersion=1.9.3
kotestVersion=5.6.2
junitVersion=5.10.0
junitRunnerVersion=1.10.0
kotestVersion=5.7.2
rgxgenVersion=1.4
uuidGeneratorVersion=3.3.0
uuidGeneratorVersion=4.3.0

# Gradle
org.gradle.caching=true
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
4 changes: 2 additions & 2 deletions src/main/kotlin/com/fwdekker/randomness/PopupAction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class PopupAction : AnAction(Icons.RANDOMNESS) {
* @param event carries contextual information
*/
override fun getChildren(event: AnActionEvent?) =
PersistentSettings.default.state.templates.map { TemplateGroupAction(it) }.toTypedArray<AnAction>() +
Settings.DEFAULT.templates.map { TemplateGroupAction(it) }.toTypedArray<AnAction>() +
Separator() +
TemplateSettingsAction()
}
Expand All @@ -121,7 +121,7 @@ class PopupAction : AnAction(Icons.RANDOMNESS) {
* @param event carries contextual information
*/
override fun getChildren(event: AnActionEvent?) =
PersistentSettings.default.state.templates.map { TemplateSettingsAction(it) }.toTypedArray<AnAction>() +
Settings.DEFAULT.templates.map { TemplateSettingsAction(it) }.toTypedArray<AnAction>() +
Separator() +
TemplateSettingsAction()
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/com/fwdekker/randomness/State.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ abstract class State {
* @see applyContext
*/
@get:Transient
var context: Box<Settings> = Box({ PersistentSettings.default.state })
var context: Box<Settings> = Box({ Settings.DEFAULT })
protected set


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,25 @@ import com.fwdekker.randomness.array.ArrayDecorator.Companion.MIN_MIN_COUNT
import com.fwdekker.randomness.array.ArrayDecorator.Companion.PRESET_AFFIX_DECORATOR_DESCRIPTORS
import com.fwdekker.randomness.array.ArrayDecorator.Companion.PRESET_SEPARATORS
import com.fwdekker.randomness.ui.JIntSpinner
import com.fwdekker.randomness.ui.LiteralPredicate
import com.fwdekker.randomness.ui.UIConstants
import com.fwdekker.randomness.ui.bindCurrentText
import com.fwdekker.randomness.ui.bindIntValue
import com.fwdekker.randomness.ui.bindSpinners
import com.fwdekker.randomness.ui.indentedRowRange
import com.fwdekker.randomness.ui.decoratedRowRange
import com.fwdekker.randomness.ui.isEditable
import com.fwdekker.randomness.ui.loadMnemonic
import com.fwdekker.randomness.ui.withFixedWidth
import com.fwdekker.randomness.ui.withName
import com.intellij.openapi.ui.ComboBox
import com.intellij.ui.dsl.builder.BottomGap
import com.intellij.ui.dsl.builder.Cell
import com.intellij.ui.dsl.builder.TopGap
import com.intellij.ui.dsl.builder.bindSelected
import com.intellij.ui.dsl.builder.panel
import com.intellij.ui.dsl.builder.selected
import com.intellij.ui.layout.ComponentPredicate
import com.intellij.ui.layout.and
import com.intellij.ui.layout.or
import com.intellij.ui.layout.selected
import javax.swing.JCheckBox

Expand All @@ -32,30 +34,29 @@ import javax.swing.JCheckBox
* Component for editing an [ArrayDecorator].
*
* @param scheme the scheme to edit
* @property embedded `true` if the editor is embedded, which means that no titled separator is shown at the top, and
* the user cannot disable the array decorator; [apply] always enables the array decorator.
* @property embedded `true` if the editor is embedded, which means that no titled separator is shown at the top,
* components are additionally indented, and the user cannot disable the array decorator; does not affect the value of
* [ArrayDecorator.enabled]
*/
class ArrayDecoratorEditor(
scheme: ArrayDecorator,
private val embedded: Boolean = false,
) : SchemeEditor<ArrayDecorator>(scheme) {
override val rootComponent = panel {
separator(Bundle("array.title"))
.topGap(TopGap.MEDIUM)
.visible(!embedded)

indentedRowRange(indented = !embedded) {
decoratedRowRange(title = if (!embedded) Bundle("array.title") else null, indent = !embedded) {
lateinit var enabledCheckBox: Cell<JCheckBox>
lateinit var isEnabled: ComponentPredicate

row {
checkBox(Bundle("array.ui.enabled"))
.loadMnemonic()
.withName("arrayEnabled")
.bindSelected(scheme::enabled)
.also { enabledCheckBox = it }
.also { isEnabled = enabledCheckBox.selected.or(LiteralPredicate(embedded)) }
}.visible(!embedded)

indentedRowRange(indented = !embedded) {
decoratedRowRange(indent = !embedded) {
lateinit var minCountSpinner: JIntSpinner
lateinit var maxCountSpinner: JIntSpinner

Expand Down Expand Up @@ -86,7 +87,7 @@ class ArrayDecoratorEditor(
.also { separatorEnabledCheckBox = it.component }

cell(ComboBox(PRESET_SEPARATORS))
.enabledIf(enabledCheckBox.selected.and(separatorEnabledCheckBox.selected))
.enabledIf(isEnabled.and(separatorEnabledCheckBox.selected))
.isEditable(true)
.withName("arraySeparator")
.bindCurrentText(scheme::separator)
Expand All @@ -96,14 +97,14 @@ class ArrayDecoratorEditor(
AffixDecoratorEditor(
scheme.affixDecorator,
PRESET_AFFIX_DECORATOR_DESCRIPTORS,
enabledIf = enabledCheckBox.selected,
enabledIf = isEnabled,
enableMnemonic = false,
namePrefix = "array",
)
.also { decoratorEditors += it }
.let { cell(it.rootComponent) }
}
}.enabledIf(enabledCheckBox.selected)
}.enabledIf(isEnabled)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import com.fwdekker.randomness.ui.withName
import com.fwdekker.randomness.ui.withSimpleRenderer
import com.intellij.openapi.ui.ComboBox
import com.intellij.ui.dsl.builder.BottomGap
import com.intellij.ui.dsl.builder.EMPTY_LABEL
import com.intellij.ui.dsl.builder.bindItem
import com.intellij.ui.dsl.builder.bindSelected
import com.intellij.ui.dsl.builder.bindText
Expand All @@ -38,14 +37,14 @@ class StringSchemeEditor(scheme: StringScheme = StringScheme()) : SchemeEditor<S
browserLink(Bundle("string.ui.value.pattern_help"), Bundle("string.ui.value.pattern_help_url"))
}

row(EMPTY_LABEL) {
row("") {
checkBox(Bundle("string.ui.value.is_regex_option"))
.loadMnemonic()
.withName("isRegex")
.bindSelected(scheme::isRegex)
}

row(EMPTY_LABEL) {
row("") {
checkBox(Bundle("string.ui.value.remove_look_alike"))
.loadMnemonic()
.withName("removeLookAlikeCharacters")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.fwdekker.randomness.template

import com.fwdekker.randomness.PersistentSettings
import com.fwdekker.randomness.Settings
import com.intellij.openapi.actionSystem.ActionManager
import com.intellij.openapi.actionSystem.impl.DynamicActionConfigurationCustomizer

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

/**
* Unregisters the actions of all [Template]s in the user's [PersistentSettings] using [actionManager].
* Unregisters the actions of all [Template]s in the user's [Settings] using [actionManager].
*/
override fun unregisterActions(actionManager: ActionManager) {
getTemplates().forEach { unregisterAction(actionManager, it) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class TemplateInsertAction(
/**
* Saves the [editor]'s state.
*/
override fun apply() = Unit
override fun apply() = editor.apply()

/**
* Returns [text].
Expand Down
Loading

0 comments on commit 0ccf143

Please sign in to comment.