-
Notifications
You must be signed in to change notification settings - Fork 5
/
GSTable.java
202 lines (167 loc) · 7.32 KB
/
GSTable.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
package org.genericsystem.reactor.ca_gscomponents2;
import org.genericsystem.reactor.Context;
import org.genericsystem.reactor.Tag;
import org.genericsystem.reactor.aa_modelproperties.GenericStringDefaults;
import org.genericsystem.reactor.aa_modelproperties.SelectionDefaults;
import org.genericsystem.reactor.annotations.ForEach;
import org.genericsystem.reactor.annotations.ReactorDependencies;
import org.genericsystem.reactor.annotations.Select;
import org.genericsystem.reactor.annotations.Styles.Color;
import org.genericsystem.reactor.annotations.Styles.Flex;
import org.genericsystem.reactor.annotations.Styles.FlexDirectionStyle;
import org.genericsystem.reactor.annotations.Styles.Height;
import org.genericsystem.reactor.annotations.Styles.MarginBottom;
import org.genericsystem.reactor.annotations.Styles.MarginRight;
import org.genericsystem.reactor.annotations.Styles.ReverseFlexDirection;
import org.genericsystem.reactor.annotations.Styles.Width;
import org.genericsystem.reactor.ba_htmltag.HtmlButton;
import org.genericsystem.reactor.ba_htmltag.HtmlH2;
import org.genericsystem.reactor.ba_htmltag.HtmlHyperLink;
import org.genericsystem.reactor.ba_htmltag.HtmlLabel.GSLabelDisplayer;
import org.genericsystem.reactor.ca_gscomponents.FlexDirection;
import org.genericsystem.reactor.ca_gscomponents.GSCheckBoxWithValue.GSCheckBoxDisplayer;
import org.genericsystem.reactor.ca_gscomponents.GSDiv;
import org.genericsystem.reactor.ca_gscomponents2.DivWithTitle.GSTitleDiv;
import org.genericsystem.reactor.ca_gscomponents2.GSCellDiv.GSTitleLineCellDiv;
import org.genericsystem.reactor.ca_gscomponents2.GSTable.Row.Cell.SubCell.BooleanValueSubCell.BooleanDisplayer;
import org.genericsystem.reactor.ca_gscomponents2.GSTable.Row.Cell.SubCell.ComponentSubCell.ComponentLabel;
import org.genericsystem.reactor.ca_gscomponents2.GSTable.Row.Cell.SubCell.ValueSubCell.ValueDisplayer;
import org.genericsystem.reactor.ca_gscomponents2.GSTable.Row.RemoveButtonDiv.RemoveButton;
import org.genericsystem.reactor.ca_gscomponents2.GSTable.Row.RowName.RowNameDisplayer;
import org.genericsystem.reactor.ca_gscomponents2.GSTable.TableTitle.TableTitleContent;
import org.genericsystem.reactor.ca_gscomponents2.GSTable.TitleRow.EmptyCell;
import org.genericsystem.reactor.ca_gscomponents2.GSTable.TitleRow.TypeAttribute.AttributeName.AttributeNameDisplayer;
import org.genericsystem.reactor.ca_gscomponents2.GSTable.TitleRow.TypeAttribute.RelationName.ComponentName.ComponentNameDisplayer;
import org.genericsystem.reactor.ca_gscomponents2.GSTable.TitleRow.TypeName.TypeNameDisplayer;
import org.genericsystem.reactor.model.ObservableListExtractor.ATTRIBUTES_OF_INSTANCES;
import org.genericsystem.reactor.model.ObservableListExtractor.ATTRIBUTES_OF_TYPE;
import org.genericsystem.reactor.model.ObservableListExtractor.HOLDERS;
import org.genericsystem.reactor.model.ObservableListExtractor.OTHER_COMPONENTS_1;
import org.genericsystem.reactor.model.ObservableListExtractor.OTHER_COMPONENTS_2;
import org.genericsystem.reactor.model.ObservableListExtractor.SUBINSTANCES;
import org.genericsystem.reactor.model.ObservableValueSelector.CHECK_BOX_DISPLAYER;
import org.genericsystem.reactor.model.ObservableValueSelector.LABEL_DISPLAYER;
import org.genericsystem.reactor.model.ObservableValueSelector.RELATION_SELECTOR;
import org.genericsystem.reactor.model.ObservableValueSelector.STRICT_ATTRIBUTE_SELECTOR;
import org.genericsystem.reactor.model.StringExtractor;
@ReactorDependencies({ TableTitleContent.class, TypeNameDisplayer.class, AttributeNameDisplayer.class, ComponentNameDisplayer.class, GSInstanceBuilder.class, RowNameDisplayer.class, ComponentLabel.class, EmptyCell.class, BooleanDisplayer.class,
ValueDisplayer.class, RemoveButton.class })
@Flex("1")
public class GSTable extends GSDiv implements SelectionDefaults, Tag {
public GSTable() {
super();
}
public GSTable(Tag parent) {
super(parent);
}
// No automatic enclosing class parent for this GSTable extention
@FlexDirectionStyle(FlexDirection.ROW)
public static class HorizontalTable extends GSTable {
public HorizontalTable(Tag parent) {
super(parent);
}
}
@Override
public void postfix() {
bindSelection(find(Row.class));
}
public static class TableTitle extends GSTitleDiv {
public static class TableTitleContent extends HtmlH2 {
@Override
public void init() {
setStringExtractor(StringExtractor.MANAGEMENT);
bindText();
}
}
}
@ReverseFlexDirection
@Flex("1")
public static class TitleRow extends GSDiv {
public static class TypeName extends GSTitleLineCellDiv {
public static class TypeNameDisplayer extends GSLabelDisplayer {
}
}
@ForEach(ATTRIBUTES_OF_TYPE.class)
@Flex("1")
@FlexDirectionStyle(FlexDirection.ROW)
public static class TypeAttribute extends GSDiv {
@Select(STRICT_ATTRIBUTE_SELECTOR.class)
public static class AttributeName extends GSTitleLineCellDiv {
public static class AttributeNameDisplayer extends GSLabelDisplayer {
}
}
@Select(RELATION_SELECTOR.class)
@Flex("1")
@FlexDirectionStyle(FlexDirection.ROW)
public static class RelationName extends GSDiv {
@ForEach(OTHER_COMPONENTS_1.class)
public static class ComponentName extends GSTitleLineCellDiv {
public static class ComponentNameDisplayer extends GSLabelDisplayer {
}
}
@ForEach(OTHER_COMPONENTS_2.class)
public static class InstanceComponentName extends ComponentName {
}
}
}
// EmptyCell corresponding to the “Remove” or “Add” button of other lines.
public static class EmptyCell extends InstancesTable.ButtonDiv {
}
}
@ForEach(SUBINSTANCES.class)
@ReverseFlexDirection
@Flex("1")
public static class Row extends GSDiv {
public static class RowName extends GSCellDiv {
@Flex("1")
@Color("white")
@MarginRight("1px")
@MarginBottom("1px")
public static class RowNameDisplayer extends HtmlHyperLink {
@Override
public void init() {
bindText();
bindAction(model -> getSelectionProperty(model).setValue(model));
addPrefixBinding(modelContext -> addStyle(modelContext, "background-color",
"Color".equals(StringExtractor.SIMPLE_CLASS_EXTRACTOR.apply(modelContext.getGeneric().getMeta())) ? ((GenericStringDefaults) this).getGenericStringProperty(modelContext).getValue() : "#3393FF"));
}
}
}
@ForEach(ATTRIBUTES_OF_INSTANCES.class)
public static class Cell extends GSCellDiv {
@ForEach(HOLDERS.class)
@Flex("1")
@FlexDirectionStyle(FlexDirection.ROW)
public static class SubCell extends GSDiv {
@ForEach(OTHER_COMPONENTS_2.class)
public static class ComponentSubCell extends GSSubcellDiv {
public static class ComponentLabel extends GSLabelDisplayer {
}
}
@Select(CHECK_BOX_DISPLAYER.class)
public static class BooleanValueSubCell extends GSSubcellDiv {
public static class BooleanDisplayer extends GSCheckBoxDisplayer {
}
}
@Select(LABEL_DISPLAYER.class)
public static class ValueSubCell extends GSSubcellDiv {
public static class ValueDisplayer extends GSLabelDisplayer {
}
}
}
}
// Button to delete the instance.
public static class RemoveButtonDiv extends InstancesTable.ButtonDiv {
@Flex("1")
@Height("100%")
@Width("100%")
public static class RemoveButton extends HtmlButton {
@Override
public void init() {
setText("Remove");
bindAction(Context::remove);
}
}
}
}
}