-
Notifications
You must be signed in to change notification settings - Fork 5
/
GSSubcellDisplayer.java
204 lines (169 loc) · 8.15 KB
/
GSSubcellDisplayer.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
package org.genericsystem.reactor.gs;
import org.genericsystem.reactor.Model;
import org.genericsystem.reactor.gs.GSBooleanHolderEditor.GSBooleanHolderAdder;
import org.genericsystem.reactor.gs.GSBooleanHolderEditor.GSBooleanHolderBuilder;
import org.genericsystem.reactor.gs.GSBooleanHolderEditor.GSBooleanHolderEditorWithRemoval;
import org.genericsystem.reactor.gs.GSCheckBoxWithValue.GSCheckBoxDisplayer;
import org.genericsystem.reactor.gs.GSHolderEditor.GSHolderAdder;
import org.genericsystem.reactor.gs.GSHolderEditor.GSHolderBuilder;
import org.genericsystem.reactor.gs.GSHolderEditor.GSHolderEditorWithRemoval;
import org.genericsystem.reactor.gs.GSLinkEditor.GSLinkAdder;
import org.genericsystem.reactor.gs.GSLinkEditor.GSLinkBuilder;
import org.genericsystem.reactor.gs.GSLinkEditor.GSLinkEditorWithRemoval;
import org.genericsystem.reactor.gs.GSSingleLinkComponentDisplayer.GSInstanceLinkComponentsTitleDisplayer;
import org.genericsystem.reactor.gs.GSSingleLinkComponentDisplayer.GSLinkComponentsDisplayer;
import org.genericsystem.reactor.gs.GSSingleLinkComponentDisplayer.GSLinkComponentsTitleDisplayer;
import org.genericsystem.reactor.gstag.HtmlLabel.GSLabelDisplayer;
import org.genericsystem.reactor.model.StringExtractor;
public class GSSubcellDisplayer extends GSSection {
protected final GSTagConstructor holderDisplayerConstructor;
protected final GSTagConstructor booleanHolderDisplayerConstructor;
protected final GSTagConstructor linkDisplayerConstructor;
private final boolean needMeta;
public GSSubcellDisplayer(GSTag parent, GSTagConstructor holderDisplayerConstructor, GSTagConstructor booleanHolderDisplayerConstructor, GSTagConstructor linkDisplayerConstructor) {
this(parent, FlexDirection.ROW, holderDisplayerConstructor, booleanHolderDisplayerConstructor, linkDisplayerConstructor);
}
public GSSubcellDisplayer(GSTag parent, FlexDirection direction, GSTagConstructor holderDisplayerConstructor, GSTagConstructor booleanHolderDisplayerConstructor, GSTagConstructor linkDisplayerConstructor) {
this(parent, direction, holderDisplayerConstructor, booleanHolderDisplayerConstructor, linkDisplayerConstructor, true);
}
public GSSubcellDisplayer(GSTag parent, FlexDirection direction, GSTagConstructor holderDisplayerConstructor, GSTagConstructor booleanHolderDisplayerConstructor, GSTagConstructor linkDisplayerConstructor, boolean needMeta) {
super(parent, direction);
this.holderDisplayerConstructor = holderDisplayerConstructor;
this.booleanHolderDisplayerConstructor = booleanHolderDisplayerConstructor;
this.linkDisplayerConstructor = linkDisplayerConstructor;
this.needMeta = needMeta;
addStyle("flex", "1");
addStyle("overflow", "hidden");
content();
}
public void content() {
new GSSection(this, this.getDirection()) {
{
style(this);
if (needMeta)
select(gs -> gs[0].getComponents().size() < 2 && !Boolean.class.equals(gs[0].getMeta().getInstanceValueClassConstraint()) ? gs[0] : null);
else
select(gs -> gs[0].getComponents().size() < 2 && !Boolean.class.equals(gs[0].getInstanceValueClassConstraint()) ? gs[0] : null);
holderDisplayerConstructor.build(this);
}
};
new GSSection(this, this.getDirection()) {
{
style(this);
if (needMeta)
select(gs -> gs[0].getComponents().size() < 2 && Boolean.class.equals(gs[0].getMeta().getInstanceValueClassConstraint()) ? gs[0] : null);
else
select(gs -> gs[0].getComponents().size() < 2 && Boolean.class.equals(gs[0].getInstanceValueClassConstraint()) ? gs[0] : null);
booleanHolderDisplayerConstructor.build(this);
}
};
new GSSection(this, this.getDirection()) {
{
addStyle("flex", "1");
select(gs -> gs[0].getComponents().size() >= 2 ? gs[0] : null);
GSTag components = linkDisplayerConstructor.build(this);
style(components);
}
};
}
public void style(GSTag tag) {
tag.addStyle("justify-content", "center");
tag.addStyle("align-items", "center");
tag.addStyle("flex", "1");
tag.addStyle("margin-right", "1px");
tag.addStyle("margin-bottom", "1px");
tag.addStyle("overflow", "hidden");
}
public static class GSSubcellEditor extends GSSubcellDisplayer {
public GSSubcellEditor(GSTag parent) {
this(parent, FlexDirection.ROW);
}
public GSSubcellEditor(GSTag parent, FlexDirection direction) {
this(parent, direction, GSHolderEditor::new, GSBooleanHolderEditor::new, GSLinkEditor::new);
}
public GSSubcellEditor(GSTag parent, GSTagConstructor holderEditorConstructor, GSTagConstructor booleanHolderEditorConstructor, GSTagConstructor linkEditorConstructor) {
this(parent, FlexDirection.ROW, holderEditorConstructor, booleanHolderEditorConstructor, linkEditorConstructor);
}
public GSSubcellEditor(GSTag parent, FlexDirection direction, GSTagConstructor holderEditorConstructor, GSTagConstructor booleanHolderEditorConstructor, GSTagConstructor linkEditorConstructor) {
super(parent, direction, holderEditorConstructor, booleanHolderEditorConstructor, linkEditorConstructor, false);
}
@Override
public void style(GSTag tag) {
super.style(tag);
tag.addStyle("color", "#ffffff");
tag.addStyle("background-color", "#dda5e2");
tag.addStyle("justify-content", "flex-start");
tag.addStyle("align-items", "stretch");
}
}
public static class GSSubcellEditorWithRemoval extends GSSubcellEditor {
public GSSubcellEditorWithRemoval(GSTag parent) {
this(parent, FlexDirection.ROW);
}
public GSSubcellEditorWithRemoval(GSTag parent, FlexDirection direction) {
super(parent, direction, GSHolderEditorWithRemoval::new, GSBooleanHolderEditorWithRemoval::new, GSLinkEditorWithRemoval::new);
}
}
public static class GSSubcellAdder extends GSSubcellEditor {
public GSSubcellAdder(GSTag parent) {
this(parent, FlexDirection.ROW);
}
public GSSubcellAdder(GSTag parent, FlexDirection direction) {
super(parent, direction, GSHolderAdder::new, GSBooleanHolderAdder::new, GSLinkAdder::new);
}
}
public static class GSInstanceSubcellDisplayer extends GSSubcellDisplayer {
public GSInstanceSubcellDisplayer(GSTag parent) {
super(parent, GSLabelDisplayer::new, GSCheckBoxDisplayer::new, GSLinkComponentsDisplayer::new);
}
@Override
public void style(GSTag tag) {
super.style(tag);
tag.addPrefixBinding(modelContext -> ((Model) modelContext).getObservableStyles(tag).put("background-color",
"Color".equals(StringExtractor.SIMPLE_CLASS_EXTRACTOR.apply(modelContext.getGeneric().getMeta())) ? tag.getGenericStringProperty(modelContext).getValue() : "#dda5e2"));
}
}
public static class LinkTitleDisplayer extends GSSubcellDisplayer {
public LinkTitleDisplayer(GSTag parent) {
this(parent, GSLabelDisplayer::new, GSCheckBoxDisplayer::new, GSLinkComponentsTitleDisplayer::new);
}
public LinkTitleDisplayer(GSTag parent, GSTagConstructor holderDisplayerConstructor, GSTagConstructor booleanHolderDisplayerConstructor, GSTagConstructor linkDisplayerConstructor) {
super(parent, FlexDirection.ROW, holderDisplayerConstructor, booleanHolderDisplayerConstructor, linkDisplayerConstructor);
}
@Override
public void style(GSTag tag) {
super.style(tag);
tag.addStyle("color", "#ffffff");
tag.addStyle("background-color", "#ffa5a5");
}
}
public static class InstanceTitleDisplayer extends InstanceLinkTitleDisplayer {
public InstanceTitleDisplayer(GSTag parent) {
super(parent);
select(gs -> gs[0].getMeta());
}
}
public static class InstanceLinkTitleDisplayer extends LinkTitleDisplayer {
public InstanceLinkTitleDisplayer(GSTag parent) {
super(parent, GSLabelDisplayer::new, GSCheckBoxDisplayer::new, GSInstanceLinkComponentsTitleDisplayer::new);
}
}
@FunctionalInterface
public interface GSTagConstructor {
GSTag build(GSTag parent);
}
public static class GSAttributeBuilder extends GSSubcellEditor {
public GSAttributeBuilder(GSTag parent, FlexDirection direction) {
super(parent, direction, GSHolderBuilder::new, GSBooleanHolderBuilder::new, GSLinkBuilder::new);
}
@Override
public void style(GSTag tag) {
tag.addStyle("flex", "1");
tag.addStyle("color", "#ffffff");
tag.addStyle("background-color", "#dda5a5");
tag.addStyle("margin-right", "1px");
tag.addStyle("margin-bottom", "1px");
tag.addStyle("overflow", "hidden");
}
}
}