updating routes
This commit is contained in:
@@ -800,7 +800,7 @@ public class Plan extends BaseClass{
|
|||||||
Id id = parts.length>1 ? new Id(parts[1]) : null;
|
Id id = parts.length>1 ? new Id(parts[1]) : null;
|
||||||
switch (realm) {
|
switch (realm) {
|
||||||
case REALM_ROUTE:
|
case REALM_ROUTE:
|
||||||
return route(id).properties(params);
|
return route(id).properties();
|
||||||
case REALM_CONTACT:
|
case REALM_CONTACT:
|
||||||
case REALM_PLAN:
|
case REALM_PLAN:
|
||||||
Tile tile = get(id, false);
|
Tile tile = get(id, false);
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import de.srsoftware.web4rail.conditions.ConditionList;
|
|||||||
import de.srsoftware.web4rail.moving.Train;
|
import de.srsoftware.web4rail.moving.Train;
|
||||||
import de.srsoftware.web4rail.tags.Button;
|
import de.srsoftware.web4rail.tags.Button;
|
||||||
import de.srsoftware.web4rail.tags.Checkbox;
|
import de.srsoftware.web4rail.tags.Checkbox;
|
||||||
|
import de.srsoftware.web4rail.tags.Fieldset;
|
||||||
import de.srsoftware.web4rail.tags.Form;
|
import de.srsoftware.web4rail.tags.Form;
|
||||||
import de.srsoftware.web4rail.tags.Input;
|
import de.srsoftware.web4rail.tags.Input;
|
||||||
import de.srsoftware.web4rail.tags.Label;
|
import de.srsoftware.web4rail.tags.Label;
|
||||||
@@ -174,7 +175,7 @@ public class Route extends BaseClass implements Comparable<Route>{
|
|||||||
}
|
}
|
||||||
return message;
|
return message;
|
||||||
case ACTION_PROPS:
|
case ACTION_PROPS:
|
||||||
return route.properties(params);
|
return route.properties();
|
||||||
case ACTION_UPDATE:
|
case ACTION_UPDATE:
|
||||||
return route.update(params,plan);
|
return route.update(params,plan);
|
||||||
case DROP_CONDITION:
|
case DROP_CONDITION:
|
||||||
@@ -223,21 +224,22 @@ public class Route extends BaseClass implements Comparable<Route>{
|
|||||||
conditions.add(condition);
|
conditions.add(condition);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addBasicPropertiesTo(Window win) {
|
private Fieldset basicProperties() {
|
||||||
if (isSet(train)) train.link("span",t("Train: {}",train)).addTo(win);
|
Fieldset fieldset = new Fieldset(t("Route properties"));
|
||||||
new Tag("h4").content(t("Origin and destination")).addTo(win);
|
|
||||||
|
if (isSet(train)) train.link("span",t("Train: {}",train)).addTo(fieldset);
|
||||||
Tag list = new Tag("ul");
|
Tag list = new Tag("ul");
|
||||||
Plan.addLink(startBlock, t("Origin: {} to {}",startBlock.name,startDirection), list);
|
Plan.addLink(startBlock, t("Origin: {} to {}",startBlock.name,startDirection), list);
|
||||||
Plan.addLink(endBlock, t("Destination: {} from {}",endBlock.name,endDirection.inverse()), list);
|
Plan.addLink(endBlock, t("Destination: {} from {}",endBlock.name,endDirection.inverse()), list);
|
||||||
list.addTo(win);
|
list.addTo(fieldset);
|
||||||
|
|
||||||
|
|
||||||
if (!signals.isEmpty()) {
|
if (!signals.isEmpty()) {
|
||||||
new Tag("h4").content(t("Signals")).addTo(win);
|
new Tag("h4").content(t("Signals")).addTo(fieldset);
|
||||||
list = new Tag("ul");
|
list = new Tag("ul");
|
||||||
for (Signal s : signals) Plan.addLink(s,s.toString(),list);
|
for (Signal s : signals) Plan.addLink(s,s.toString(),list);
|
||||||
list.addTo(win);
|
list.addTo(fieldset);
|
||||||
}
|
}
|
||||||
|
return fieldset;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addBraketimesTo(Window win) {
|
private void addBraketimesTo(Window win) {
|
||||||
@@ -253,10 +255,11 @@ public class Route extends BaseClass implements Comparable<Route>{
|
|||||||
new Tag("p").content(t("1) Duration between 5 {} steps during brake process.",speedUnit)).addTo(win);
|
new Tag("p").content(t("1) Duration between 5 {} steps during brake process.",speedUnit)).addTo(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addConditionsTo(Window win) {
|
private Fieldset conditions() {
|
||||||
new Tag("h4").content(t("Conditions")).addTo(win);
|
Fieldset fieldset = new Fieldset(t("Conditions"));
|
||||||
new Tag("div").content(t("Route will only be available, if all conditions are fulfilled.")).addTo(win);
|
new Tag("div").content(t("Route will only be available, if all conditions are fulfilled.")).addTo(fieldset);
|
||||||
conditions.tag(REALM_ROUTE+":"+id()).addTo(win);
|
conditions.tag(REALM_ROUTE+":"+id()).addTo(fieldset);
|
||||||
|
return fieldset;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addContactsTo(Window win) {
|
private void addContactsTo(Window win) {
|
||||||
@@ -324,16 +327,15 @@ public class Route extends BaseClass implements Comparable<Route>{
|
|||||||
turnouts.put(t, s);
|
turnouts.put(t, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addTurnoutsTo(Window win) {
|
private Fieldset turnouts() {
|
||||||
if (!turnouts.isEmpty()) {
|
Fieldset win = new Fieldset(t("Turnouts"));
|
||||||
new Tag("h4").content(t("Turnouts")).addTo(win);
|
|
||||||
Tag list = new Tag("ul");
|
Tag list = new Tag("ul");
|
||||||
for (Entry<Turnout, State> entry : turnouts.entrySet()) {
|
for (Entry<Turnout, State> entry : turnouts.entrySet()) {
|
||||||
Turnout turnout = entry.getKey();
|
Turnout turnout = entry.getKey();
|
||||||
Plan.addLink(turnout, turnout+": "+t(entry.getValue().toString()), list);
|
Plan.addLink(turnout, turnout+": "+t(entry.getValue().toString()), list);
|
||||||
}
|
}
|
||||||
list.addTo(win);
|
list.addTo(win);
|
||||||
}
|
return win;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -439,7 +441,7 @@ public class Route extends BaseClass implements Comparable<Route>{
|
|||||||
private Object dropCodition(HashMap<String, String> params) {
|
private Object dropCodition(HashMap<String, String> params) {
|
||||||
Id condId = Id.from(params,REALM_CONDITION);
|
Id condId = Id.from(params,REALM_CONDITION);
|
||||||
if (isSet(condId)) conditions.removeById(condId);
|
if (isSet(condId)) conditions.removeById(condId);
|
||||||
return properties(params);
|
return properties();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Block endBlock() {
|
public Block endBlock() {
|
||||||
@@ -666,12 +668,24 @@ public class Route extends BaseClass implements Comparable<Route>{
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Window properties(HashMap<String, String> params) {
|
@Override
|
||||||
|
protected Window properties(List<Fieldset> preForm, FormInput formInputs, List<Fieldset> postForm) {
|
||||||
|
|
||||||
|
formInputs.add(t("Name"),new Input(NAME, name()));
|
||||||
|
formInputs.add(t("disabled"),new Checkbox(DISABLED, t("disabled"), disabled));
|
||||||
|
|
||||||
|
preForm.add(basicProperties());
|
||||||
|
if (!turnouts.isEmpty()) preForm.add(turnouts());
|
||||||
|
preForm.add(conditions());
|
||||||
|
return super.properties(preForm, formInputs, postForm);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Window properties(HashMap<String, String> params) {
|
||||||
Window win = new Window("route-properties",t("Properties of {}",this));
|
Window win = new Window("route-properties",t("Properties of {}",this));
|
||||||
addFormTo(win,params);
|
addFormTo(win,params);
|
||||||
addBasicPropertiesTo(win);
|
//basicProperties();
|
||||||
addTurnoutsTo(win);
|
//addTurnoutsTo(win);
|
||||||
addConditionsTo(win);
|
//addConditionsTo(win);
|
||||||
addContactsTo(win);
|
addContactsTo(win);
|
||||||
addBraketimesTo(win);
|
addBraketimesTo(win);
|
||||||
return win;
|
return win;
|
||||||
@@ -790,7 +804,7 @@ public class Route extends BaseClass implements Comparable<Route>{
|
|||||||
Condition condition = Condition.create(params.get(REALM_CONDITION));
|
Condition condition = Condition.create(params.get(REALM_CONDITION));
|
||||||
if (isSet(condition)) {
|
if (isSet(condition)) {
|
||||||
conditions.add(condition.parent(this));
|
conditions.add(condition.parent(this));
|
||||||
return properties(params);
|
return properties();
|
||||||
}
|
}
|
||||||
String message = t("{} updated.",this);
|
String message = t("{} updated.",this);
|
||||||
if (params.containsKey(CONTEXT)) {
|
if (params.containsKey(CONTEXT)) {
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ public abstract class Condition extends BaseClass {
|
|||||||
Route route = plan.route(contextId);
|
Route route = plan.route(contextId);
|
||||||
if (isNull(route)) return t("Unknown route: {}",contextId);
|
if (isNull(route)) return t("Unknown route: {}",contextId);
|
||||||
route.add(condition);
|
route.add(condition);
|
||||||
return route.properties(new HashMap<String,String>(Map.of(REALM,REALM_ROUTE,ACTION,ACTION_PROPS,ID,contextId.toString())));
|
return route.properties();
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user