-
Notifications
You must be signed in to change notification settings - Fork 5
/
WatchApp.java
119 lines (101 loc) · 5.14 KB
/
WatchApp.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
package org.genericsystem.cv.watch;
import org.genericsystem.api.core.Snapshot;
import org.genericsystem.common.Generic;
import org.genericsystem.common.Root;
import org.genericsystem.cv.model.Doc;
import org.genericsystem.cv.model.DocClass;
import org.genericsystem.cv.model.ImgFilter;
import org.genericsystem.cv.model.ZoneGeneric;
import org.genericsystem.cv.model.ZoneText;
import org.genericsystem.cv.watch.WatchApp.DocumentsList;
import org.genericsystem.cv.watch.WatchApp.HeaderRow;
import org.genericsystem.reactor.annotations.Attribute;
import org.genericsystem.reactor.annotations.BindAction;
import org.genericsystem.reactor.annotations.BindText;
import org.genericsystem.reactor.annotations.Children;
import org.genericsystem.reactor.annotations.DependsOnModel;
import org.genericsystem.reactor.annotations.ForEach;
import org.genericsystem.reactor.annotations.SetText;
import org.genericsystem.reactor.annotations.Style;
import org.genericsystem.reactor.annotations.StyleClass;
import org.genericsystem.reactor.annotations.Style.FlexDirectionStyle;
import org.genericsystem.reactor.appserver.ApplicationServer;
import org.genericsystem.reactor.context.ContextAction.SET_SELECTION;
import org.genericsystem.reactor.context.ObservableListExtractor;
import org.genericsystem.reactor.gscomponents.AppHeader;
import org.genericsystem.reactor.gscomponents.AppHeader.AppTitleDiv;
import org.genericsystem.reactor.gscomponents.AppHeader.Logo;
import org.genericsystem.reactor.gscomponents.FlexDirection;
import org.genericsystem.reactor.gscomponents.FlexDiv;
import org.genericsystem.reactor.gscomponents.HtmlTag.HtmlH1;
import org.genericsystem.reactor.gscomponents.HtmlTag.HtmlH2;
import org.genericsystem.reactor.gscomponents.HtmlTag.HtmlH4;
import org.genericsystem.reactor.gscomponents.HtmlTag.HtmlHyperLink;
import org.genericsystem.reactor.gscomponents.HtmlTag.HtmlImg;
import org.genericsystem.reactor.gscomponents.HtmlTag.HtmlLabel;
import org.genericsystem.reactor.gscomponents.Monitor;
import org.genericsystem.reactor.gscomponents.RootTagImpl;
import javafx.collections.ObservableList;
@DependsOnModel({ Doc.class, DocClass.class, ZoneGeneric.class, ZoneText.class, ImgFilter.class })
@Children({ EditDocumentZones.class, AppHeader.class, FlexDiv.class, Monitor.class })
@Children(path = FlexDiv.class, pos = 2, value = { HeaderRow.class, DocumentsList.class })
@Children(path = AppHeader.class, value = { Logo.class, AppTitleDiv.class })
@Style(path = AppHeader.class, name = "background-color", value = "#00afeb")
@SetText(path = { AppHeader.class, AppTitleDiv.class, HtmlH1.class }, value = "GS-Watch interface")
public class WatchApp extends RootTagImpl {
private static final String gsPath = "/gs-cv_model3";
private static final String docClass = "id-fr-front";
public static void main(String[] mainArgs) {
ApplicationServer.startSimpleGenericApp(mainArgs, WatchApp.class, gsPath);
}
public WatchApp() {
addPrefixBinding(context -> getAdminModeProperty(context).setValue(true));
}
@Children({ HtmlLabel.class, HtmlLabel.class })
@FlexDirectionStyle(FlexDirection.ROW)
@Style(path = HtmlLabel.class, name = "justify-content", value = "center")
@Style(path = HtmlLabel.class, name = "align-items", value = "center")
@Style(path = HtmlLabel.class, name = "flex", value = "1 0 auto")
@Style(path = HtmlLabel.class, name = "text-align", value = "center")
@Style(path = HtmlLabel.class, name = "font-weight", value = "bold")
@SetText(path = HtmlLabel.class, value = { "Nom", "Superviser" })
public static class HeaderRow extends FlexDiv {
}
@ForEach(DOC_CLASS_SELECTOR.class)
@FlexDirectionStyle(FlexDirection.ROW)
@Style(name = "margin", value = "0.5em")
@Children({ DocumentName.class, DocumentEditButtonDiv.class })
public static class DocumentsList extends FlexDiv {
}
@BindText
@FlexDirectionStyle(FlexDirection.COLUMN)
@Style(name = "justify-content", value = "center")
@Style(name = "align-items", value = "center")
@Style(name = "flex", value = "1 0 auto")
public static class DocumentName extends FlexDiv {
}
@FlexDirectionStyle(FlexDirection.COLUMN)
@Style(name = "justify-content", value = "center")
@Style(name = "align-items", value = "center")
@Style(name = "flex", value = "1 0 auto")
@Children(DocumentEditButton.class)
public static class DocumentEditButtonDiv extends FlexDiv {
}
@Children(HtmlHyperLink.class)
@Children(path = HtmlHyperLink.class, value = HtmlImg.class)
@Attribute(path = { HtmlHyperLink.class, HtmlImg.class }, pos = { 0, 0 }, name = "src", value = "edit.png")
@StyleClass(path = { HtmlHyperLink.class, HtmlImg.class }, pos = { -1, 0 }, value = "img")
@BindAction(SET_SELECTION.class)
public static class DocumentEditButton extends DocumentEditButtonDiv {
}
public static class DOC_CLASS_SELECTOR implements ObservableListExtractor {
@Override
public ObservableList<Generic> apply(Generic[] generics) {
Root root = generics[0].getRoot();
Generic currentDocClass = root.find(DocClass.class).getInstance(docClass);
System.out.println("Current doc class : " + currentDocClass.info());
Snapshot<Generic> docInstances = currentDocClass.getHolders(root.find(Doc.class));
return docInstances.toObservableList();
}
}
}