From 37e6e8920e2dac7c5330401113d62e8e06d10153 Mon Sep 17 00:00:00 2001 From: bobi Date: Sun, 28 Aug 2022 17:45:18 +0300 Subject: [PATCH] Added ability to test connection during server configuration --- CHANGELOG.md | 4 +--- gradle.properties | 2 +- .../config/ui/AemServerEditDialog.kt | 17 +++++++++++++++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0f1e49..abbdb8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,9 +3,7 @@ # aem-groovyconsole-plugin Changelog ## [Unreleased] - -## [0.4.15] -### Added +### Added - Added ability to test connection during server configuration ## [0.4.13] diff --git a/gradle.properties b/gradle.properties index 1b933a8..775b9e5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ pluginGroup = com.github.bobi.aemgroovyconsoleplugin pluginName = aem-groovyconsole-plugin # SemVer format -> https://semver.org -pluginVersion = 0.4.15 +pluginVersion = 0.4.16 # See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html # for insight into build numbers and IntelliJ Platform versions. diff --git a/src/main/kotlin/com/github/bobi/aemgroovyconsoleplugin/config/ui/AemServerEditDialog.kt b/src/main/kotlin/com/github/bobi/aemgroovyconsoleplugin/config/ui/AemServerEditDialog.kt index fd8da86..4fe48a6 100644 --- a/src/main/kotlin/com/github/bobi/aemgroovyconsoleplugin/config/ui/AemServerEditDialog.kt +++ b/src/main/kotlin/com/github/bobi/aemgroovyconsoleplugin/config/ui/AemServerEditDialog.kt @@ -8,6 +8,7 @@ import com.intellij.openapi.progress.runModalTask import com.intellij.openapi.project.Project import com.intellij.openapi.ui.DialogWrapper import com.intellij.openapi.ui.ValidationInfo +import com.intellij.openapi.wm.IdeFocusManager import com.intellij.ui.components.JBLabel import com.intellij.ui.components.JBTextField import com.intellij.ui.layout.PropertyBinding @@ -99,7 +100,13 @@ class AemServerEditDialog(private val project: Project, private val tableItem: A testServerAction = object : DialogWrapperAction("Test") { override fun doAction(e: ActionEvent) { - testServer() + testConnectionToServer() + } + } + + okAction.addPropertyChangeListener { + if ("enabled" == it.propertyName) { + testServerAction.isEnabled = it.newValue as Boolean } } } @@ -108,7 +115,7 @@ class AemServerEditDialog(private val project: Project, private val tableItem: A return arrayOf(testServerAction, *super.createActions()) } - private fun testServer() { + private fun testConnectionToServer() { val validationInfos = doValidateAll() updateErrorInfo(validationInfos) @@ -143,6 +150,12 @@ class AemServerEditDialog(private val project: Project, private val tableItem: A promise.setError(th) } } + } else { + val firstError = validationInfos.first() + + if (firstError.component?.isVisible == true) { + IdeFocusManager.getInstance(null).requestFocus(firstError.component!!, true) + } } }