diff --git a/pom.xml b/pom.xml index 0a2f0af..06eefae 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 de.srsoftware web4rail - 0.7.1 + 0.7.2 Web4Rail jar Java Model Railway Control diff --git a/src/main/java/de/srsoftware/web4rail/Plan.java b/src/main/java/de/srsoftware/web4rail/Plan.java index d7b8289..219f463 100644 --- a/src/main/java/de/srsoftware/web4rail/Plan.java +++ b/src/main/java/de/srsoftware/web4rail/Plan.java @@ -411,6 +411,8 @@ public class Plan implements Constants{ return route.addActionForm(params); case ACTION_DROP: return route.dropAction(params); + case ACTION_MOVE: + return route.moveAction(params); case ACTION_PROPS: return route.properties(); case ACTION_UPDATE: diff --git a/src/main/java/de/srsoftware/web4rail/Route.java b/src/main/java/de/srsoftware/web4rail/Route.java index f8bd2e2..9a52e3d 100644 --- a/src/main/java/de/srsoftware/web4rail/Route.java +++ b/src/main/java/de/srsoftware/web4rail/Route.java @@ -76,7 +76,7 @@ public class Route implements Constants{ new Input(ACTION,ACTION_ADD_ACTION).hideIn(typeForm); new Input(CONTACT,contact.id()).hideIn(typeForm); Select select = new Select(TYPE); - List> classes = List.of(SpeedReduction.class); + List> classes = List.of(SpeedReduction.class,SetSignalsToStop.class,FinishRoute.class); for (Class clazz : classes) select.addOption(clazz.getSimpleName()); select.addTo(new Label("Action type:")).addTo(typeForm); return new Button(t("Create action"),"return submitForm('"+formId+"');").addTo(typeForm); @@ -116,24 +116,6 @@ public class Route implements Constants{ actions.add(action); } - public Object dropAction(HashMap params) { - String action_id = params.get(ACTION_ID); - if (action_id == null) return t("No action id passed to request!"); - String contactId = params.get(CONTACT); - Tile tag = plan.get(contactId, false); - if (!(tag instanceof Contact)) return t("No contact id passed to request!"); - Contact contact = (Contact) tag; - Vector actions = triggers.get(contact.trigger()); - - for (int i=0; i params) { String contactId = params.get(CONTACT); Tile tag = plan.get(contactId, false); @@ -146,8 +128,16 @@ public class Route implements Constants{ String type = params.get(TYPE); if (type == null) return (actionTypeForm(contact).addTo(win)); switch (type) { + case "FinishRoute": + addAction(contact.trigger(),new FinishRoute(id())); + plan.stream("Action added!"); + return properties(); case "SpeedReduction": return SpeedReduction.propForm(params,this,contact); + case "SetSignalsToStop": + addAction(contact.trigger(),new SetSignalsToStop(id())); + plan.stream("Action added!"); + return properties(); } return win; @@ -183,14 +173,19 @@ public class Route implements Constants{ Vector actions = triggers.get(c.trigger()); if (actions != null && !actions.isEmpty()) { Tag ul = new Tag("ul"); + boolean first = true; for (Action action : actions) { + json.put(ACTION_ID, action.toString()); + Tag act = new Tag("li").content(action.toString()); - new Button("↑").addTo(act); - new Button("↓").addTo(act); + if (!first) { + json.put(ACTION, ACTION_MOVE); + new Button("↑",json).addTo(act); + } json.put(ACTION, ACTION_DROP); - json.put(ACTION_ID, action.toString()); new Button("-",json).addTo(act); act.addTo(ul); + first = false; } ul.addTo(link); } @@ -282,6 +277,26 @@ public class Route implements Constants{ return new Vector<>(contacts); } + public Object dropAction(HashMap params) { + String actionId = params.get(ACTION_ID); + if (actionId == null) return t("No action id passed to request!"); + String contactId = params.get(CONTACT); + Tile tag = plan.get(contactId, false); + if (!(tag instanceof Contact)) return t("No contact id passed to request!"); + Contact contact = (Contact) tag; + Vector actions = triggers.get(contact.trigger()); + + for (int i=0; i params) { + String action_id = params.get(ACTION_ID); + if (action_id == null) return t("No action id passed to request!"); + String contactId = params.get(CONTACT); + Tile tag = plan.get(contactId, false); + if (!(tag instanceof Contact)) return t("No contact id passed to request!"); + Contact contact = (Contact) tag; + Vector actions = triggers.get(contact.trigger()); + + for (int i=1; i multiply(int size) { Vector routes = new Vector(); for (int i=0; i