-
Notifications
You must be signed in to change notification settings - Fork 5
/
WatchApp.java
102 lines (88 loc) · 4.37 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
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.reactor.Context;
import org.genericsystem.reactor.Tag;
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.SelectContext;
import org.genericsystem.reactor.annotations.SetText;
import org.genericsystem.reactor.annotations.Style;
import org.genericsystem.reactor.annotations.Style.FlexDirectionStyle;
import org.genericsystem.reactor.appserver.ApplicationServer;
import org.genericsystem.reactor.context.ContextAction;
import org.genericsystem.reactor.context.ContextAction.MODAL_DISPLAY_FLEX;
import org.genericsystem.reactor.context.ContextAction.SET_SELECTION;
import org.genericsystem.reactor.context.ObservableContextSelector.SELECTION_SELECTOR;
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.HtmlButton;
import org.genericsystem.reactor.gscomponents.HtmlTag.HtmlH1;
import org.genericsystem.reactor.gscomponents.HtmlTag.HtmlImg;
import org.genericsystem.reactor.gscomponents.Modal.ModalEditor;
import org.genericsystem.reactor.gscomponents.RootTagImpl;
import javafx.beans.property.SimpleStringProperty;
import javafx.collections.ObservableList;
@DependsOnModel({ Doc.class, DocClass.class, ZoneGeneric.class, ZoneText.class, ImgFilter.class })
//@Style(name = "background-color", value = "#ffffff")
@Children({ AppHeader.class, DocumentsList.class })
@Style(path = AppHeader.class, name = "background-color", value = "#00afeb")
@Children(path = AppHeader.class, value = { Logo.class, AppTitleDiv.class })
@SetText(path = { AppHeader.class, AppTitleDiv.class, HtmlH1.class }, value = "GS-Watch interface")
public class WatchApp extends RootTagImpl {
private static final String gsPath = "/gs-cv_model";
private static final String docClass = "id-fr-front";
public static void main(String[] mainArgs) {
ApplicationServer.startSimpleGenericApp(mainArgs, WatchApp.class, gsPath);
}
@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({ EditDocumentZones.class, DocumentEditButton.class })
public static class DocumentEditButtonDiv extends FlexDiv {
}
@SetText("Edit")
@Style(name = "flex", value = "0 0 auto")
@BindAction({ SET_SELECTION.class, MODAL_DISPLAY_FLEX.class })
public static class DocumentEditButton extends HtmlButton {
// TODO: change the way the context is loaded (currently, everything is loaded for every file)
}
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);
Snapshot<Generic> docInstances = currentDocClass.getHolders(root.find(Doc.class));
return docInstances.toObservableList();
}
}
}