Wizard: add support of JS singleplatform projects
This commit is contained in:
+4
@@ -19,6 +19,7 @@ import javax.swing.Icon
|
||||
class CreateModuleOrTargetPopup private constructor(
|
||||
private val target: Module?,
|
||||
private val allowMultiplatform: Boolean,
|
||||
private val allowSinglepaltformJs: Boolean,
|
||||
private val allowAndroid: Boolean,
|
||||
private val allowIos: Boolean,
|
||||
private val createTarget: (TargetConfigurator) -> Unit,
|
||||
@@ -42,6 +43,7 @@ class CreateModuleOrTargetPopup private constructor(
|
||||
if (allowMultiplatform) +MppModuleConfigurator
|
||||
+JvmSinglePlatformModuleConfigurator
|
||||
if (allowAndroid) +AndroidSinglePlatformModuleConfigurator
|
||||
if (allowSinglepaltformJs) +JsSingleplatformModuleConfigurator
|
||||
|
||||
//todo ios support
|
||||
//if (allowIos) +IOSSinglePlatformModuleConfigurator
|
||||
@@ -101,6 +103,7 @@ class CreateModuleOrTargetPopup private constructor(
|
||||
fun create(
|
||||
target: Module?,
|
||||
allowMultiplatform: Boolean,
|
||||
allowSinglepaltformJs: Boolean,
|
||||
allowAndroid: Boolean,
|
||||
allowIos: Boolean,
|
||||
createTarget: (TargetConfigurator) -> Unit,
|
||||
@@ -108,6 +111,7 @@ class CreateModuleOrTargetPopup private constructor(
|
||||
) = CreateModuleOrTargetPopup(
|
||||
target = target,
|
||||
allowMultiplatform = allowMultiplatform,
|
||||
allowSinglepaltformJs = allowSinglepaltformJs,
|
||||
allowAndroid = allowAndroid,
|
||||
allowIos = allowIos,
|
||||
createTarget = createTarget,
|
||||
|
||||
+1
@@ -28,6 +28,7 @@ class ModulesEditorComponent(
|
||||
moduleCreator.create(
|
||||
target = null, // The empty tree case
|
||||
allowMultiplatform = isMppProject,
|
||||
allowSinglepaltformJs = isMppProject,
|
||||
allowAndroid = isMppProject,
|
||||
allowIos = isMppProject,
|
||||
allModules = value ?: emptyList(),
|
||||
|
||||
+8
-5
@@ -4,9 +4,7 @@ import com.intellij.icons.AllIcons
|
||||
import com.intellij.openapi.actionSystem.ActionToolbarPosition
|
||||
import com.intellij.openapi.ui.Messages
|
||||
import com.intellij.ui.ToolbarDecorator
|
||||
import org.jetbrains.kotlin.tools.projectWizard.moduleConfigurators.AndroidSinglePlatformModuleConfigurator
|
||||
import org.jetbrains.kotlin.tools.projectWizard.moduleConfigurators.IOSSinglePlatformModuleConfigurator
|
||||
import org.jetbrains.kotlin.tools.projectWizard.moduleConfigurators.MppModuleConfigurator
|
||||
import org.jetbrains.kotlin.tools.projectWizard.moduleConfigurators.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.kotlin.withAllSubModules
|
||||
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.ui.createPanelWithPopupHandler
|
||||
@@ -31,6 +29,9 @@ class ModulesEditorToolbarDecorator(
|
||||
allowMultiplatform = isMultiplatformProject()
|
||||
&& isRootModule
|
||||
&& allModules.none { it.configurator == MppModuleConfigurator },
|
||||
allowSinglepaltformJs = isMultiplatformProject()
|
||||
&& isRootModule
|
||||
&& allModules.none { it.configurator == JsSingleplatformModuleConfigurator },
|
||||
allowAndroid = isRootModule
|
||||
&& isMultiplatformProject()
|
||||
&& allModules.none { it.configurator == AndroidSinglePlatformModuleConfigurator },
|
||||
@@ -52,7 +53,8 @@ class ModulesEditorToolbarDecorator(
|
||||
}
|
||||
text = "Add" + when (tree.selectedSettingItem?.safeAs<Module>()?.kind) {
|
||||
ModuleKind.multiplatform -> " Target"
|
||||
ModuleKind.singleplatform -> " Module"
|
||||
ModuleKind.singleplatformJvm -> " Module"
|
||||
ModuleKind.singleplatformJs -> " JS Module"
|
||||
ModuleKind.target -> ""
|
||||
null -> ""
|
||||
}
|
||||
@@ -105,6 +107,7 @@ class ModulesEditorToolbarDecorator(
|
||||
private val Module.kindText
|
||||
get() = when (kind) {
|
||||
ModuleKind.multiplatform -> "Module"
|
||||
ModuleKind.singleplatform -> "Module"
|
||||
ModuleKind.singleplatformJvm -> "Module"
|
||||
ModuleKind.singleplatformJs -> "Module"
|
||||
ModuleKind.target -> "Target"
|
||||
}
|
||||
+2
@@ -36,6 +36,7 @@ class NewModuleCreator {
|
||||
fun create(
|
||||
target: Module?,
|
||||
allowMultiplatform: Boolean,
|
||||
allowSinglepaltformJs: Boolean,
|
||||
allowAndroid: Boolean,
|
||||
allowIos: Boolean,
|
||||
allModules: List<Module>,
|
||||
@@ -43,6 +44,7 @@ class NewModuleCreator {
|
||||
) = CreateModuleOrTargetPopup.create(
|
||||
target = target,
|
||||
allowMultiplatform = allowMultiplatform,
|
||||
allowSinglepaltformJs = allowSinglepaltformJs,
|
||||
allowAndroid = allowAndroid,
|
||||
allowIos = allowIos,
|
||||
createTarget = { targetConfigurator ->
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ class TargetsModel(
|
||||
DefaultMutableTreeNode(moduleToAdd).apply {
|
||||
val userObject = parentToAdd.userObject
|
||||
when {
|
||||
userObject is Module && userObject.kind == ModuleKind.singleplatform -> {
|
||||
userObject is Module && userObject.kind == ModuleKind.singleplatformJvm -> {
|
||||
val indexOfLastModule = parentToAdd.children()
|
||||
.toList()
|
||||
.indexOfLast {
|
||||
|
||||
+2
-1
@@ -91,7 +91,8 @@ val Module.icon: Icon
|
||||
get() = when (kind) {
|
||||
ModuleKind.target -> configurator.moduleType.icon
|
||||
ModuleKind.multiplatform -> AllIcons.Nodes.Module
|
||||
ModuleKind.singleplatform -> AllIcons.Nodes.Module
|
||||
ModuleKind.singleplatformJs -> KotlinIcons.JS
|
||||
ModuleKind.singleplatformJvm -> AllIcons.Nodes.Module
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user