Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

pluginGroup = no.eirikb.avatest
pluginName = AvaJavaScriptTestRunnerRunConfigurationGenerator
pluginVersion = 1.8.1
pluginVersion = 1.9.0
pluginSinceBuild = 202
pluginUntilBuild = 222.*
# Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class AvaJavaScriptTestRunnerRunConfigurationGenerator : AnAction() {
val basePath = project.basePath
val relPath = if (basePath == null) fileName else currentFile.path.substring(basePath.length + 1)

val configuration = if (AppSettingsState.selectedCommand) {
val configuration = if (AppSettingsState.instance.selectedCommand) {
this.createNodeJsRunConfiguration(project, fileName, relPath, testName)
} else {
this.createNPMRunConfiguration(project, currentFile, fileName, relPath, testName)
Expand Down Expand Up @@ -153,7 +153,7 @@ class AvaJavaScriptTestRunnerRunConfigurationGenerator : AnAction() {
return null
}
node.workingDirectory = project.basePath
node.inputPath = AppSettingsState.inputPath
node.inputPath = AppSettingsState.instance.inputPath
if (node.inputPath == null) {
val projectDir = project.guessProjectDir()
node.inputPath = listOf(
Expand Down Expand Up @@ -189,7 +189,7 @@ class AvaJavaScriptTestRunnerRunConfigurationGenerator : AnAction() {
npmRunSettingsBuilder.setPackageJsonPath(packageJsonPath)

npmRunSettingsBuilder.setArguments(getRunArguments(relPath, testName))
npmRunSettingsBuilder.setScriptNames(listOf(AppSettingsState.npmScriptsText))
npmRunSettingsBuilder.setScriptNames(listOf(AppSettingsState.instance.npmScriptsText))

val npmRunConfiguration = NpmRunConfiguration(
project,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import javax.swing.JComponent

class AppSettingsConfigurable : Configurable {
private var mySettingsComponent: AppSettingsComponent? = null
private val settings = AppSettingsState.instance

override fun getDisplayName(): @Nls(capitalization = Nls.Capitalization.Title) String =
"AVA Test Runner Run Configuration Generator"
Expand All @@ -18,30 +19,31 @@ class AppSettingsConfigurable : Configurable {
}

override fun isModified(): Boolean {
var modifiedInputPath = mySettingsComponent!!.inputPathText != AppSettingsState.inputPath
modifiedInputPath = modifiedInputPath or (mySettingsComponent!!.inputPathText != AppSettingsState.inputPath)
var modifiedInputPath = mySettingsComponent!!.inputPathText != settings.inputPath
modifiedInputPath =
modifiedInputPath or (mySettingsComponent!!.inputPathText != settings.inputPath)

var modifiedSelectedModel = mySettingsComponent!!.selectedCommand != AppSettingsState.selectedCommand
var modifiedSelectedModel = mySettingsComponent!!.selectedCommand != settings.selectedCommand
modifiedSelectedModel =
modifiedSelectedModel or (mySettingsComponent!!.selectedCommand != AppSettingsState.selectedCommand)
modifiedSelectedModel or (mySettingsComponent!!.selectedCommand != settings.selectedCommand)

var modifiedNPMScriptsText = mySettingsComponent!!.npmScriptsText != AppSettingsState.npmScriptsText
var modifiedNPMScriptsText = mySettingsComponent!!.npmScriptsText != settings.npmScriptsText
modifiedNPMScriptsText =
modifiedNPMScriptsText or (mySettingsComponent!!.npmScriptsText != AppSettingsState.npmScriptsText)
modifiedNPMScriptsText or (mySettingsComponent!!.npmScriptsText != settings.npmScriptsText)

return modifiedInputPath || modifiedSelectedModel || modifiedNPMScriptsText
}

override fun apply() {
AppSettingsState.inputPath = mySettingsComponent!!.inputPathText
AppSettingsState.selectedCommand = mySettingsComponent!!.selectedCommand
AppSettingsState.npmScriptsText = mySettingsComponent!!.npmScriptsText
settings.inputPath = mySettingsComponent!!.inputPathText
settings.selectedCommand = mySettingsComponent!!.selectedCommand
settings.npmScriptsText = mySettingsComponent!!.npmScriptsText
}

override fun reset() {
mySettingsComponent!!.inputPathText = AppSettingsState.inputPath
mySettingsComponent!!.selectedCommand = AppSettingsState.selectedCommand
mySettingsComponent!!.npmScriptsText = AppSettingsState.npmScriptsText
mySettingsComponent!!.inputPathText = settings.inputPath
mySettingsComponent!!.selectedCommand = settings.selectedCommand
mySettingsComponent!!.npmScriptsText = settings.npmScriptsText ?: ""
}

override fun disposeUIResources() {
Expand Down
20 changes: 12 additions & 8 deletions src/main/kotlin/no/eirikb/avatest/settings/AppSettingsState.kt
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
package no.eirikb.avatest.settings

import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.components.BaseState
import com.intellij.openapi.components.PersistentStateComponent
import com.intellij.openapi.components.State
import com.intellij.openapi.components.Storage
import com.intellij.util.xmlb.XmlSerializerUtil

@State(name = "no.eirikb.avatest.settings.AppSettingsState", storages = [Storage("SdkSettingsPlugin.xml")])
object AppSettingsState : PersistentStateComponent<AppSettingsState?> {
var inputPath: String? = null
var selectedCommand = true
var npmScriptsText = ""
class AppSettingsState : BaseState(), PersistentStateComponent<AppSettingsState> {
var inputPath by string(null)
var selectedCommand by property(true)
var npmScriptsText by string("")

override fun getState(): AppSettingsState {
return this
companion object {
val instance: AppSettingsState
get() = ApplicationManager.getApplication().getService(AppSettingsState::class.java)
}

override fun getState(): AppSettingsState = this

override fun loadState(state: AppSettingsState) {
XmlSerializerUtil.copyBean(state, this)
copyFrom(state)
}
}