Wizard: fix UI layout
This commit is contained in:
+2
-1
@@ -70,7 +70,8 @@ abstract class DynamicComponent(private val context: Context) : Component() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
abstract class TitledComponent(context: Context) : DynamicComponent(context) {
|
abstract class TitledComponent(context: Context) : DynamicComponent(context) {
|
||||||
open val needCentering: Boolean = true
|
open val forceLabelCenteringOffset: Int? = null
|
||||||
|
open val additionalComponentPadding: Int = 0
|
||||||
open val maximumWidth: Int? = null
|
open val maximumWidth: Int? = null
|
||||||
abstract val title: String?
|
abstract val title: String?
|
||||||
open fun shouldBeShow(): Boolean = true
|
open fun shouldBeShow(): Boolean = true
|
||||||
|
|||||||
+1
@@ -38,6 +38,7 @@ class BuildSystemTypeSettingComponent(
|
|||||||
BuildSystemPlugin::type.reference,
|
BuildSystemPlugin::type.reference,
|
||||||
context
|
context
|
||||||
), Disposable {
|
), Disposable {
|
||||||
|
override val forceLabelCenteringOffset: Int? = 2
|
||||||
private val buttons = setting.type.values.map(::BuildSystemChooseButton)
|
private val buttons = setting.type.values.map(::BuildSystemChooseButton)
|
||||||
override val component = panel {
|
override val component = panel {
|
||||||
row {
|
row {
|
||||||
|
|||||||
+6
-5
@@ -10,7 +10,6 @@ import com.intellij.ui.TitledSeparator
|
|||||||
import com.intellij.ui.layout.panel
|
import com.intellij.ui.layout.panel
|
||||||
import com.intellij.util.ui.JBUI
|
import com.intellij.util.ui.JBUI
|
||||||
import com.intellij.util.ui.components.BorderLayoutPanel
|
import com.intellij.util.ui.components.BorderLayoutPanel
|
||||||
import org.jetbrains.kotlin.idea.framework.KotlinModuleBuilder
|
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.core.Context
|
import org.jetbrains.kotlin.tools.projectWizard.core.Context
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.path
|
import org.jetbrains.kotlin.tools.projectWizard.core.entity.path
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.SettingReference
|
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.SettingReference
|
||||||
@@ -43,7 +42,9 @@ class FirstWizardStepComponent(ideWizard: IdeWizard) : WizardStepComponent(ideWi
|
|||||||
class ProjectSettingsComponent(ideWizard: IdeWizard) : DynamicComponent(ideWizard.context) {
|
class ProjectSettingsComponent(ideWizard: IdeWizard) : DynamicComponent(ideWizard.context) {
|
||||||
private val context = ideWizard.context
|
private val context = ideWizard.context
|
||||||
private val projectTemplateComponent = ProjectTemplateSettingComponent(context).asSubComponent()
|
private val projectTemplateComponent = ProjectTemplateSettingComponent(context).asSubComponent()
|
||||||
private val buildSystemSetting = BuildSystemTypeSettingComponent(context).asSubComponent()
|
private val buildSystemSetting = BuildSystemTypeSettingComponent(context).asSubComponent().apply {
|
||||||
|
component.addBorder(JBUI.Borders.empty(0, /*left&right*/4))
|
||||||
|
}
|
||||||
private val buildSystemAdditionalSettingsComponent = BuildSystemAdditionalSettingsComponent(ideWizard).asSubComponent()
|
private val buildSystemAdditionalSettingsComponent = BuildSystemAdditionalSettingsComponent(ideWizard).asSubComponent()
|
||||||
|
|
||||||
private val nameAndLocationComponent = TitledComponentsList(
|
private val nameAndLocationComponent = TitledComponentsList(
|
||||||
@@ -66,7 +67,7 @@ class ProjectSettingsComponent(ideWizard: IdeWizard) : DynamicComponent(ideWizar
|
|||||||
row {
|
row {
|
||||||
buildSystemAdditionalSettingsComponent.component(growX)
|
buildSystemAdditionalSettingsComponent.component(growX)
|
||||||
}
|
}
|
||||||
}
|
}.addBorder(JBUI.Borders.emptyRight(UIConstants.PADDING))
|
||||||
}
|
}
|
||||||
|
|
||||||
private var locationWasUpdatedByHand: Boolean = false
|
private var locationWasUpdatedByHand: Boolean = false
|
||||||
@@ -234,10 +235,10 @@ class ProjectPreviewComponent(context: Context) : DynamicComponent(context) {
|
|||||||
).asSubComponent()
|
).asSubComponent()
|
||||||
|
|
||||||
override val component: JComponent = borderPanel {
|
override val component: JComponent = borderPanel {
|
||||||
border = JBUI.Borders.empty(10)
|
|
||||||
addToTop(label("Preview", bold = true).addBorder(JBUI.Borders.emptyBottom(5)))
|
addToTop(label("Preview", bold = true).addBorder(JBUI.Borders.emptyBottom(5)))
|
||||||
addToCenter(modulesEditorComponent.component)
|
addToCenter(modulesEditorComponent.component)
|
||||||
}.addBorder(JBUI.Borders.customLine(JBColor.border(), 0, /*left*/1, 0, 0))
|
}.addBorder(JBUI.Borders.empty(UIConstants.PADDING, /*left*/UIConstants.PADDING * 2, UIConstants.PADDING, UIConstants.PADDING))
|
||||||
|
.addBorder(JBUI.Borders.customLine(JBColor.border(), 0, /*left*/1, 0, 0))
|
||||||
|
|
||||||
override fun onValueUpdated(reference: SettingReference<*, *>?) {
|
override fun onValueUpdated(reference: SettingReference<*, *>?) {
|
||||||
super.onValueUpdated(reference)
|
super.onValueUpdated(reference)
|
||||||
|
|||||||
+3
-3
@@ -24,7 +24,7 @@ class ProjectTemplateSettingComponent(
|
|||||||
context
|
context
|
||||||
) {
|
) {
|
||||||
override val validationIndicator: ValidationIndicator? get() = null
|
override val validationIndicator: ValidationIndicator? get() = null
|
||||||
override val needCentering: Boolean = false
|
override val forceLabelCenteringOffset: Int? = 4
|
||||||
private val templateDescriptionComponent = TemplateDescriptionComponent().asSubComponent()
|
private val templateDescriptionComponent = TemplateDescriptionComponent().asSubComponent()
|
||||||
|
|
||||||
private val list = ImmutableSingleSelectableListWithIcon(
|
private val list = ImmutableSingleSelectableListWithIcon(
|
||||||
@@ -64,9 +64,9 @@ class ProjectTemplateSettingComponent(
|
|||||||
}
|
}
|
||||||
|
|
||||||
class TemplateDescriptionComponent : Component() {
|
class TemplateDescriptionComponent : Component() {
|
||||||
private val descriptionLabel = label("").apply {
|
private val descriptionLabel = label("") {
|
||||||
fontColor = UIUtil.FontColor.BRIGHTER
|
fontColor = UIUtil.FontColor.BRIGHTER
|
||||||
preferredSize = Dimension(preferredSize.width, 55)
|
preferredSize = Dimension(preferredSize.width, 45)
|
||||||
verticalAlignment = SwingConstants.TOP
|
verticalAlignment = SwingConstants.TOP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -23,7 +23,8 @@ class ModuleDependenciesComponent(
|
|||||||
) : TitledComponent(context) {
|
) : TitledComponent(context) {
|
||||||
override val title: String = "Module dependencies"
|
override val title: String = "Module dependencies"
|
||||||
private val dependenciesList = ModuleDependenciesList()
|
private val dependenciesList = ModuleDependenciesList()
|
||||||
override val needCentering: Boolean = false
|
override val forceLabelCenteringOffset: Int? = 4
|
||||||
|
override val additionalComponentPadding: Int = 1
|
||||||
override val maximumWidth: Int = 500
|
override val maximumWidth: Int = 500
|
||||||
|
|
||||||
private val toolbarDecorator: ToolbarDecorator = ToolbarDecorator.createDecorator(dependenciesList).apply {
|
private val toolbarDecorator: ToolbarDecorator = ToolbarDecorator.createDecorator(dependenciesList).apply {
|
||||||
|
|||||||
+1
-1
@@ -127,7 +127,7 @@ private class ModuleTemplateComponent(
|
|||||||
onTemplateChanged()
|
onTemplateChanged()
|
||||||
}.asSubComponent()
|
}.asSubComponent()
|
||||||
|
|
||||||
override val needCentering: Boolean = false
|
override val forceLabelCenteringOffset: Int? = 4
|
||||||
private val templateDescriptionLabel = label("") {
|
private val templateDescriptionLabel = label("") {
|
||||||
fontColor = UIUtil.FontColor.BRIGHTER
|
fontColor = UIUtil.FontColor.BRIGHTER
|
||||||
addBorder(JBUI.Borders.empty(4, 4))
|
addBorder(JBUI.Borders.empty(4, 4))
|
||||||
|
|||||||
+1
-1
@@ -53,7 +53,7 @@ class ProjectStructureEditorComponent(
|
|||||||
).asSubComponent()
|
).asSubComponent()
|
||||||
|
|
||||||
override val component = borderPanel {
|
override val component = borderPanel {
|
||||||
addToCenter(moduleSettingComponent.component)
|
addToCenter(moduleSettingComponent.component.addBorder(JBUI.Borders.empty(UIConstants.PADDING)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -11,6 +11,8 @@ import org.jetbrains.kotlin.tools.projectWizard.plugins.kotlin.KotlinPlugin
|
|||||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.kotlin.ProjectKind
|
import org.jetbrains.kotlin.tools.projectWizard.plugins.kotlin.ProjectKind
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.settings.DisplayableSettingItem
|
import org.jetbrains.kotlin.tools.projectWizard.settings.DisplayableSettingItem
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.Module
|
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.Module
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.wizard.ui.UIConstants
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.wizard.ui.addBorder
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.ui.customPanel
|
import org.jetbrains.kotlin.tools.projectWizard.wizard.ui.customPanel
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.ui.setting.SettingComponent
|
import org.jetbrains.kotlin.tools.projectWizard.wizard.ui.setting.SettingComponent
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.ui.setting.ValidationIndicator
|
import org.jetbrains.kotlin.tools.projectWizard.wizard.ui.setting.ValidationIndicator
|
||||||
@@ -44,7 +46,9 @@ class ModulesEditorComponent(
|
|||||||
)?.showInCenterOf(component)
|
)?.showInCenterOf(component)
|
||||||
}
|
}
|
||||||
).apply {
|
).apply {
|
||||||
border = JBUI.Borders.emptyRight(10)
|
if (editable) {
|
||||||
|
border = JBUI.Borders.emptyRight(10)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val model = TargetsModel(tree, ::value, context, uiEditorUsagesStats)
|
private val model = TargetsModel(tree, ::value, context, uiEditorUsagesStats)
|
||||||
|
|||||||
+11
-9
@@ -53,20 +53,21 @@ open class TitledComponentsList(
|
|||||||
TitledComponentData(
|
TitledComponentData(
|
||||||
label.also { add(it) }.constraints(),
|
label.also { add(it) }.constraints(),
|
||||||
component.component.also { add(it) }.constraints(),
|
component.component.also { add(it) }.constraints(),
|
||||||
component.needCentering,
|
component.forceLabelCenteringOffset,
|
||||||
|
component.additionalComponentPadding,
|
||||||
component.maximumWidth
|
component.maximumWidth
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun TitledComponentData.centerConstraint() =
|
fun TitledComponentData.centerConstraint() =
|
||||||
if (needCentering) component.height * .5f - label.height * .5f
|
if (forceCenteringOffset == null) component.height * .5f - label.height * .5f
|
||||||
else 4.asSpring()
|
else forceCenteringOffset.asSpring()
|
||||||
|
|
||||||
val labelWidth = componentsWithLabels.fold(componentsWithLabels.first().label.width) { spring, row ->
|
val labelWidth = componentsWithLabels.fold(componentsWithLabels.first().label.width) { spring, row ->
|
||||||
Spring.max(spring, row.label.width)
|
Spring.max(spring, row.label.width)
|
||||||
}
|
}
|
||||||
|
|
||||||
componentsWithLabels.forEach { (label, component, _, componentMaxWidth) ->
|
componentsWithLabels.forEach { (label, component, _, _, componentMaxWidth) ->
|
||||||
label.width = labelWidth
|
label.width = labelWidth
|
||||||
val maxWidth = componentMaxWidth ?: globalMaxWidth
|
val maxWidth = componentMaxWidth ?: globalMaxWidth
|
||||||
if (maxWidth == null) {
|
if (maxWidth == null) {
|
||||||
@@ -85,7 +86,7 @@ open class TitledComponentsList(
|
|||||||
component.x = label[SpringLayout.EAST] + xGap
|
component.x = label[SpringLayout.EAST] + xGap
|
||||||
|
|
||||||
if (lastComponent != null && lastLabel != null) {
|
if (lastComponent != null && lastLabel != null) {
|
||||||
val constraint = lastComponent[SpringLayout.SOUTH] + yGap
|
val constraint = lastComponent[SpringLayout.SOUTH] + yGap + data.additionalComponentGap
|
||||||
label.y = constraint + data.centerConstraint()
|
label.y = constraint + data.centerConstraint()
|
||||||
component.y = constraint
|
component.y = constraint
|
||||||
} else {
|
} else {
|
||||||
@@ -106,15 +107,16 @@ open class TitledComponentsList(
|
|||||||
private const val xGap = 5
|
private const val xGap = 5
|
||||||
private const val yGapSmall = 6
|
private const val yGapSmall = 6
|
||||||
private const val yGapBig = 12
|
private const val yGapBig = 12
|
||||||
private const val xPanelPadding = 16
|
private const val xPanelPadding = UIConstants.PADDING
|
||||||
private const val yPanelPadding = 16
|
private const val yPanelPadding = UIConstants.PADDING
|
||||||
}
|
}
|
||||||
|
|
||||||
private data class TitledComponentData(
|
private data class TitledComponentData(
|
||||||
val label: SpringLayout.Constraints,
|
val label: SpringLayout.Constraints,
|
||||||
val component: SpringLayout.Constraints,
|
val component: SpringLayout.Constraints,
|
||||||
val needCentering: Boolean,
|
val forceCenteringOffset: Int?,
|
||||||
val maximumWidth: Int?,
|
val additionalComponentGap: Int,
|
||||||
|
val maximumWidth: Int?
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
@@ -149,3 +149,7 @@ val DisplayableSettingItem.fullTextHtml
|
|||||||
append("</span>")
|
append("</span>")
|
||||||
}
|
}
|
||||||
}.asHtml()
|
}.asHtml()
|
||||||
|
|
||||||
|
object UIConstants {
|
||||||
|
const val PADDING = 8
|
||||||
|
}
|
||||||
+1
-1
@@ -44,7 +44,7 @@ class RealNativeTargetConfigurator private constructor(
|
|||||||
object NativeForCurrentSystemTarget : NativeTargetConfigurator, SingleCoexistenceTargetConfigurator {
|
object NativeForCurrentSystemTarget : NativeTargetConfigurator, SingleCoexistenceTargetConfigurator {
|
||||||
override val moduleType = ModuleType.native
|
override val moduleType = ModuleType.native
|
||||||
override val id = "nativeForCurrentSystem"
|
override val id = "nativeForCurrentSystem"
|
||||||
override val text = "For Current System"
|
override val text = "Your system"
|
||||||
|
|
||||||
|
|
||||||
override fun Reader.createTargetIrs(
|
override fun Reader.createTargetIrs(
|
||||||
|
|||||||
Reference in New Issue
Block a user