User: rednesto Date: 16 Jul 24 12:20 Revision: 1579723a3f7834ce8f03a090c6f9e06505da71b6 Summary: Move graph and properties map into a CreatorContext Also add WizardContext to it so we can access it anytime This is required for more flexibility and a future change to migrate away from Dispatchers.Swing and possibly remove our bundled coroutines lib TeamCity URL: https://ci.mcdev.io/viewModification.html?tab=vcsModificationFiles&modId=9474&personal=false Index: src/main/kotlin/creator/custom/CreatorContext.kt =================================================================== --- src/main/kotlin/creator/custom/CreatorContext.kt (revision 1579723a3f7834ce8f03a090c6f9e06505da71b6) +++ src/main/kotlin/creator/custom/CreatorContext.kt (revision 1579723a3f7834ce8f03a090c6f9e06505da71b6) @@ -0,0 +1,31 @@ +/* + * Minecraft Development for IntelliJ + * + * https://mcdev.io/ + * + * Copyright (C) 2024 minecraft-dev + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, version 3.0 only. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.demonwav.mcdev.creator.custom + +import com.demonwav.mcdev.creator.custom.types.CreatorProperty +import com.intellij.ide.util.projectWizard.WizardContext +import com.intellij.openapi.observable.properties.PropertyGraph + +data class CreatorContext( + val graph: PropertyGraph, + val properties: Map>, + val wizardContext: WizardContext, +) Index: src/main/kotlin/creator/custom/CustomPlatformStep.kt =================================================================== --- src/main/kotlin/creator/custom/CustomPlatformStep.kt (revision 69241a67289807a8303f679ffeb053382a6ee622) +++ src/main/kotlin/creator/custom/CustomPlatformStep.kt (revision 1579723a3f7834ce8f03a090c6f9e06505da71b6) @@ -120,6 +120,7 @@ private var hasTemplateErrors: Boolean = true private var properties = mutableMapOf>() + private var creatorContext = CreatorContext(propertyGraph, properties, context) override fun setupUI(builder: Panel) { lateinit var templatePropertyPlaceholder: Placeholder @@ -311,6 +312,7 @@ private fun createOptionsPanelInBackground(template: LoadedTemplate, placeholder: Placeholder) { properties = mutableMapOf() + creatorContext = creatorContext.copy(properties = properties) if (!template.isValid) { return @@ -320,8 +322,7 @@ ?: return thisLogger().error("Could not find wizard base data") properties["PROJECT_NAME"] = ExternalCreatorProperty( - graph = propertyGraph, - properties = properties, + context = creatorContext, graphProperty = baseData.nameProperty, valueType = String::class.java ) @@ -421,7 +422,7 @@ reporter.fatal("Duplicate property name ${descriptor.name}") } - val prop = CreatorPropertyFactory.createFromType(descriptor.type, descriptor, propertyGraph, properties) + val prop = CreatorPropertyFactory.createFromType(descriptor.type, descriptor, creatorContext) if (prop == null) { reporter.fatal("Unknown template property type ${descriptor.type}") } @@ -434,7 +435,7 @@ return null } - val factory = Consumer { panel -> prop.buildUi(panel, context) } + val factory = Consumer { panel -> prop.buildUi(panel) } val order = descriptor.order ?: 0 return factory to order } Index: src/main/kotlin/creator/custom/types/ArchitecturyVersionsCreatorProperty.kt =================================================================== --- src/main/kotlin/creator/custom/types/ArchitecturyVersionsCreatorProperty.kt (revision 69241a67289807a8303f679ffeb053382a6ee622) +++ src/main/kotlin/creator/custom/types/ArchitecturyVersionsCreatorProperty.kt (revision 1579723a3f7834ce8f03a090c6f9e06505da71b6) @@ -24,6 +24,7 @@ import com.demonwav.mcdev.asset.MCDevBundle.invoke import com.demonwav.mcdev.creator.collectMavenVersions import com.demonwav.mcdev.creator.custom.BuiltinValidations +import com.demonwav.mcdev.creator.custom.CreatorContext import com.demonwav.mcdev.creator.custom.TemplateEvaluator import com.demonwav.mcdev.creator.custom.TemplatePropertyDescriptor import com.demonwav.mcdev.creator.custom.TemplateValidationReporter @@ -35,9 +36,7 @@ import com.demonwav.mcdev.platform.neoforge.version.NeoForgeVersion import com.demonwav.mcdev.util.SemanticVersion import com.demonwav.mcdev.util.asyncIO -import com.intellij.ide.util.projectWizard.WizardContext import com.intellij.openapi.observable.properties.GraphProperty -import com.intellij.openapi.observable.properties.PropertyGraph import com.intellij.openapi.observable.util.not import com.intellij.openapi.observable.util.transform import com.intellij.ui.ComboboxSpeedSearch @@ -56,9 +55,8 @@ class ArchitecturyVersionsCreatorProperty( descriptor: TemplatePropertyDescriptor, - graph: PropertyGraph, - properties: Map> -) : CreatorProperty(descriptor, graph, properties, ArchitecturyVersionsModel::class.java) { + context: CreatorContext +) : CreatorProperty(descriptor, context, ArchitecturyVersionsModel::class.java) { private val emptyVersion = SemanticVersion.release() private val emptyValue = ArchitecturyVersionsModel( @@ -164,7 +162,7 @@ ) } - override fun buildUi(panel: Panel, context: WizardContext) { + override fun buildUi(panel: Panel) { panel.row("") { cell(AsyncProcessIcon("ArchitecturyVersions download")) label(MCDevBundle("creator.ui.versions_download.label")) @@ -474,8 +472,7 @@ override fun create( descriptor: TemplatePropertyDescriptor, - graph: PropertyGraph, - properties: Map> - ): CreatorProperty<*> = ArchitecturyVersionsCreatorProperty(descriptor, graph, properties) + context: CreatorContext + ): CreatorProperty<*> = ArchitecturyVersionsCreatorProperty(descriptor, context) } } Index: src/main/kotlin/creator/custom/types/BooleanCreatorProperty.kt =================================================================== --- src/main/kotlin/creator/custom/types/BooleanCreatorProperty.kt (revision 69241a67289807a8303f679ffeb053382a6ee622) +++ src/main/kotlin/creator/custom/types/BooleanCreatorProperty.kt (revision 1579723a3f7834ce8f03a090c6f9e06505da71b6) @@ -20,10 +20,9 @@ package com.demonwav.mcdev.creator.custom.types +import com.demonwav.mcdev.creator.custom.CreatorContext import com.demonwav.mcdev.creator.custom.TemplatePropertyDescriptor import com.intellij.icons.AllIcons -import com.intellij.ide.util.projectWizard.WizardContext -import com.intellij.openapi.observable.properties.PropertyGraph import com.intellij.ui.content.AlertIcon import com.intellij.ui.dsl.builder.Panel import com.intellij.ui.dsl.builder.RightGap @@ -31,9 +30,8 @@ class BooleanCreatorProperty( descriptor: TemplatePropertyDescriptor, - graph: PropertyGraph, - properties: Map> -) : SimpleCreatorProperty(descriptor, graph, properties, Boolean::class.java) { + context: CreatorContext +) : SimpleCreatorProperty(descriptor, context, Boolean::class.java) { override fun createDefaultValue(raw: Any?): Boolean = raw as? Boolean ?: false @@ -41,7 +39,7 @@ override fun deserialize(string: String): Boolean = string.toBoolean() - override fun buildSimpleUi(panel: Panel, context: WizardContext) { + override fun buildSimpleUi(panel: Panel) { val label = descriptor.translatedLabel panel.row(label) { val warning = descriptor.translatedWarning @@ -60,8 +58,7 @@ class Factory : CreatorPropertyFactory { override fun create( descriptor: TemplatePropertyDescriptor, - graph: PropertyGraph, - properties: Map> - ): CreatorProperty<*> = BooleanCreatorProperty(descriptor, graph, properties) + context: CreatorContext + ): CreatorProperty<*> = BooleanCreatorProperty(descriptor, context) } } Index: src/main/kotlin/creator/custom/types/BuildSystemCoordinatesCreatorProperty.kt =================================================================== --- src/main/kotlin/creator/custom/types/BuildSystemCoordinatesCreatorProperty.kt (revision 69241a67289807a8303f679ffeb053382a6ee622) +++ src/main/kotlin/creator/custom/types/BuildSystemCoordinatesCreatorProperty.kt (revision 1579723a3f7834ce8f03a090c6f9e06505da71b6) @@ -22,12 +22,11 @@ import com.demonwav.mcdev.asset.MCDevBundle import com.demonwav.mcdev.creator.custom.BuiltinValidations +import com.demonwav.mcdev.creator.custom.CreatorContext import com.demonwav.mcdev.creator.custom.TemplatePropertyDescriptor import com.demonwav.mcdev.creator.custom.TemplateValidationReporter import com.demonwav.mcdev.creator.custom.model.BuildSystemCoordinates -import com.intellij.ide.util.projectWizard.WizardContext import com.intellij.openapi.observable.properties.GraphProperty -import com.intellij.openapi.observable.properties.PropertyGraph import com.intellij.openapi.observable.util.transform import com.intellij.openapi.ui.validation.CHECK_ARTIFACT_ID import com.intellij.openapi.ui.validation.CHECK_GROUP_ID @@ -46,9 +45,8 @@ class BuildSystemCoordinatesCreatorProperty( descriptor: TemplatePropertyDescriptor, - graph: PropertyGraph, - properties: Map> -) : CreatorProperty(descriptor, graph, properties, BuildSystemCoordinates::class.java) { + context: CreatorContext +) : CreatorProperty(descriptor, context, BuildSystemCoordinates::class.java) { private val default = createDefaultValue(descriptor.default) @@ -99,7 +97,7 @@ } } - override fun buildUi(panel: Panel, context: WizardContext) { + override fun buildUi(panel: Panel) { panel.collapsibleGroup(MCDevBundle("creator.ui.group.title")) { this.row(MCDevBundle("creator.ui.group.group_id")) { this.textField() @@ -128,8 +126,7 @@ class Factory : CreatorPropertyFactory { override fun create( descriptor: TemplatePropertyDescriptor, - graph: PropertyGraph, - properties: Map> - ): CreatorProperty<*> = BuildSystemCoordinatesCreatorProperty(descriptor, graph, properties) + context: CreatorContext + ): CreatorProperty<*> = BuildSystemCoordinatesCreatorProperty(descriptor, context) } } Index: src/main/kotlin/creator/custom/types/ClassFqnCreatorProperty.kt =================================================================== --- src/main/kotlin/creator/custom/types/ClassFqnCreatorProperty.kt (revision 69241a67289807a8303f679ffeb053382a6ee622) +++ src/main/kotlin/creator/custom/types/ClassFqnCreatorProperty.kt (revision 1579723a3f7834ce8f03a090c6f9e06505da71b6) @@ -21,14 +21,13 @@ package com.demonwav.mcdev.creator.custom.types import com.demonwav.mcdev.creator.custom.BuiltinValidations +import com.demonwav.mcdev.creator.custom.CreatorContext import com.demonwav.mcdev.creator.custom.PropertyDerivation import com.demonwav.mcdev.creator.custom.TemplatePropertyDescriptor import com.demonwav.mcdev.creator.custom.TemplateValidationReporter import com.demonwav.mcdev.creator.custom.derivation.PreparedDerivation import com.demonwav.mcdev.creator.custom.derivation.SuggestClassNamePropertyDerivation import com.demonwav.mcdev.creator.custom.model.ClassFqn -import com.intellij.ide.util.projectWizard.WizardContext -import com.intellij.openapi.observable.properties.PropertyGraph import com.intellij.ui.dsl.builder.COLUMNS_LARGE import com.intellij.ui.dsl.builder.Panel import com.intellij.ui.dsl.builder.bindText @@ -37,9 +36,8 @@ class ClassFqnCreatorProperty( descriptor: TemplatePropertyDescriptor, - graph: PropertyGraph, - properties: Map> -) : SimpleCreatorProperty(descriptor, graph, properties, ClassFqn::class.java) { + context: CreatorContext +) : SimpleCreatorProperty(descriptor, context, ClassFqn::class.java) { override fun createDefaultValue(raw: Any?): ClassFqn = ClassFqn(raw as? String ?: "") @@ -47,7 +45,7 @@ override fun deserialize(string: String): ClassFqn = ClassFqn(string) - override fun buildSimpleUi(panel: Panel, context: WizardContext) { + override fun buildSimpleUi(panel: Panel) { panel.row(descriptor.translatedLabel) { this.textField().bindText(this@ClassFqnCreatorProperty.toStringProperty(graphProperty)) .columns(COLUMNS_LARGE) @@ -71,8 +69,7 @@ class Factory : CreatorPropertyFactory { override fun create( descriptor: TemplatePropertyDescriptor, - graph: PropertyGraph, - properties: Map> - ): CreatorProperty<*> = ClassFqnCreatorProperty(descriptor, graph, properties) + context: CreatorContext + ): CreatorProperty<*> = ClassFqnCreatorProperty(descriptor, context) } } Index: src/main/kotlin/creator/custom/types/CreatorProperty.kt =================================================================== --- src/main/kotlin/creator/custom/types/CreatorProperty.kt (revision 69241a67289807a8303f679ffeb053382a6ee622) +++ src/main/kotlin/creator/custom/types/CreatorProperty.kt (revision 1579723a3f7834ce8f03a090c6f9e06505da71b6) @@ -20,6 +20,7 @@ package com.demonwav.mcdev.creator.custom.types +import com.demonwav.mcdev.creator.custom.CreatorContext import com.demonwav.mcdev.creator.custom.PropertyDerivation import com.demonwav.mcdev.creator.custom.TemplateEvaluator import com.demonwav.mcdev.creator.custom.TemplatePropertyDescriptor @@ -38,10 +39,18 @@ abstract class CreatorProperty( val descriptor: TemplatePropertyDescriptor, - val graph: PropertyGraph, - protected val properties: Map>, + protected val context: CreatorContext, val valueType: Class ) { + protected val graph: PropertyGraph + get() = context.graph + + protected val properties + get() = context.properties + + protected val wizardContext: WizardContext + get() = context.wizardContext + private var derivation: PreparedDerivation? = null private lateinit var visibleProperty: GraphProperty @@ -95,7 +104,7 @@ protected open fun convertSelectDerivationResult(original: Any?): Any? = original - abstract fun buildUi(panel: Panel, context: WizardContext) + abstract fun buildUi(panel: Panel) /** * Prepares everything this property needs, like calling [GraphProperty]'s [GraphProperty.afterChange] and Index: src/main/kotlin/creator/custom/types/CreatorPropertyFactory.kt =================================================================== --- src/main/kotlin/creator/custom/types/CreatorPropertyFactory.kt (revision 69241a67289807a8303f679ffeb053382a6ee622) +++ src/main/kotlin/creator/custom/types/CreatorPropertyFactory.kt (revision 1579723a3f7834ce8f03a090c6f9e06505da71b6) @@ -20,10 +20,10 @@ package com.demonwav.mcdev.creator.custom.types +import com.demonwav.mcdev.creator.custom.CreatorContext import com.demonwav.mcdev.creator.custom.TemplatePropertyDescriptor import com.intellij.openapi.extensions.ExtensionPointName import com.intellij.openapi.extensions.RequiredElement -import com.intellij.openapi.observable.properties.PropertyGraph import com.intellij.openapi.util.KeyedExtensionCollector import com.intellij.serviceContainer.BaseKeyedLazyInstance import com.intellij.util.KeyedLazyInstance @@ -42,18 +42,13 @@ fun createFromType( type: String, descriptor: TemplatePropertyDescriptor, - graph: PropertyGraph, - properties: Map> + context: CreatorContext ): CreatorProperty<*>? { - return COLLECTOR.findSingle(type)?.create(descriptor, graph, properties) + return COLLECTOR.findSingle(type)?.create(descriptor, context) } } - fun create( - descriptor: TemplatePropertyDescriptor, - graph: PropertyGraph, - properties: Map> - ): CreatorProperty<*> + fun create(descriptor: TemplatePropertyDescriptor, context: CreatorContext): CreatorProperty<*> } class CreatorPropertyFactoryBean : Index: src/main/kotlin/creator/custom/types/ExternalCreatorProperty.kt =================================================================== --- src/main/kotlin/creator/custom/types/ExternalCreatorProperty.kt (revision 69241a67289807a8303f679ffeb053382a6ee622) +++ src/main/kotlin/creator/custom/types/ExternalCreatorProperty.kt (revision 1579723a3f7834ce8f03a090c6f9e06505da71b6) @@ -20,20 +20,18 @@ package com.demonwav.mcdev.creator.custom.types +import com.demonwav.mcdev.creator.custom.CreatorContext import com.demonwav.mcdev.creator.custom.TemplatePropertyDescriptor import com.demonwav.mcdev.creator.custom.TemplateValidationReporter -import com.intellij.ide.util.projectWizard.WizardContext import com.intellij.openapi.observable.properties.GraphProperty -import com.intellij.openapi.observable.properties.PropertyGraph import com.intellij.ui.dsl.builder.Panel class ExternalCreatorProperty( descriptor: TemplatePropertyDescriptor = TemplatePropertyDescriptor("", "", "", default = ""), - graph: PropertyGraph, - properties: Map>, + context: CreatorContext, override val graphProperty: GraphProperty, valueType: Class, -) : CreatorProperty(descriptor, graph, properties, valueType) { +) : CreatorProperty(descriptor, context, valueType) { override fun setupProperty(reporter: TemplateValidationReporter) = Unit @@ -46,5 +44,5 @@ override fun deserialize(string: String): T = throw UnsupportedOperationException("Unsupported for external properties") - override fun buildUi(panel: Panel, context: WizardContext) = Unit + override fun buildUi(panel: Panel) = Unit } Index: src/main/kotlin/creator/custom/types/FabricVersionsCreatorProperty.kt =================================================================== --- src/main/kotlin/creator/custom/types/FabricVersionsCreatorProperty.kt (revision 69241a67289807a8303f679ffeb053382a6ee622) +++ src/main/kotlin/creator/custom/types/FabricVersionsCreatorProperty.kt (revision 1579723a3f7834ce8f03a090c6f9e06505da71b6) @@ -23,6 +23,7 @@ import com.demonwav.mcdev.asset.MCDevBundle import com.demonwav.mcdev.creator.collectMavenVersions import com.demonwav.mcdev.creator.custom.BuiltinValidations +import com.demonwav.mcdev.creator.custom.CreatorContext import com.demonwav.mcdev.creator.custom.TemplatePropertyDescriptor import com.demonwav.mcdev.creator.custom.TemplateValidationReporter import com.demonwav.mcdev.creator.custom.model.FabricVersionsModel @@ -30,9 +31,7 @@ import com.demonwav.mcdev.platform.fabric.util.FabricVersions import com.demonwav.mcdev.util.SemanticVersion import com.demonwav.mcdev.util.asyncIO -import com.intellij.ide.util.projectWizard.WizardContext import com.intellij.openapi.observable.properties.GraphProperty -import com.intellij.openapi.observable.properties.PropertyGraph import com.intellij.openapi.observable.util.bindBooleanStorage import com.intellij.openapi.observable.util.not import com.intellij.openapi.observable.util.transform @@ -53,9 +52,8 @@ class FabricVersionsCreatorProperty( descriptor: TemplatePropertyDescriptor, - graph: PropertyGraph, - properties: Map> -) : CreatorProperty(descriptor, graph, properties, FabricVersionsModel::class.java) { + context: CreatorContext +) : CreatorProperty(descriptor, context, FabricVersionsModel::class.java) { private val emptyVersion = SemanticVersion.release() private val emptyValue = FabricVersionsModel( @@ -135,7 +133,7 @@ ) } - override fun buildUi(panel: Panel, context: WizardContext) { + override fun buildUi(panel: Panel) { panel.row("") { cell(AsyncProcessIcon("FabricVersions download")) label(MCDevBundle("creator.ui.versions_download.label")) @@ -343,8 +341,7 @@ override fun create( descriptor: TemplatePropertyDescriptor, - graph: PropertyGraph, - properties: Map> - ): CreatorProperty<*> = FabricVersionsCreatorProperty(descriptor, graph, properties) + context: CreatorContext + ): CreatorProperty<*> = FabricVersionsCreatorProperty(descriptor, context) } } Index: src/main/kotlin/creator/custom/types/ForgeVersionsCreatorProperty.kt =================================================================== --- src/main/kotlin/creator/custom/types/ForgeVersionsCreatorProperty.kt (revision 69241a67289807a8303f679ffeb053382a6ee622) +++ src/main/kotlin/creator/custom/types/ForgeVersionsCreatorProperty.kt (revision 1579723a3f7834ce8f03a090c6f9e06505da71b6) @@ -22,15 +22,14 @@ import com.demonwav.mcdev.asset.MCDevBundle import com.demonwav.mcdev.creator.custom.BuiltinValidations +import com.demonwav.mcdev.creator.custom.CreatorContext import com.demonwav.mcdev.creator.custom.TemplateEvaluator import com.demonwav.mcdev.creator.custom.TemplatePropertyDescriptor import com.demonwav.mcdev.creator.custom.TemplateValidationReporter import com.demonwav.mcdev.creator.custom.model.ForgeVersions import com.demonwav.mcdev.platform.forge.version.ForgeVersion import com.demonwav.mcdev.util.SemanticVersion -import com.intellij.ide.util.projectWizard.WizardContext import com.intellij.openapi.observable.properties.GraphProperty -import com.intellij.openapi.observable.properties.PropertyGraph import com.intellij.openapi.observable.util.not import com.intellij.openapi.observable.util.transform import com.intellij.ui.ComboboxSpeedSearch @@ -40,7 +39,6 @@ import com.intellij.util.application import com.intellij.util.ui.AsyncProcessIcon import javax.swing.DefaultComboBoxModel -import kotlin.collections.Map import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.runBlocking import kotlinx.coroutines.swing.Swing @@ -48,9 +46,8 @@ class ForgeVersionsCreatorProperty( descriptor: TemplatePropertyDescriptor, - graph: PropertyGraph, - properties: Map> -) : CreatorProperty(descriptor, graph, properties, ForgeVersions::class.java) { + context: CreatorContext +) : CreatorProperty(descriptor, context, ForgeVersions::class.java) { private val emptyVersion = SemanticVersion.release() @@ -92,7 +89,7 @@ ) } - override fun buildUi(panel: Panel, context: WizardContext) { + override fun buildUi(panel: Panel) { panel.row("") { cell(AsyncProcessIcon("ForgeVersions download")) label(MCDevBundle("creator.ui.versions_download.label")) @@ -212,8 +209,7 @@ class Factory : CreatorPropertyFactory { override fun create( descriptor: TemplatePropertyDescriptor, - graph: PropertyGraph, - properties: Map> - ): CreatorProperty<*> = ForgeVersionsCreatorProperty(descriptor, graph, properties) + context: CreatorContext + ): CreatorProperty<*> = ForgeVersionsCreatorProperty(descriptor, context) } } Index: src/main/kotlin/creator/custom/types/InlineStringListCreatorProperty.kt =================================================================== --- src/main/kotlin/creator/custom/types/InlineStringListCreatorProperty.kt (revision 69241a67289807a8303f679ffeb053382a6ee622) +++ src/main/kotlin/creator/custom/types/InlineStringListCreatorProperty.kt (revision 1579723a3f7834ce8f03a090c6f9e06505da71b6) @@ -20,10 +20,9 @@ package com.demonwav.mcdev.creator.custom.types +import com.demonwav.mcdev.creator.custom.CreatorContext import com.demonwav.mcdev.creator.custom.TemplatePropertyDescriptor import com.demonwav.mcdev.creator.custom.model.StringList -import com.intellij.ide.util.projectWizard.WizardContext -import com.intellij.openapi.observable.properties.PropertyGraph import com.intellij.ui.dsl.builder.COLUMNS_LARGE import com.intellij.ui.dsl.builder.Panel import com.intellij.ui.dsl.builder.bindText @@ -31,9 +30,8 @@ class InlineStringListCreatorProperty( descriptor: TemplatePropertyDescriptor, - graph: PropertyGraph, - properties: Map> -) : SimpleCreatorProperty(descriptor, graph, properties, StringList::class.java) { + context: CreatorContext +) : SimpleCreatorProperty(descriptor, context, StringList::class.java) { override fun createDefaultValue(raw: Any?): StringList = deserialize(raw as? String ?: "") @@ -44,7 +42,7 @@ .filter(String::isNotBlank) .run(::StringList) - override fun buildSimpleUi(panel: Panel, context: WizardContext) { + override fun buildSimpleUi(panel: Panel) { panel.row(descriptor.translatedLabel) { this.textField().bindText(this@InlineStringListCreatorProperty.toStringProperty(graphProperty)) .columns(COLUMNS_LARGE) @@ -55,8 +53,7 @@ class Factory : CreatorPropertyFactory { override fun create( descriptor: TemplatePropertyDescriptor, - graph: PropertyGraph, - properties: Map> - ): CreatorProperty<*> = InlineStringListCreatorProperty(descriptor, graph, properties) + context: CreatorContext + ): CreatorProperty<*> = InlineStringListCreatorProperty(descriptor, context) } } Index: src/main/kotlin/creator/custom/types/IntegerCreatorProperty.kt =================================================================== --- src/main/kotlin/creator/custom/types/IntegerCreatorProperty.kt (revision 69241a67289807a8303f679ffeb053382a6ee622) +++ src/main/kotlin/creator/custom/types/IntegerCreatorProperty.kt (revision 1579723a3f7834ce8f03a090c6f9e06505da71b6) @@ -20,14 +20,13 @@ package com.demonwav.mcdev.creator.custom.types +import com.demonwav.mcdev.creator.custom.CreatorContext import com.demonwav.mcdev.creator.custom.PropertyDerivation import com.demonwav.mcdev.creator.custom.TemplatePropertyDescriptor import com.demonwav.mcdev.creator.custom.TemplateValidationReporter import com.demonwav.mcdev.creator.custom.derivation.PreparedDerivation import com.demonwav.mcdev.creator.custom.derivation.RecommendJavaVersionForMcVersionPropertyDerivation import com.demonwav.mcdev.creator.custom.derivation.SelectPropertyDerivation -import com.intellij.ide.util.projectWizard.WizardContext -import com.intellij.openapi.observable.properties.PropertyGraph import com.intellij.ui.dsl.builder.COLUMNS_LARGE import com.intellij.ui.dsl.builder.Panel import com.intellij.ui.dsl.builder.bindIntText @@ -35,9 +34,8 @@ class IntegerCreatorProperty( descriptor: TemplatePropertyDescriptor, - graph: PropertyGraph, - properties: Map> -) : SimpleCreatorProperty(descriptor, graph, properties, Int::class.java) { + context: CreatorContext +) : SimpleCreatorProperty(descriptor, context, Int::class.java) { override fun createDefaultValue(raw: Any?): Int = (raw as? Number)?.toInt() ?: 0 @@ -47,7 +45,7 @@ override fun convertSelectDerivationResult(original: Any?): Any? = (original as? Number)?.toInt() - override fun buildSimpleUi(panel: Panel, context: WizardContext) { + override fun buildSimpleUi(panel: Panel) { panel.row(descriptor.translatedLabel) { this.intTextField().bindIntText(graphProperty) .columns(COLUMNS_LARGE) @@ -75,8 +73,7 @@ class Factory : CreatorPropertyFactory { override fun create( descriptor: TemplatePropertyDescriptor, - graph: PropertyGraph, - properties: Map> - ): CreatorProperty<*> = IntegerCreatorProperty(descriptor, graph, properties) + context: CreatorContext + ): CreatorProperty<*> = IntegerCreatorProperty(descriptor, context) } } Index: src/main/kotlin/creator/custom/types/JdkCreatorProperty.kt =================================================================== --- src/main/kotlin/creator/custom/types/JdkCreatorProperty.kt (revision 69241a67289807a8303f679ffeb053382a6ee622) +++ src/main/kotlin/creator/custom/types/JdkCreatorProperty.kt (revision 1579723a3f7834ce8f03a090c6f9e06505da71b6) @@ -21,11 +21,10 @@ package com.demonwav.mcdev.creator.custom.types import com.demonwav.mcdev.creator.JdkComboBoxWithPreference +import com.demonwav.mcdev.creator.custom.CreatorContext import com.demonwav.mcdev.creator.custom.TemplatePropertyDescriptor import com.demonwav.mcdev.creator.custom.model.CreatorJdk import com.demonwav.mcdev.creator.jdkComboBoxWithPreference -import com.intellij.ide.util.projectWizard.WizardContext -import com.intellij.openapi.observable.properties.PropertyGraph import com.intellij.openapi.observable.util.transform import com.intellij.openapi.projectRoots.JavaSdkVersion import com.intellij.openapi.projectRoots.ProjectJdkTable @@ -33,9 +32,8 @@ class JdkCreatorProperty( descriptor: TemplatePropertyDescriptor, - graph: PropertyGraph, - properties: Map> -) : SimpleCreatorProperty(descriptor, graph, properties, CreatorJdk::class.java) { + context: CreatorContext +) : SimpleCreatorProperty(descriptor, context, CreatorJdk::class.java) { private lateinit var jdkComboBox: JdkComboBoxWithPreference @@ -46,10 +44,10 @@ override fun deserialize(string: String): CreatorJdk = CreatorJdk(ProjectJdkTable.getInstance().allJdks.find { it.homePath == string }) - override fun buildSimpleUi(panel: Panel, context: WizardContext) { + override fun buildSimpleUi(panel: Panel) { panel.row(descriptor.translatedLabel) { val sdkProperty = graphProperty.transform(CreatorJdk::sdk, ::CreatorJdk) - jdkComboBox = this.jdkComboBoxWithPreference(context, sdkProperty, descriptor.name).component + jdkComboBox = this.jdkComboBoxWithPreference(wizardContext, sdkProperty, descriptor.name).component val minVersionPropName = descriptor.default as? String if (minVersionPropName != null) { @@ -70,8 +68,7 @@ class Factory : CreatorPropertyFactory { override fun create( descriptor: TemplatePropertyDescriptor, - graph: PropertyGraph, - properties: Map> - ): CreatorProperty<*> = JdkCreatorProperty(descriptor, graph, properties) + context: CreatorContext + ): CreatorProperty<*> = JdkCreatorProperty(descriptor, context) } } Index: src/main/kotlin/creator/custom/types/LicenseCreatorProperty.kt =================================================================== --- src/main/kotlin/creator/custom/types/LicenseCreatorProperty.kt (revision 69241a67289807a8303f679ffeb053382a6ee622) +++ src/main/kotlin/creator/custom/types/LicenseCreatorProperty.kt (revision 1579723a3f7834ce8f03a090c6f9e06505da71b6) @@ -20,12 +20,11 @@ package com.demonwav.mcdev.creator.custom.types +import com.demonwav.mcdev.creator.custom.CreatorContext import com.demonwav.mcdev.creator.custom.TemplatePropertyDescriptor import com.demonwav.mcdev.creator.custom.model.LicenseData import com.demonwav.mcdev.util.License -import com.intellij.ide.util.projectWizard.WizardContext import com.intellij.openapi.observable.properties.GraphProperty -import com.intellij.openapi.observable.properties.PropertyGraph import com.intellij.openapi.observable.util.transform import com.intellij.ui.ComboboxSpeedSearch import com.intellij.ui.EnumComboBoxModel @@ -35,9 +34,8 @@ class LicenseCreatorProperty( descriptor: TemplatePropertyDescriptor, - graph: PropertyGraph, - properties: Map> -) : CreatorProperty(descriptor, graph, properties, LicenseData::class.java) { + context: CreatorContext +) : CreatorProperty(descriptor, context, LicenseData::class.java) { override val graphProperty: GraphProperty = graph.property(createDefaultValue(descriptor.default)) @@ -50,7 +48,7 @@ override fun deserialize(string: String): LicenseData = LicenseData(string, License.byId(string)?.toString() ?: string, ZonedDateTime.now().year.toString()) - override fun buildUi(panel: Panel, context: WizardContext) { + override fun buildUi(panel: Panel) { panel.row(descriptor.translatedLabel) { val model = EnumComboBoxModel(License::class.java) val licenseEnumProperty = graphProperty.transform( @@ -67,8 +65,7 @@ override fun create( descriptor: TemplatePropertyDescriptor, - graph: PropertyGraph, - properties: Map> - ): CreatorProperty<*> = LicenseCreatorProperty(descriptor, graph, properties) + context: CreatorContext + ): CreatorProperty<*> = LicenseCreatorProperty(descriptor, context) } } Index: src/main/kotlin/creator/custom/types/MavenArtifactVersionCreatorProperty.kt =================================================================== --- src/main/kotlin/creator/custom/types/MavenArtifactVersionCreatorProperty.kt (revision 69241a67289807a8303f679ffeb053382a6ee622) +++ src/main/kotlin/creator/custom/types/MavenArtifactVersionCreatorProperty.kt (revision 1579723a3f7834ce8f03a090c6f9e06505da71b6) @@ -21,15 +21,14 @@ package com.demonwav.mcdev.creator.custom.types import com.demonwav.mcdev.creator.collectMavenVersions +import com.demonwav.mcdev.creator.custom.CreatorContext import com.demonwav.mcdev.creator.custom.TemplateEvaluator import com.demonwav.mcdev.creator.custom.TemplatePropertyDescriptor import com.demonwav.mcdev.creator.custom.TemplateValidationReporter import com.demonwav.mcdev.util.SemanticVersion -import com.intellij.ide.util.projectWizard.WizardContext import com.intellij.openapi.diagnostic.getOrLogException import com.intellij.openapi.diagnostic.thisLogger import com.intellij.openapi.observable.properties.GraphProperty -import com.intellij.openapi.observable.properties.PropertyGraph import com.intellij.ui.ComboboxSpeedSearch import com.intellij.ui.dsl.builder.Panel import com.intellij.ui.dsl.builder.bindItem @@ -43,9 +42,8 @@ class MavenArtifactVersionCreatorProperty( descriptor: TemplatePropertyDescriptor, - graph: PropertyGraph, - properties: Map> -) : SemanticVersionCreatorProperty(descriptor, graph, properties) { + context: CreatorContext +) : SemanticVersionCreatorProperty(descriptor, context) { lateinit var sourceUrl: String var rawVersionFilter: (String) -> Boolean = { true } @@ -55,7 +53,7 @@ private val versionsProperty = graph.property>(emptyList()) private val loadingVersionsProperty = graph.property(true) - override fun buildUi(panel: Panel, context: WizardContext) { + override fun buildUi(panel: Panel) { panel.row(descriptor.translatedLabel) { val combobox = comboBox(versionsProperty.get()) .bindItem(graphProperty) @@ -170,8 +168,7 @@ override fun create( descriptor: TemplatePropertyDescriptor, - graph: PropertyGraph, - properties: Map> - ): CreatorProperty<*> = MavenArtifactVersionCreatorProperty(descriptor, graph, properties) + context: CreatorContext + ): CreatorProperty<*> = MavenArtifactVersionCreatorProperty(descriptor, context) } } Index: src/main/kotlin/creator/custom/types/NeoForgeVersionsCreatorProperty.kt =================================================================== --- src/main/kotlin/creator/custom/types/NeoForgeVersionsCreatorProperty.kt (revision 69241a67289807a8303f679ffeb053382a6ee622) +++ src/main/kotlin/creator/custom/types/NeoForgeVersionsCreatorProperty.kt (revision 1579723a3f7834ce8f03a090c6f9e06505da71b6) @@ -22,6 +22,7 @@ import com.demonwav.mcdev.asset.MCDevBundle import com.demonwav.mcdev.creator.custom.BuiltinValidations +import com.demonwav.mcdev.creator.custom.CreatorContext import com.demonwav.mcdev.creator.custom.TemplateEvaluator import com.demonwav.mcdev.creator.custom.TemplatePropertyDescriptor import com.demonwav.mcdev.creator.custom.TemplateValidationReporter @@ -31,9 +32,7 @@ import com.demonwav.mcdev.platform.neoforge.version.platform.neoforge.version.NeoModDevVersion import com.demonwav.mcdev.util.SemanticVersion import com.demonwav.mcdev.util.asyncIO -import com.intellij.ide.util.projectWizard.WizardContext import com.intellij.openapi.observable.properties.GraphProperty -import com.intellij.openapi.observable.properties.PropertyGraph import com.intellij.openapi.observable.util.not import com.intellij.openapi.observable.util.transform import com.intellij.ui.ComboboxSpeedSearch @@ -51,9 +50,8 @@ class NeoForgeVersionsCreatorProperty( descriptor: TemplatePropertyDescriptor, - graph: PropertyGraph, - properties: Map> -) : CreatorProperty(descriptor, graph, properties, NeoForgeVersions::class.java) { + context: CreatorContext +) : CreatorProperty(descriptor, context, NeoForgeVersions::class.java) { private val emptyVersion = SemanticVersion.release() @@ -97,7 +95,7 @@ ) } - override fun buildUi(panel: Panel, context: WizardContext) { + override fun buildUi(panel: Panel) { panel.row("") { cell(AsyncProcessIcon("NeoForgeVersions download")) label(MCDevBundle("creator.ui.versions_download.label")) @@ -204,8 +202,7 @@ class Factory : CreatorPropertyFactory { override fun create( descriptor: TemplatePropertyDescriptor, - graph: PropertyGraph, - properties: Map> - ): CreatorProperty<*> = NeoForgeVersionsCreatorProperty(descriptor, graph, properties) + context: CreatorContext + ): CreatorProperty<*> = NeoForgeVersionsCreatorProperty(descriptor, context) } } Index: src/main/kotlin/creator/custom/types/ParchmentCreatorProperty.kt =================================================================== --- src/main/kotlin/creator/custom/types/ParchmentCreatorProperty.kt (revision 69241a67289807a8303f679ffeb053382a6ee622) +++ src/main/kotlin/creator/custom/types/ParchmentCreatorProperty.kt (revision 1579723a3f7834ce8f03a090c6f9e06505da71b6) @@ -22,14 +22,13 @@ import com.demonwav.mcdev.creator.ParchmentVersion import com.demonwav.mcdev.creator.custom.BuiltinValidations +import com.demonwav.mcdev.creator.custom.CreatorContext import com.demonwav.mcdev.creator.custom.TemplatePropertyDescriptor import com.demonwav.mcdev.creator.custom.TemplateValidationReporter import com.demonwav.mcdev.creator.custom.model.HasMinecraftVersion import com.demonwav.mcdev.creator.custom.model.ParchmentVersions import com.demonwav.mcdev.util.SemanticVersion -import com.intellij.ide.util.projectWizard.WizardContext import com.intellij.openapi.observable.properties.GraphProperty -import com.intellij.openapi.observable.properties.PropertyGraph import com.intellij.openapi.observable.util.transform import com.intellij.ui.ComboboxSpeedSearch import com.intellij.ui.dsl.builder.Panel @@ -44,9 +43,8 @@ class ParchmentCreatorProperty( descriptor: TemplatePropertyDescriptor, - graph: PropertyGraph, - properties: Map> -) : CreatorProperty(descriptor, graph, properties, ParchmentVersions::class.java) { + context: CreatorContext +) : CreatorProperty(descriptor, context, ParchmentVersions::class.java) { private val emptyVersion = SemanticVersion.release() @@ -92,7 +90,7 @@ ) } - override fun buildUi(panel: Panel, context: WizardContext) { + override fun buildUi(panel: Panel) { panel.row(descriptor.translatedLabel) { checkBox("Use Parchment") .bindSelected(useParchmentProperty) @@ -274,8 +272,7 @@ class Factory : CreatorPropertyFactory { override fun create( descriptor: TemplatePropertyDescriptor, - graph: PropertyGraph, - properties: Map> - ): CreatorProperty<*> = ParchmentCreatorProperty(descriptor, graph, properties) + context: CreatorContext + ): CreatorProperty<*> = ParchmentCreatorProperty(descriptor, context) } } Index: src/main/kotlin/creator/custom/types/SemanticVersionCreatorProperty.kt =================================================================== --- src/main/kotlin/creator/custom/types/SemanticVersionCreatorProperty.kt (revision 69241a67289807a8303f679ffeb053382a6ee622) +++ src/main/kotlin/creator/custom/types/SemanticVersionCreatorProperty.kt (revision 1579723a3f7834ce8f03a090c6f9e06505da71b6) @@ -20,6 +20,7 @@ package com.demonwav.mcdev.creator.custom.types +import com.demonwav.mcdev.creator.custom.CreatorContext import com.demonwav.mcdev.creator.custom.PropertyDerivation import com.demonwav.mcdev.creator.custom.TemplatePropertyDescriptor import com.demonwav.mcdev.creator.custom.TemplateValidationReporter @@ -27,8 +28,6 @@ import com.demonwav.mcdev.creator.custom.derivation.PreparedDerivation import com.demonwav.mcdev.creator.custom.derivation.SelectPropertyDerivation import com.demonwav.mcdev.util.SemanticVersion -import com.intellij.ide.util.projectWizard.WizardContext -import com.intellij.openapi.observable.properties.PropertyGraph import com.intellij.ui.dsl.builder.COLUMNS_SHORT import com.intellij.ui.dsl.builder.Panel import com.intellij.ui.dsl.builder.bindText @@ -36,9 +35,8 @@ open class SemanticVersionCreatorProperty( descriptor: TemplatePropertyDescriptor, - graph: PropertyGraph, - properties: Map> -) : SimpleCreatorProperty(descriptor, graph, properties, SemanticVersion::class.java) { + context: CreatorContext +) : SimpleCreatorProperty(descriptor, context, SemanticVersion::class.java) { override fun createDefaultValue(raw: Any?): SemanticVersion = SemanticVersion.tryParse(raw as? String ?: "") ?: SemanticVersion(emptyList()) @@ -48,7 +46,7 @@ override fun deserialize(string: String): SemanticVersion = SemanticVersion.tryParse(string) ?: SemanticVersion(emptyList()) - override fun buildSimpleUi(panel: Panel, context: WizardContext) { + override fun buildSimpleUi(panel: Panel) { panel.row(descriptor.translatedLabel) { this.textField().bindText(this@SemanticVersionCreatorProperty.toStringProperty(graphProperty)) .columns(COLUMNS_SHORT) @@ -79,8 +77,7 @@ class Factory : CreatorPropertyFactory { override fun create( descriptor: TemplatePropertyDescriptor, - graph: PropertyGraph, - properties: Map> - ): CreatorProperty<*> = SemanticVersionCreatorProperty(descriptor, graph, properties) + context: CreatorContext + ): CreatorProperty<*> = SemanticVersionCreatorProperty(descriptor, context) } } Index: src/main/kotlin/creator/custom/types/SimpleCreatorProperty.kt =================================================================== --- src/main/kotlin/creator/custom/types/SimpleCreatorProperty.kt (revision 69241a67289807a8303f679ffeb053382a6ee622) +++ src/main/kotlin/creator/custom/types/SimpleCreatorProperty.kt (revision 1579723a3f7834ce8f03a090c6f9e06505da71b6) @@ -22,10 +22,9 @@ import com.demonwav.mcdev.asset.MCDevBundle import com.demonwav.mcdev.creator.custom.BuiltinValidations +import com.demonwav.mcdev.creator.custom.CreatorContext import com.demonwav.mcdev.creator.custom.TemplatePropertyDescriptor -import com.intellij.ide.util.projectWizard.WizardContext import com.intellij.openapi.observable.properties.GraphProperty -import com.intellij.openapi.observable.properties.PropertyGraph import com.intellij.ui.ComboboxSpeedSearch import com.intellij.ui.dsl.builder.Panel import com.intellij.ui.dsl.builder.bindItem @@ -35,10 +34,9 @@ abstract class SimpleCreatorProperty( descriptor: TemplatePropertyDescriptor, - graph: PropertyGraph, - properties: Map>, + context: CreatorContext, valueType: Class -) : CreatorProperty(descriptor, graph, properties, valueType) { +) : CreatorProperty(descriptor, context, valueType) { private val options: Map? = makeOptionsList() @@ -80,7 +78,7 @@ override val graphProperty: GraphProperty by lazy { graph.property(defaultValue) } - override fun buildUi(panel: Panel, context: WizardContext) { + override fun buildUi(panel: Panel) { if (isDropdown) { if (graphProperty.get() !in options!!.keys) { graphProperty.set(defaultValue) @@ -112,11 +110,11 @@ } }.propertyVisibility() } else { - buildSimpleUi(panel, context) + buildSimpleUi(panel) } } - abstract fun buildSimpleUi(panel: Panel, context: WizardContext) + abstract fun buildSimpleUi(panel: Panel) private inner class DropdownAutoRenderer : DefaultListCellRenderer() { Index: src/main/kotlin/creator/custom/types/StringCreatorProperty.kt =================================================================== --- src/main/kotlin/creator/custom/types/StringCreatorProperty.kt (revision 69241a67289807a8303f679ffeb053382a6ee622) +++ src/main/kotlin/creator/custom/types/StringCreatorProperty.kt (revision 1579723a3f7834ce8f03a090c6f9e06505da71b6) @@ -21,15 +21,14 @@ package com.demonwav.mcdev.creator.custom.types import com.demonwav.mcdev.creator.custom.BuiltinValidations +import com.demonwav.mcdev.creator.custom.CreatorContext import com.demonwav.mcdev.creator.custom.PropertyDerivation import com.demonwav.mcdev.creator.custom.TemplatePropertyDescriptor import com.demonwav.mcdev.creator.custom.TemplateValidationReporter import com.demonwav.mcdev.creator.custom.derivation.PreparedDerivation import com.demonwav.mcdev.creator.custom.derivation.ReplacePropertyDerivation import com.demonwav.mcdev.creator.custom.derivation.SelectPropertyDerivation -import com.intellij.ide.util.projectWizard.WizardContext import com.intellij.openapi.observable.properties.GraphProperty -import com.intellij.openapi.observable.properties.PropertyGraph import com.intellij.ui.dsl.builder.COLUMNS_LARGE import com.intellij.ui.dsl.builder.Panel import com.intellij.ui.dsl.builder.bindText @@ -38,9 +37,8 @@ class StringCreatorProperty( descriptor: TemplatePropertyDescriptor, - graph: PropertyGraph, - properties: Map> -) : SimpleCreatorProperty(descriptor, graph, properties, String::class.java) { + context: CreatorContext +) : SimpleCreatorProperty(descriptor, context, String::class.java) { private var validationRegex: Regex? = null @@ -82,7 +80,7 @@ else -> null } - override fun buildSimpleUi(panel: Panel, context: WizardContext) { + override fun buildSimpleUi(panel: Panel) { panel.row(descriptor.translatedLabel) { val textField = textField().bindText(this@StringCreatorProperty.toStringProperty(graphProperty)) .columns(COLUMNS_LARGE) @@ -96,8 +94,7 @@ class Factory : CreatorPropertyFactory { override fun create( descriptor: TemplatePropertyDescriptor, - graph: PropertyGraph, - properties: Map> - ): CreatorProperty<*> = StringCreatorProperty(descriptor, graph, properties) + context: CreatorContext + ): CreatorProperty<*> = StringCreatorProperty(descriptor, context) } }