improved car and train management forms
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>de.srsoftware</groupId>
|
||||
<artifactId>web4rail</artifactId>
|
||||
<version>0.11.30</version>
|
||||
<version>0.11.31</version>
|
||||
<name>Web4Rail</name>
|
||||
<packaging>jar</packaging>
|
||||
<description>Java Model Railway Control</description>
|
||||
|
||||
@@ -67,12 +67,13 @@ public class Car extends BaseClass implements Comparable<Car>{
|
||||
|
||||
switch (params.get(ACTION)) {
|
||||
case ACTION_ADD:
|
||||
return new Car(params.get(Car.NAME)).plan(plan);
|
||||
|
||||
new Car(params.get(Car.NAME)).plan(plan);
|
||||
return Car.manager();
|
||||
case ACTION_PROPS:
|
||||
return car == null ? Car.manager() : car.properties();
|
||||
case ACTION_UPDATE:
|
||||
return car.update(params);
|
||||
car.update(params);
|
||||
return Car.manager();
|
||||
}
|
||||
if (car instanceof Locomotive) return Locomotive.action(params,plan);
|
||||
return t("Unknown action: {}",params.get(ACTION));
|
||||
@@ -150,12 +151,12 @@ public class Car extends BaseClass implements Comparable<Car>{
|
||||
}
|
||||
list.addTo(win);
|
||||
|
||||
Form form = new Form();
|
||||
Form form = new Form("add-car-form");
|
||||
new Input(ACTION, ACTION_ADD).hideIn(form);
|
||||
new Input(REALM,REALM_CAR).hideIn(form);
|
||||
Fieldset fieldset = new Fieldset(t("add new car"));
|
||||
new Input(Locomotive.NAME, t("new car")).addTo(new Label(t("Name:")+NBSP)).addTo(fieldset);
|
||||
new Button(t("Apply")).addTo(fieldset);
|
||||
new Button(t("Apply"),form).addTo(fieldset);
|
||||
fieldset.addTo(form).addTo(win);
|
||||
return win;
|
||||
}
|
||||
@@ -173,8 +174,8 @@ public class Car extends BaseClass implements Comparable<Car>{
|
||||
return this;
|
||||
}
|
||||
|
||||
public Tag propertyForm() {
|
||||
Form form = new Form();
|
||||
public Form propertyForm() {
|
||||
Form form = new Form("car-prop-form");
|
||||
new Input(ACTION, ACTION_UPDATE).hideIn(form);
|
||||
new Input(REALM,REALM_CAR).hideIn(form);
|
||||
new Input(ID,id()).hideIn(form);
|
||||
@@ -193,10 +194,9 @@ public class Car extends BaseClass implements Comparable<Car>{
|
||||
Tag cockpit = cockpit();
|
||||
if (cockpit != null) cockpit.addTo(win);
|
||||
|
||||
Tag form = propertyForm();
|
||||
Form form = propertyForm();
|
||||
if (form!=null && form.children().size()>2) {
|
||||
new Button(t("Apply")).addTo(form);
|
||||
form.addTo(win);
|
||||
new Button(t("Apply"),form).addTo(form).addTo(win);
|
||||
} else {
|
||||
win.content(t("This tile ({}) has no editable properties",getClass().getSimpleName()));
|
||||
}
|
||||
|
||||
@@ -46,7 +46,8 @@ public class Locomotive extends Car implements Constants,Device{
|
||||
Locomotive loco = id == null ? null : Locomotive.get(id);
|
||||
switch (params.get(ACTION)) {
|
||||
case ACTION_ADD:
|
||||
return new Locomotive(params.get(Locomotive.NAME)).plan(plan);
|
||||
new Locomotive(params.get(Locomotive.NAME)).plan(plan);
|
||||
return Locomotive.manager();
|
||||
case ACTION_FASTER10:
|
||||
return loco.faster(10);
|
||||
case ACTION_PROPS:
|
||||
@@ -65,6 +66,9 @@ public class Locomotive extends Car implements Constants,Device{
|
||||
return loco.toggleFunction(4);
|
||||
case ACTION_TURN:
|
||||
return loco.turn();
|
||||
case ACTION_UPDATE:
|
||||
loco.update(params);
|
||||
return Locomotive.manager();
|
||||
}
|
||||
|
||||
return t("Unknown action: {}",params.get(ACTION));
|
||||
@@ -198,7 +202,7 @@ public class Locomotive extends Car implements Constants,Device{
|
||||
return this;
|
||||
}
|
||||
|
||||
public static Object manager() {
|
||||
public static Window manager() {
|
||||
Window win = new Window("loco-manager", t("Locomotive manager"));
|
||||
new Tag("h4").content(t("known locomotives")).addTo(win);
|
||||
Tag list = new Tag("ul");
|
||||
@@ -213,22 +217,22 @@ public class Locomotive extends Car implements Constants,Device{
|
||||
}
|
||||
list.addTo(win);
|
||||
|
||||
Form form = new Form();
|
||||
Form form = new Form("add-loco-form");
|
||||
new Input(ACTION, ACTION_ADD).hideIn(form);
|
||||
new Input(REALM,REALM_LOCO).hideIn(form);
|
||||
Fieldset fieldset = new Fieldset(t("add new locomotive"));
|
||||
new Input(Locomotive.NAME, t("new locomotive")).addTo(new Label(t("Name:")+NBSP)).addTo(fieldset);
|
||||
new Button(t("Apply")).addTo(fieldset);
|
||||
new Button(t("Apply"),form).addTo(fieldset);
|
||||
fieldset.addTo(form).addTo(win);
|
||||
return win;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tag propertyForm() {
|
||||
Tag form = super.propertyForm();
|
||||
public Form propertyForm() {
|
||||
Form form = super.propertyForm();
|
||||
for (Tag tag : form.children()) {
|
||||
if (REALM.equals(tag.get(Input.NAME)) && REALM_CAR.equals(tag.get(Input.VALUE))) {
|
||||
tag.attr(REALM, REALM_LOCO);
|
||||
tag.attr("value", REALM_LOCO);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ public class Train extends BaseClass implements Comparable<Train> {
|
||||
if (car instanceof Locomotive) {
|
||||
locos.add((Locomotive) car);
|
||||
} else cars.add(car);
|
||||
return this;
|
||||
return props();
|
||||
}
|
||||
|
||||
public void add(Car car) {
|
||||
@@ -211,7 +211,8 @@ public class Train extends BaseClass implements Comparable<Train> {
|
||||
li.addTo(locoList);
|
||||
}
|
||||
|
||||
Tag addCarForm = new Form().content(t("add car:")+" ");
|
||||
Form addCarForm = new Form("append-car-form");
|
||||
addCarForm.content(t("add car:")+" ");
|
||||
new Input(REALM, REALM_TRAIN).hideIn(addCarForm);
|
||||
new Input(ACTION, ACTION_ADD).hideIn(addCarForm);
|
||||
new Input(ID,id).hideIn(addCarForm);
|
||||
@@ -221,7 +222,7 @@ public class Train extends BaseClass implements Comparable<Train> {
|
||||
}
|
||||
if (!select.children().isEmpty()) {
|
||||
select.addTo(addCarForm);
|
||||
new Button(t("add")).addTo(addCarForm);
|
||||
new Button(t("add"),addCarForm).addTo(addCarForm);
|
||||
addCarForm.addTo(new Tag("li")).addTo(locoList);
|
||||
}
|
||||
return locoList.addTo(locoProp);
|
||||
@@ -384,7 +385,8 @@ public class Train extends BaseClass implements Comparable<Train> {
|
||||
new Button(t("delete"),params).addTo(li);
|
||||
}
|
||||
|
||||
Tag addLocoForm = new Form().content(t("add locomotive:")+" ");
|
||||
Form addLocoForm = new Form("append-loco-form");
|
||||
addLocoForm.content(t("add locomotive:")+" ");
|
||||
new Input(REALM, REALM_TRAIN).hideIn(addLocoForm);
|
||||
new Input(ACTION, ACTION_ADD).hideIn(addLocoForm);
|
||||
new Input(ID,id).hideIn(addLocoForm);
|
||||
@@ -394,7 +396,7 @@ public class Train extends BaseClass implements Comparable<Train> {
|
||||
}
|
||||
if (!select.children().isEmpty()) {
|
||||
select.addTo(addLocoForm);
|
||||
new Button(t("add")).addTo(addLocoForm);
|
||||
new Button(t("add"),addLocoForm).addTo(addLocoForm);
|
||||
addLocoForm.addTo(new Tag("li")).addTo(locoList);
|
||||
}
|
||||
return locoList.addTo(locoProp);
|
||||
|
||||
Reference in New Issue
Block a user