diff --git a/src/main/kotlin/creator/custom/CustomPlatformStep.kt b/src/main/kotlin/creator/custom/CustomPlatformStep.kt index 6d54cab04..682e4256d 100644 --- a/src/main/kotlin/creator/custom/CustomPlatformStep.kt +++ b/src/main/kotlin/creator/custom/CustomPlatformStep.kt @@ -124,7 +124,7 @@ class CustomPlatformStep( lateinit var templatePropertyPlaceholder: Placeholder builder.row(MCDevBundle("creator.ui.custom.repos.label")) { - segmentedButton(templateRepos) { it.name } + segmentedButton(templateRepos) { text = it.name } .bind(templateRepoProperty) }.visible(templateRepos.size > 1) @@ -153,7 +153,7 @@ class CustomPlatformStep( builder.row(MCDevBundle("creator.ui.custom.groups.label")) { availableGroupsSegmentedButton = - segmentedButton(emptyList(), String::toString) + segmentedButton(emptyList()) { text = it } .bind(selectedGroupProperty) }.visibleIf( availableGroupsProperty.transform { it.size > 1 } @@ -161,8 +161,10 @@ class CustomPlatformStep( builder.row(MCDevBundle("creator.ui.custom.templates.label")) { availableTemplatesSegmentedButton = - segmentedButton(emptyList(), LoadedTemplate::label, LoadedTemplate::tooltip) - .bind(selectedTemplateProperty) + segmentedButton(emptyList()) { template: LoadedTemplate -> + text = template.label + toolTipText = template.tooltip + }.bind(selectedTemplateProperty) .validation { addApplyRule("", condition = ::hasTemplateErrors) } @@ -172,7 +174,7 @@ class CustomPlatformStep( availableTemplatesProperty.afterChange { newTemplates -> val groups = newTemplates.mapTo(linkedSetOf()) { it.descriptor.translatedGroup } - availableGroupsSegmentedButton.items(groups) + availableGroupsSegmentedButton.items = groups // availableGroupsSegmentedButton.visible(groups.size > 1) availableGroups = groups selectedGroup = groups.firstOrNull() ?: "empty" @@ -180,7 +182,7 @@ class CustomPlatformStep( selectedGroupProperty.afterChange { group -> val templates = availableTemplates.filter { it.descriptor.translatedGroup == group } - availableTemplatesSegmentedButton.items(templates) + availableTemplatesSegmentedButton.items = templates // Force visiblity because the component might become hidden and not show up again // when the segmented button switches between dropdown and buttons availableTemplatesSegmentedButton.visible(true) diff --git a/src/main/kotlin/creator/custom/finalizers/ImportMavenProjectFinalizer.kt b/src/main/kotlin/creator/custom/finalizers/ImportMavenProjectFinalizer.kt index 3e1e71a0f..38aefd975 100644 --- a/src/main/kotlin/creator/custom/finalizers/ImportMavenProjectFinalizer.kt +++ b/src/main/kotlin/creator/custom/finalizers/ImportMavenProjectFinalizer.kt @@ -20,14 +20,14 @@ package com.demonwav.mcdev.creator.custom.finalizers -import com.demonwav.mcdev.util.invokeAndWait import com.intellij.ide.util.projectWizard.WizardContext import com.intellij.openapi.diagnostic.thisLogger import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.VfsUtil import java.nio.file.Path -import java.util.concurrent.TimeUnit -import org.jetbrains.idea.maven.project.importing.MavenImportingManager +import kotlinx.coroutines.runBlocking +import org.jetbrains.idea.maven.buildtool.MavenImportSpec +import org.jetbrains.idea.maven.project.MavenProjectsManager class ImportMavenProjectFinalizer : CreatorFinalizer { @@ -38,25 +38,16 @@ class ImportMavenProjectFinalizer : CreatorFinalizer { templateProperties: Map ) { val projectDir = context.projectFileDirectory - val pomFile = VfsUtil.findFile(Path.of(projectDir).resolve("pom.xml"), true) ?: return - thisLogger().info("Invoking import on EDT pomFile = ${pomFile.path}") - val promise = invokeAndWait { - if (project.isDisposed || !project.isInitialized) { - return@invokeAndWait null - } - MavenImportingManager.getInstance(project).linkAndImportFile(pomFile) - } - - if (promise == null) { - thisLogger().info("Could not start import") - return + thisLogger().info("Invoking import on EDT pomFile = ${pomFile.path}") + val projectsManager = MavenProjectsManager.getInstance(project) + projectsManager.addManagedFiles(listOf(pomFile)) + runBlocking { + projectsManager.updateAllMavenProjects(MavenImportSpec(true, true, false)) } - thisLogger().info("Waiting for import to finish") - promise.finishPromise.blockingGet(Int.MAX_VALUE, TimeUnit.SECONDS) thisLogger().info("Import finished") } } diff --git a/src/main/kotlin/creator/custom/types/SimpleCreatorProperty.kt b/src/main/kotlin/creator/custom/types/SimpleCreatorProperty.kt index 7a735d7fb..eee7e0ee1 100644 --- a/src/main/kotlin/creator/custom/types/SimpleCreatorProperty.kt +++ b/src/main/kotlin/creator/custom/types/SimpleCreatorProperty.kt @@ -100,7 +100,7 @@ abstract class SimpleCreatorProperty( it.validationOnApply(validation) } } else { - segmentedButton(options.keys) { options[it] ?: it.toString() } + segmentedButton(options.keys) { text = options[it] ?: it.toString() } .bind(graphProperty) .enabled(descriptor.editable != false) .maxButtonsCount(4) diff --git a/src/main/kotlin/platform/mixin/expression/MEExpressionCompletionContributor.kt b/src/main/kotlin/platform/mixin/expression/MEExpressionCompletionContributor.kt index 339634a39..762a7c22c 100644 --- a/src/main/kotlin/platform/mixin/expression/MEExpressionCompletionContributor.kt +++ b/src/main/kotlin/platform/mixin/expression/MEExpressionCompletionContributor.kt @@ -21,6 +21,7 @@ package com.demonwav.mcdev.platform.mixin.expression import com.intellij.codeInsight.TailType +import com.intellij.codeInsight.TailTypes import com.intellij.codeInsight.completion.BasicExpressionCompletionContributor import com.intellij.codeInsight.completion.CompletionContributor import com.intellij.codeInsight.completion.CompletionParameters @@ -38,8 +39,8 @@ class MEExpressionCompletionContributor : CompletionContributor() { CompletionType.BASIC, MEExpressionCompletionUtil.STATEMENT_KEYWORD_PLACE, KeywordCompletionProvider( - Keyword("return", TailType.INSERT_SPACE), - Keyword("throw", TailType.INSERT_SPACE), + Keyword("return", TailTypes.insertSpaceType()), + Keyword("throw", TailTypes.insertSpaceType()), ) ) extend( @@ -51,7 +52,7 @@ class MEExpressionCompletionContributor : CompletionContributor() { Keyword("true"), Keyword("false"), Keyword("null"), - Keyword("new", TailType.INSERT_SPACE), + Keyword("new", TailTypes.insertSpaceType()), ) ) extend( @@ -65,7 +66,7 @@ class MEExpressionCompletionContributor : CompletionContributor() { CompletionType.BASIC, MEExpressionCompletionUtil.INSTANCEOF_PLACE, KeywordCompletionProvider( - Keyword("instanceof", TailType.INSERT_SPACE) + Keyword("instanceof", TailTypes.insertSpaceType()) ) ) extend( @@ -123,7 +124,7 @@ class MEExpressionCompletionContributor : CompletionContributor() { keywords.map { keyword -> var lookupItem = BasicExpressionCompletionContributor.createKeywordLookupItem(parameters.position, keyword.name) - if (keyword.tailType != TailType.NONE) { + if (keyword.tailType != TailTypes.noneType()) { lookupItem = object : TailTypeDecorator(lookupItem) { override fun computeTailType(context: InsertionContext?) = keyword.tailType } @@ -134,5 +135,5 @@ class MEExpressionCompletionContributor : CompletionContributor() { } } - private class Keyword(val name: String, val tailType: TailType = TailType.NONE) + private class Keyword(val name: String, val tailType: TailType = TailTypes.noneType()) }