-
Notifications
You must be signed in to change notification settings - Fork 5
/
GSMonitor.java
58 lines (51 loc) · 1.52 KB
/
GSMonitor.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
package org.genericsystem.reactor.gs;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import org.genericsystem.common.Statics;
import org.genericsystem.reactor.Context;
import org.genericsystem.reactor.Tag;
import org.genericsystem.reactor.gstag.HtmlButton;
import org.genericsystem.reactor.gstag.HtmlLabel;
import javafx.beans.binding.Bindings;
public class GSMonitor extends GSDiv {
public GSMonitor(Tag parent) {
this(parent, FlexDirection.ROW);
}
public GSMonitor(Tag parent, FlexDirection direction) {
super(parent, direction);
addStyle("justify-content", "space-around");
addStyle("padding", "10px");
new HtmlButton(this) {
{
setText("Save");
bindAction(Context::flush);
}
};
new HtmlButton(this) {
{
setText("Cancel");
bindAction(Context::cancel);
}
};
new HtmlLabel(this) {
{
bindText(context -> Bindings.createStringBinding(() -> {
Long tsMs = (Long) context.getTsObservableValue().getValue() / Statics.MILLI_TO_NANOSECONDS;
Date dateMs = new Date(tsMs);
Instant instant = Instant.ofEpochMilli(dateMs.getTime());
LocalDateTime ldt = LocalDateTime.ofInstant(instant, ZoneOffset.systemDefault());
return "Last update : " + ldt.format(DateTimeFormatter.ofPattern("uuuu-MM-dd HH:mm:ss"));
}, context.getTsObservableValue()));
}
};
// new GSButton(this) {
// {
// setText("Collect");
// bindAction(model -> System.gc());
// }
// };
}
}