-
Notifications
You must be signed in to change notification settings - Fork 5
/
CarColorApp.java
119 lines (109 loc) · 4.74 KB
/
CarColorApp.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.carcolor;
import io.vertx.core.http.ServerWebSocket;
import javafx.beans.binding.Bindings;
import org.genericsystem.api.core.ApiStatics;
import org.genericsystem.carcolor.model.Car;
import org.genericsystem.carcolor.model.CarColor;
import org.genericsystem.carcolor.model.Color;
import org.genericsystem.carcolor.model.Power;
import org.genericsystem.common.AbstractRoot;
import org.genericsystem.common.Generic;
import org.genericsystem.common.Statics;
import org.genericsystem.kernel.Engine;
import org.genericsystem.reactor.ReactorStatics;
import org.genericsystem.reactor.appserver.ApplicationServer;
import org.genericsystem.reactor.appserver.ApplicationsDeploymentConfig;
import org.genericsystem.reactor.flex.FlexDirection;
import org.genericsystem.reactor.flex.GenericDependenciesTable;
import org.genericsystem.reactor.flex.GenericEditor;
import org.genericsystem.reactor.flex.GenericSection;
import org.genericsystem.reactor.html.HtmlApp;
import org.genericsystem.reactor.html.HtmlHyperLink;
import org.genericsystem.reactor.model.EngineModel;
import org.genericsystem.reactor.model.GenericModel;
import org.genericsystem.reactor.model.StringExtractor;
public class CarColorApp extends HtmlApp<EngineModel> {
private static final String MAIN_COLOR = "#3393ff";
public static void main(String[] args) {
ApplicationsDeploymentConfig appsConfig = new ApplicationsDeploymentConfig(Statics.DEFAULT_HOST, args.length != 0 ? Integer.parseInt(args[0])
: Statics.DEFAULT_PORT);
appsConfig.addApplication("/", CarColorApp.class, EngineModel.class, Engine.class, System.getenv("HOME") + "/genericsystem/cars/", Car.class,
Power.class, Color.class, CarColor.class);
new ApplicationServer(appsConfig).start();
}
public CarColorApp(AbstractRoot engine, ServerWebSocket webSocket) {
super(webSocket);
runScript(engine);
new GenericSection(this, FlexDirection.COLUMN) {
{
addStyle("justify-content", "center");
new H1FlexElement(this, "Generic System Reactor Live Demo").addStyle("background-color", MAIN_COLOR);
new GenericSection(this, FlexDirection.COLUMN) {
{
createProperty(ReactorStatics.SELECTION);
new GenericDependenciesTable(this).select(StringExtractor.MANAGEMENT, Car.class);
new GenericSection(this, FlexDirection.COLUMN) {
{
addStyleClass("modal");
bindStyle(ReactorStatics.DISPLAY, ReactorStatics.DISPLAY,
model -> Bindings.createStringBinding(() -> getProperty(ReactorStatics.SELECTION, model).getValue() != null ? "flex" : "none", this.getProperty(ReactorStatics.SELECTION, model)));
new GenericSection(this, FlexDirection.COLUMN) {
{
addStyle("max-width", "40%");
addStyle("max-height", "40%");
addStyleClass("modal-content");
new HtmlHyperLink<GenericModel>(this) {
{
addStyleClass("close");
setText("×");
bindAction(model -> getProperty(ReactorStatics.SELECTION, model).setValue(null));
}
};
new GenericEditor(this, FlexDirection.COLUMN) {
{
select_(StringExtractor.TYPE_INSTANCE_EXTRACTOR, model -> getProperty(ReactorStatics.SELECTION, model));
addStyle("min-height", "300px");
}
};
}
};
}
};
new GenericDependenciesTable(this).select(StringExtractor.MANAGEMENT, Color.class);
}
};
new TransactionMonitor(this).addStyle("background-color", MAIN_COLOR);
}
};
}
void runScript(AbstractRoot engine) {
Generic car = engine.find(Car.class);
Generic power = engine.find(Power.class);
Generic carColor = engine.find(CarColor.class);
Generic color = engine.find(Color.class);
Generic red = color.setInstance("Red");
Generic black = color.setInstance("Black");
Generic green = color.setInstance("Green");
color.setInstance("Blue");
color.setInstance("Orange");
color.setInstance("White");
color.setInstance("Yellow");
Generic audiS4 = car.setInstance("Audi S4");
audiS4.setHolder(power, 333);
audiS4.setLink(carColor, "Audi S4 Green", green);
Generic bmwM3 = car.setInstance("BMW M3");
bmwM3.setHolder(power, 450);
bmwM3.setLink(carColor, "BMW M3 Red", red);
Generic ferrariF40 = car.setInstance("Ferrari F40");
ferrariF40.setHolder(power, 478);
ferrariF40.setLink(carColor, "Ferrari F40 red", red);
Generic miniCooper = car.setInstance("Mini Cooper");
miniCooper.setHolder(power, 175);
miniCooper.setLink(carColor, "Mini Cooper", black);
car.setInstance("Audi A4 3.0 TDI").setHolder(power, 233);
car.setInstance("Peugeot 106 GTI").setHolder(power, 120);
car.setInstance("Peugeot 206 S16").setHolder(power, 136);
power.enableRequiredConstraint(ApiStatics.BASE_POSITION);
engine.getCurrentCache().flush();
}
}