-
Notifications
You must be signed in to change notification settings - Fork 5
/
GSCellDisplayer.java
196 lines (163 loc) · 7.91 KB
/
GSCellDisplayer.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
package org.genericsystem.reactor.gs;
import org.genericsystem.reactor.Model;
import org.genericsystem.reactor.Tag;
import org.genericsystem.reactor.gs.GSBooleanHolderEditor.GSBooleanHolderAdder;
import org.genericsystem.reactor.gs.GSBooleanHolderEditor.GSBooleanHolderCreator;
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.GSHolderCreator;
import org.genericsystem.reactor.gs.GSHolderEditor.GSHolderEditorWithRemoval;
import org.genericsystem.reactor.gs.GSLinkEditor.GSLinkAdder;
import org.genericsystem.reactor.gs.GSLinkEditor.GSLinkCreator;
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.GSLabel.GSLabelDisplayer;
import org.genericsystem.reactor.model.GenericModel;
import org.genericsystem.reactor.model.StringExtractor;
public class GSCellDisplayer extends GSSection {
protected final GSTagConstructor holderDisplayerConstructor;
protected final GSTagConstructor booleanHolderDisplayerConstructor;
protected final GSTagConstructor linkDisplayerConstructor;
private final boolean needMeta;
public GSCellDisplayer(GSTag parent, GSTagConstructor holderDisplayerConstructor, GSTagConstructor booleanHolderDisplayerConstructor, GSTagConstructor linkDisplayerConstructor) {
this(parent, FlexDirection.ROW, holderDisplayerConstructor, booleanHolderDisplayerConstructor, linkDisplayerConstructor);
}
public GSCellDisplayer(GSTag parent, FlexDirection direction, GSTagConstructor holderDisplayerConstructor, GSTagConstructor booleanHolderDisplayerConstructor, GSTagConstructor linkDisplayerConstructor) {
this(parent, direction, holderDisplayerConstructor, booleanHolderDisplayerConstructor, linkDisplayerConstructor, true);
}
public GSCellDisplayer(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(Tag<?> 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 GSCellEditor extends GSCellDisplayer {
public GSCellEditor(GSTag parent) {
this(parent, FlexDirection.ROW);
}
public GSCellEditor(GSTag parent, FlexDirection direction) {
this(parent, direction, GSHolderEditor::new, GSBooleanHolderEditor::new, GSLinkEditor::new);
}
public GSCellEditor(GSTag parent, GSTagConstructor holderEditorConstructor, GSTagConstructor booleanHolderEditorConstructor, GSTagConstructor linkEditorConstructor) {
this(parent, FlexDirection.ROW, holderEditorConstructor, booleanHolderEditorConstructor, linkEditorConstructor);
}
public GSCellEditor(GSTag parent, FlexDirection direction, GSTagConstructor holderEditorConstructor, GSTagConstructor booleanHolderEditorConstructor, GSTagConstructor linkEditorConstructor) {
super(parent, direction, holderEditorConstructor, booleanHolderEditorConstructor, linkEditorConstructor, false);
}
@Override
public void style(Tag<?> tag) {
super.style(tag);
tag.addStyle("color", "#ffffff");
tag.addStyle("background-color", "#dda5e2");
}
}
public static class GSCellEditorWithRemoval extends GSCellEditor {
public GSCellEditorWithRemoval(GSTag parent) {
this(parent, FlexDirection.ROW);
}
public GSCellEditorWithRemoval(GSTag parent, FlexDirection direction) {
super(parent, direction, GSHolderEditorWithRemoval::new, GSBooleanHolderEditorWithRemoval::new, GSLinkEditorWithRemoval::new);
}
}
public static class GSCellAdder extends GSCellEditor {
public GSCellAdder(GSTag parent) {
this(parent, FlexDirection.ROW);
}
public GSCellAdder(GSTag parent, FlexDirection direction) {
super(parent, direction, GSHolderAdder::new, GSBooleanHolderAdder::new, GSLinkAdder::new);
}
}
public static class GSInstanceCellDisplayer extends GSCellDisplayer {
public GSInstanceCellDisplayer(GSTag parent) {
super(parent, GSLabelDisplayer::new, GSCheckBoxDisplayer::new, GSLinkComponentsDisplayer::new);
}
@Override
public void style(Tag<?> tag) {
super.style(tag);
tag.addPrefixBinding(modelContext -> ((Model) modelContext).getObservableStyles(tag).put("background-color",
"Color".equals(StringExtractor.SIMPLE_CLASS_EXTRACTOR.apply(((GenericModel) modelContext).getGeneric().getMeta())) ? getString((GenericModel) modelContext).getValue() : "#dda5e2"));
}
}
public static class LinkTitleDisplayer extends GSCellDisplayer {
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(Tag<?> tag) {
super.style(tag);
tag.addStyle("color", "#ffffff");
tag.addStyle("background-color", "#ffa5a5");
}
}
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 GSAttributeCreator extends GSCellEditor {
public GSAttributeCreator(GSTag parent, FlexDirection direction) {
super(parent, direction, GSHolderCreator::new, GSBooleanHolderCreator::new, GSLinkCreator::new);
}
@Override
public void style(Tag<?> 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");
}
}
}