Wizard: do not update path & artifactId value for invalid project name

This commit is contained in:
Ilya Kirillov
2020-03-31 20:26:33 +03:00
parent fef3ea573b
commit 487e1ddddc
2 changed files with 8 additions and 2 deletions
@@ -78,8 +78,11 @@ class ProjectSettingsComponent(ideWizard: IdeWizard) : DynamicComponent(ideWizar
super.onValueUpdated(reference)
when (reference?.path) {
StructurePlugin::name.path -> {
tryUpdateLocationByProjectName()
tryArtifactIdByProjectName()
val isNameValid = read { StructurePlugin::name.reference.validate().isOk }
if (isNameValid) {
tryUpdateLocationByProjectName()
tryArtifactIdByProjectName()
}
}
StructurePlugin::artifactId.path -> {
artifactIdWasUpdatedByHand = true
@@ -192,6 +192,9 @@ class Context private constructor(
val <V : Any, T : SettingType<V>> SettingReference<V, T>.setting: Setting<V, T>
get() = with(this) { getSetting() }
fun <V : Any, T : SettingType<V>> SettingReference<V, T>.validate() =
setting.validator.validate(this@Reader, settingValue)
inline operator fun <T> invoke(reader: Reader.() -> T): T = reader()
}