@@ -7,23 +7,25 @@ import com.fwdekker.randomness.array.ArrayDecorator.Companion.MIN_MIN_COUNT
77import  com.fwdekker.randomness.array.ArrayDecorator.Companion.PRESET_AFFIX_DECORATOR_DESCRIPTORS 
88import  com.fwdekker.randomness.array.ArrayDecorator.Companion.PRESET_SEPARATORS 
99import  com.fwdekker.randomness.ui.JIntSpinner 
10+ import  com.fwdekker.randomness.ui.LiteralPredicate 
1011import  com.fwdekker.randomness.ui.UIConstants 
1112import  com.fwdekker.randomness.ui.bindCurrentText 
1213import  com.fwdekker.randomness.ui.bindIntValue 
1314import  com.fwdekker.randomness.ui.bindSpinners 
14- import  com.fwdekker.randomness.ui.indentedRowRange  
15+ import  com.fwdekker.randomness.ui.decoratedRowRange  
1516import  com.fwdekker.randomness.ui.isEditable 
1617import  com.fwdekker.randomness.ui.loadMnemonic 
1718import  com.fwdekker.randomness.ui.withFixedWidth 
1819import  com.fwdekker.randomness.ui.withName 
1920import  com.intellij.openapi.ui.ComboBox 
2021import  com.intellij.ui.dsl.builder.BottomGap 
2122import  com.intellij.ui.dsl.builder.Cell 
22- import  com.intellij.ui.dsl.builder.TopGap 
2323import  com.intellij.ui.dsl.builder.bindSelected 
2424import  com.intellij.ui.dsl.builder.panel 
2525import  com.intellij.ui.dsl.builder.selected 
26+ import  com.intellij.ui.layout.ComponentPredicate 
2627import  com.intellij.ui.layout.and 
28+ import  com.intellij.ui.layout.or 
2729import  com.intellij.ui.layout.selected 
2830import  javax.swing.JCheckBox 
2931
@@ -32,30 +34,29 @@ import javax.swing.JCheckBox
3234 * Component for editing an [ArrayDecorator]. 
3335 * 
3436 * @param scheme the scheme to edit 
35-  * @property embedded `true` if the editor is embedded, which means that no titled separator is shown at the top, and 
36-  * the user cannot disable the array decorator; [apply] always enables the array decorator. 
37+  * @property embedded `true` if the editor is embedded, which means that no titled separator is shown at the top, 
38+  * components are additionally indented, and the user cannot disable the array decorator; does not affect the value of 
39+  * [ArrayDecorator.enabled] 
3740 */  
3841class  ArrayDecoratorEditor (
3942    scheme :  ArrayDecorator ,
4043    private  val  embedded :  Boolean  = false ,
4144) : SchemeEditor<ArrayDecorator>(scheme) {
4245    override  val  rootComponent =  panel {
43-         separator(Bundle (" array.title" 
44-             .topGap(TopGap .MEDIUM )
45-             .visible(! embedded)
46- 
47-         indentedRowRange(indented =  ! embedded) {
46+         decoratedRowRange(title =  if  (! embedded) Bundle (" array.title" else  null , indent =  ! embedded) {
4847            lateinit  var  enabledCheckBox:  Cell <JCheckBox >
48+             lateinit  var  isEnabled:  ComponentPredicate 
4949
5050            row {
5151                checkBox(Bundle (" array.ui.enabled" 
5252                    .loadMnemonic()
5353                    .withName(" arrayEnabled" 
5454                    .bindSelected(scheme::enabled)
5555                    .also  { enabledCheckBox =  it }
56+                     .also  { isEnabled =  enabledCheckBox.selected.or (LiteralPredicate (embedded)) }
5657            }.visible(! embedded)
5758
58-             indentedRowRange(indented  =  ! embedded) {
59+             decoratedRowRange(indent  =  ! embedded) {
5960                lateinit  var  minCountSpinner:  JIntSpinner 
6061                lateinit  var  maxCountSpinner:  JIntSpinner 
6162
@@ -86,7 +87,7 @@ class ArrayDecoratorEditor(
8687                        .also  { separatorEnabledCheckBox =  it.component }
8788
8889                    cell(ComboBox (PRESET_SEPARATORS ))
89-                         .enabledIf(enabledCheckBox.selected .and (separatorEnabledCheckBox.selected))
90+                         .enabledIf(isEnabled .and (separatorEnabledCheckBox.selected))
9091                        .isEditable(true )
9192                        .withName(" arraySeparator" 
9293                        .bindCurrentText(scheme::separator)
@@ -96,14 +97,14 @@ class ArrayDecoratorEditor(
9697                    AffixDecoratorEditor (
9798                        scheme.affixDecorator,
9899                        PRESET_AFFIX_DECORATOR_DESCRIPTORS ,
99-                         enabledIf =  enabledCheckBox.selected ,
100+                         enabledIf =  isEnabled ,
100101                        enableMnemonic =  false ,
101102                        namePrefix =  " array" 
102103                    )
103104                        .also  { decoratorEditors + =  it }
104105                        .let  { cell(it.rootComponent) }
105106                }
106-             }.enabledIf(enabledCheckBox.selected )
107+             }.enabledIf(isEnabled )
107108        }
108109    }
109110
0 commit comments