⁠
kyle wood: Add test infrastructure for project creator tests
Creator properties can now be cleared in between tests, and define a
better model for managing the coroutine scope and jobs during project
creation.
Creator properties can now be cleared in between tests, and define a
better model for managing the coroutine scope and jobs during project
creation.
- /*
- * Minecraft Development for IntelliJ
- *
- * https://mcdev.io/
- *
- * Copyright (C) 2026 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 <https://www.gnu.org/licenses/>.
- */
-
- package com.demonwav.mcdev.creator
-
- import com.intellij.ide.util.projectWizard.WizardContext
- import com.intellij.ide.wizard.AbstractWizard
- import com.intellij.openapi.application.ModalityState
- import com.intellij.openapi.diagnostic.thisLogger
- import com.intellij.openapi.progress.ProgressManager
- import javax.swing.JComponent
-
- val WizardContext.contentPanel: JComponent?
- get() = this.getUserData(AbstractWizard.KEY)?.contentPanel
-
- val WizardContext.modalityState: ModalityState
- get() {
- ProgressManager.checkCanceled()
- val contentPanel = contentPanel
- if (contentPanel == null) {
- thisLogger().error("Wizard content panel is null, using default modality state")
- return ModalityState.defaultModalityState()
- }
-
- return ModalityState.stateForComponent(contentPanel)
- }
- /*
- * Minecraft Development for IntelliJ
- *
- * https://mcdev.io/
- *
- * Copyright (C) 2026 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 <https://www.gnu.org/licenses/>.
- */
-
- package com.demonwav.mcdev.creator
-
- import com.intellij.ide.util.projectWizard.WizardContext
- import com.intellij.ide.wizard.AbstractWizard
- import com.intellij.openapi.application.ModalityState
- import com.intellij.openapi.diagnostic.thisLogger
- import com.intellij.openapi.progress.ProgressManager
- import com.intellij.openapi.util.Key
- import javax.swing.JComponent
- import org.jetbrains.annotations.TestOnly
-
- private val MODALITY_STATE_OVERRIDE = Key.create<ModalityState>("mcdev.creator.modalityStateOverride")
-
- val WizardContext.contentPanel: JComponent?
- get() = this.getUserData(AbstractWizard.KEY)?.contentPanel
-
- val WizardContext.modalityState: ModalityState
- get() {
- ProgressManager.checkCanceled()
- getUserData(MODALITY_STATE_OVERRIDE)?.let { return it }
-
- val contentPanel = contentPanel
- if (contentPanel == null) {
- thisLogger().error("Wizard content panel is null, using default modality state")
- return ModalityState.defaultModalityState()
- }
-
- return ModalityState.stateForComponent(contentPanel)
- }
-
- /**
- * Makes the creator use [state] for this wizard instead of the wizard dialog's modality state, so the creator can run
- * without a dialog.
- */
- @TestOnly
- fun WizardContext.overrideModalityState(state: ModalityState) {
- putUserData(MODALITY_STATE_OVERRIDE, state)
- }