-
Notifications
You must be signed in to change notification settings - Fork 5
/
GSHolderEditor.java
50 lines (40 loc) · 1.51 KB
/
GSHolderEditor.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
44
45
46
47
48
49
50
package org.genericsystem.reactor.gs;
import org.genericsystem.reactor.Tag;
import org.genericsystem.reactor.gs.GSInputTextWithConversion.GSInputTextEditorWithConversion;
import org.genericsystem.reactor.modelproperties.GSBuilderDefaults;
public class GSHolderEditor extends GSDiv {
protected GSInputTextWithConversion<?> input;
public GSHolderEditor() {
this(GSInputTextEditorWithConversion::new);
}
public GSHolderEditor(Tag parent) {
this(parent, GSInputTextEditorWithConversion::new);
}
public GSHolderEditor(GSInputTextConstructor constructor) {
super(FlexDirection.ROW);
addStyle("flex", "1");
input = constructor.build(this);
input.addStyle("flex", "1");
}
public GSHolderEditor(Tag parent, GSInputTextConstructor constructor) {
super(parent, FlexDirection.ROW);
addStyle("flex", "1");
input = constructor.build(this);
input.addStyle("flex", "1 1 100%");
}
@FunctionalInterface
public interface GSInputTextConstructor {
GSInputTextWithConversion<?> build(Tag parent);
}
public static class GSHolderBuilder extends GSHolderEditor implements GSBuilderDefaults {
public GSHolderBuilder(Tag parent) {
super(parent, GSInputTextWithConversion::new);
input.addPrefixBinding(model -> {
if (getHoldersMapProperty(model) != null)
getHoldersMapProperty(model).getValue().put(model.getGeneric(), input.getConvertedValueProperty(model));
if (getInvalidListProperty(model) != null)
getInvalidListProperty(model).getValue().add(input.getInvalidObservable(model));
});
}
}
}