-
Notifications
You must be signed in to change notification settings - Fork 5
/
GSEditor.java
122 lines (113 loc) · 3.69 KB
/
GSEditor.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
package org.genericsystem.reactor.gs;
import org.genericsystem.api.core.ApiStatics;
import org.genericsystem.reactor.gs.GSLinks.LinkAdder;
import org.genericsystem.reactor.gs.GSLinks.LinkEditor;
import org.genericsystem.reactor.gs.GSLinks.LinkEditorWithRemoval;
import org.genericsystem.reactor.gs.GSLinks.LinkTitleDisplayer;
import org.genericsystem.reactor.gstag.GSH1;
import org.genericsystem.reactor.model.GenericModel;
import org.genericsystem.reactor.model.ObservableListExtractor;
import org.genericsystem.reactor.model.StringExtractor;
/**
* @author Nicolas Feybesse
*
* @param <M>
*/
public class GSEditor extends GSComposite {
public GSEditor(GSTag parent) {
this(parent, FlexDirection.COLUMN);
}
public GSEditor(GSTag parent, FlexDirection flexDirection) {
super(parent, flexDirection);
addStyle("flex", "1");
}
@Override
protected void header() {
new GSSection(this, GSEditor.this.getReverseDirection()) {
{
addStyle("flex", "0.3");
addStyle("background-color", "#ffa500");
addStyle("margin-right", "1px");
addStyle("margin-bottom", "1px");
addStyle("color", "red");
addStyle("justify-content", "center");
addStyle("align-items", "center");
new GSH1(this) {
{
bindText(GenericModel::getString);
}
};
}
};
}
@Override
protected void sections() {
new GSComposite(this, GSEditor.this.getReverseDirection()) {
{
addStyle("flex", "1");
}
@Override
protected void header() {
new GSSection(this, GSEditor.this.getDirection()) {
{
addStyle("flex", "0.3");
new LinkTitleDisplayer(this, gs -> ObservableListExtractor.COMPONENTS.apply(gs).filtered(g -> !g.equals(gs[1].getMeta())), GSEditor.this.getDirection()) {
{
addStyle("flex", "1");
addStyle("overflow", "hidden");
select(StringExtractor.SIMPLE_CLASS_EXTRACTOR, gs -> gs[0].getMeta());
}
};
new LinkTitleDisplayer(this, gs -> ObservableListExtractor.COMPONENTS.apply(gs).filtered(g -> !g.equals(gs[1].getMeta())), GSEditor.this.getDirection()) {
{
addStyle("flex", "1");
addStyle("overflow", "hidden");
forEach(StringExtractor.SIMPLE_CLASS_EXTRACTOR, ObservableListExtractor.ATTRIBUTES_OF_INSTANCES);
}
};
}
};
}
@Override
protected void sections() {
new GSSection(this, GSEditor.this.getDirection()) {
{
addStyle("flex", "1");
new GSSection(this, GSEditor.this.getReverseDirection()) {
{
addStyle("flex", "1");
addStyle("overflow", "hidden");
new LinkEditor(this, GSEditor.this.getDirection()) {
{
addStyle("flex", "1");
select(StringExtractor.SIMPLE_CLASS_EXTRACTOR, gs -> gs[0]);
}
};
}
};
new GSSection(this, GSEditor.this.getReverseDirection()) {
{
forEach(StringExtractor.SIMPLE_CLASS_EXTRACTOR, ObservableListExtractor.ATTRIBUTES_OF_INSTANCES);
addStyle("flex", "1");
addStyle("overflow", "hidden");
new LinkEditorWithRemoval(this, GSEditor.this.getDirection()) {
{
addStyle("flex", "1");
forEach(StringExtractor.SIMPLE_CLASS_EXTRACTOR, ObservableListExtractor.HOLDERS);
}
};
new LinkAdder(this, GSEditor.this.getDirection()) {
{
addStyle("flex", "1");
select(StringExtractor.SIMPLE_CLASS_EXTRACTOR, gs -> ObservableListExtractor.HOLDERS.apply(gs).isEmpty() || (gs[0].getComponents().size() < 2 && !gs[0].isPropertyConstraintEnabled())
|| (gs[0].getComponents().size() >= 2 && !gs[0].isSingularConstraintEnabled(ApiStatics.BASE_POSITION)) ? gs[0] : null);
}
};
}
};
}
};
};
};
}
}