-
Notifications
You must be signed in to change notification settings - Fork 5
/
GSBooleanHolderEditor.java
43 lines (35 loc) · 1.27 KB
/
GSBooleanHolderEditor.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package org.genericsystem.reactor.ca_gscomponents;
import org.genericsystem.reactor.Tag;
import org.genericsystem.reactor.aa_modelproperties.GSBuilderDefaults;
import org.genericsystem.reactor.ca_gscomponents.GSCheckBoxWithValue.GSCheckBoxEditor;
public class GSBooleanHolderEditor extends GSDiv {
protected GSCheckBoxWithValue checkbox;
public GSBooleanHolderEditor(Tag parent) {
this(parent, GSCheckBoxEditor::new);
}
public GSBooleanHolderEditor(Tag parent, GSCheckBoxConstructor constructor) {
super(parent, FlexDirection.ROW);
addStyle("flex", "1");
new GSDiv(this, FlexDirection.ROW) {
{
addStyle("flex", "1");
addStyle("justify-content", "center");
addStyle("align-items", "center");
checkbox = constructor.build(this);
}
};
}
@FunctionalInterface
public interface GSCheckBoxConstructor {
GSCheckBoxWithValue build(Tag parent);
}
public static class GSBooleanHolderBuilder extends GSBooleanHolderEditor implements GSBuilderDefaults {
public GSBooleanHolderBuilder(Tag parent) {
super(parent, GSCheckBoxWithValue::new);
checkbox.addPrefixBinding(model -> {
if (getHoldersMapProperty(model) != null)
getHoldersMapProperty(model).getValue().put(model.getGeneric(), checkbox.getConvertedValueProperty(model));
});
}
}
}