From 2108634ddb6bcd9ff484d775e921f73e01e0b452 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Fri, 2 Mar 2018 13:36:00 +0300 Subject: [PATCH] MPP wizard: add check-boxes to create JVM / JS module Related to KT-23097 --- .../KotlinGradleMultiplatformWizardStep.kt | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinGradleMultiplatformWizardStep.kt b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinGradleMultiplatformWizardStep.kt index 223be2fd9b7..ced595f7cb3 100644 --- a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinGradleMultiplatformWizardStep.kt +++ b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinGradleMultiplatformWizardStep.kt @@ -41,8 +41,12 @@ class KotlinGradleMultiplatformWizardStep( LabeledComponent.create(JTextField(), "Root module name:", BorderLayout.WEST) private val commonModuleNameComponent: LabeledComponent = LabeledComponent.create(JTextField(), "Common module name:", BorderLayout.WEST) + private val jvmCheckBox: JCheckBox = + JCheckBox("Create JVM module", true) private val jvmModuleNameComponent: LabeledComponent = LabeledComponent.create(JTextField(), "JVM module name:", BorderLayout.WEST) + private val jsCheckBox: JCheckBox = + JCheckBox("Create JS module", true) private val jsModuleNameComponent: LabeledComponent = LabeledComponent.create(JTextField(), "JS module name:", BorderLayout.WEST) @@ -91,6 +95,13 @@ class KotlinGradleMultiplatformWizardStep( jvmModuleNameComponent.component.document.addDocumentListener(stopSyncEditingListener) jsModuleNameComponent.component.document.addDocumentListener(stopSyncEditingListener) + jvmCheckBox.addItemListener { + jvmModuleNameComponent.isEnabled = jvmCheckBox.isSelected + } + jsCheckBox.addItemListener { + jsModuleNameComponent.isEnabled = jsCheckBox.isSelected + } + panel.border = BorderFactory.createEmptyBorder(10, 10, 10, 10) panel.add( rootModuleNameComponent, @@ -108,6 +119,14 @@ class KotlinGradleMultiplatformWizardStep( JBUI.emptyInsets(), 0, 0 ) ) + panel.add( + jvmCheckBox, + GridBagConstraints( + 0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, + GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, + JBUI.emptyInsets(), 0, 0 + ) + ) panel.add( jvmModuleNameComponent, GridBagConstraints( @@ -116,6 +135,14 @@ class KotlinGradleMultiplatformWizardStep( JBUI.emptyInsets(), 0, 0 ) ) + panel.add( + jsCheckBox, + GridBagConstraints( + 0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, + GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, + JBUI.emptyInsets(), 0, 0 + ) + ) panel.add( jsModuleNameComponent, GridBagConstraints( @@ -164,9 +191,9 @@ class KotlinGradleMultiplatformWizardStep( private val commonModuleName: String get() = commonModuleNameComponent.component.text private val jvmModuleName: String - get() = jvmModuleNameComponent.component.text + get() = if (jvmCheckBox.isSelected) jvmModuleNameComponent.component.text else "" private val jsModuleName: String - get() = jsModuleNameComponent.component.text + get() = if (jsCheckBox.isSelected) jsModuleNameComponent.component.text else "" override fun validate(): Boolean { if (rootModuleName.isEmpty()) {