preparing actions on routes
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -4,7 +4,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>de.srsoftware</groupId>
|
<groupId>de.srsoftware</groupId>
|
||||||
<artifactId>web4rail</artifactId>
|
<artifactId>web4rail</artifactId>
|
||||||
<version>0.6.10</version>
|
<version>0.6.11</version>
|
||||||
<name>Web4Rail</name>
|
<name>Web4Rail</name>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<description>Java Model Railway Control</description>
|
<description>Java Model Railway Control</description>
|
||||||
|
|||||||
@@ -2,13 +2,17 @@ Actions : Aktionen
|
|||||||
Added {} : {} hinzugefügt
|
Added {} : {} hinzugefügt
|
||||||
Add tile : Kachel hinzufügen
|
Add tile : Kachel hinzufügen
|
||||||
Analyze plan : Plan analysieren
|
Analyze plan : Plan analysieren
|
||||||
Contacts : Kontakte
|
Contacts and actions : Kontakte und Aktionen
|
||||||
|
Destination\: {} from {} : Ziel: {} von {}
|
||||||
length\: : Länge:
|
length\: : Länge:
|
||||||
name\: : Name:
|
name\: : Name:
|
||||||
|
Origin and destination : Start und Ziel
|
||||||
|
Origin\: {} to {} : Start: {} nach {}
|
||||||
Plan saved as "{}". : Plan als „{}“ gespeichert.
|
Plan saved as "{}". : Plan als „{}“ gespeichert.
|
||||||
Properties : Eigenschaften
|
Properties : Eigenschaften
|
||||||
Properties of {} : Eigenschaften von {}
|
Properties of {} : Eigenschaften von {}
|
||||||
Properties of {} @ ({},{}) : Eigenschaften von {} @ ({},{})
|
Properties of {} @ ({},{}) : Eigenschaften von {} @ ({},{})
|
||||||
|
Reduce speed to {} km/h : Geschwindigkeit auf {} km/h reduzieren
|
||||||
Routes using this tile\: : Fahrstraßen, die diesen Abschnitt verwenden:
|
Routes using this tile\: : Fahrstraßen, die diesen Abschnitt verwenden:
|
||||||
save : speichern
|
save : speichern
|
||||||
Save plan : Plan speichern
|
Save plan : Plan speichern
|
||||||
|
|||||||
@@ -105,8 +105,23 @@ public class Plan implements Constants{
|
|||||||
new Heartbeat().start();
|
new Heartbeat().start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ControlUnit controlUnit() {
|
public Object action(HashMap<String, String> params) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
|
||||||
return controlUnit;
|
switch (params.get(ACTION)) {
|
||||||
|
case ACTION_ADD:
|
||||||
|
return addTile(params.get(TILE),params.get(X),params.get(Y),null);
|
||||||
|
case ACTION_ANALYZE:
|
||||||
|
return analyze();
|
||||||
|
case ACTION_CLICK:
|
||||||
|
return click(get(params.get(Tile.ID),true));
|
||||||
|
case ACTION_MOVE:
|
||||||
|
return moveTile(params.get(DIRECTION),params.get(Tile.ID));
|
||||||
|
case ACTION_SAVE:
|
||||||
|
return saveTo("default");
|
||||||
|
case ACTION_UPDATE:
|
||||||
|
update(get(params.get(Tile.ID),true),params);
|
||||||
|
return html();
|
||||||
|
}
|
||||||
|
return t("Unknown action: {}",params.get(ACTION));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Tag actionMenu() throws IOException {
|
private Tag actionMenu() throws IOException {
|
||||||
@@ -124,8 +139,10 @@ public class Plan implements Constants{
|
|||||||
clients.put(client, 0);
|
clients.put(client, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addLink(Tile tile,String content,Tag list) {
|
public static Tag addLink(Tile tile,String content,Tag list) {
|
||||||
new Tag("li").clazz("link").attr("onclick", "return clickTile("+tile.x+","+tile.y+");").content(content).addTo(list);
|
Tag li = new Tag("li");
|
||||||
|
new Tag("span").clazz("link").attr("onclick", "return clickTile("+tile.x+","+tile.y+");").content(content).addTo(li).addTo(list);
|
||||||
|
return li;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String addTile(String clazz, String xs, String ys, String configJson) throws ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, IOException {
|
private String addTile(String clazz, String xs, String ys, String configJson) throws ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, IOException {
|
||||||
@@ -168,6 +185,10 @@ public class Plan implements Constants{
|
|||||||
return tile.click();
|
return tile.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ControlUnit controlUnit() {
|
||||||
|
return controlUnit;
|
||||||
|
}
|
||||||
|
|
||||||
private Collection<Route> follow(Route route, Connector connector) {
|
private Collection<Route> follow(Route route, Connector connector) {
|
||||||
Tile tile = get(Tile.id(connector.x,connector.y),false);
|
Tile tile = get(Tile.id(connector.x,connector.y),false);
|
||||||
Vector<Route> results = new Vector<>();
|
Vector<Route> results = new Vector<>();
|
||||||
@@ -356,23 +377,8 @@ public class Plan implements Constants{
|
|||||||
return tile;
|
return tile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object action(HashMap<String, String> params) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
|
public Command queue(Command command) {
|
||||||
switch (params.get(ACTION)) {
|
return controlUnit.queue(command);
|
||||||
case ACTION_ADD:
|
|
||||||
return addTile(params.get(TILE),params.get(X),params.get(Y),null);
|
|
||||||
case ACTION_ANALYZE:
|
|
||||||
return analyze();
|
|
||||||
case ACTION_CLICK:
|
|
||||||
return click(get(params.get(Tile.ID),true));
|
|
||||||
case ACTION_MOVE:
|
|
||||||
return moveTile(params.get(DIRECTION),params.get(Tile.ID));
|
|
||||||
case ACTION_SAVE:
|
|
||||||
return saveTo("default");
|
|
||||||
case ACTION_UPDATE:
|
|
||||||
update(get(params.get(Tile.ID),true),params);
|
|
||||||
return html();
|
|
||||||
}
|
|
||||||
return t("Unknown action: {}",params.get(ACTION));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Route route(int routeId) {
|
public Route route(int routeId) {
|
||||||
@@ -518,8 +524,4 @@ public class Plan implements Constants{
|
|||||||
public void warn(Contact contact) {
|
public void warn(Contact contact) {
|
||||||
stream(t("Warning: {}",t("Ghost train @ {}",contact)));
|
stream(t("Warning: {}",t("Ghost train @ {}",contact)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Command queue(Command command) {
|
|
||||||
return controlUnit.queue(command);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -351,9 +351,17 @@ public class Route implements Constants{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!contacts.isEmpty()) {
|
if (!contacts.isEmpty()) {
|
||||||
new Tag("h4").content(t("Contacts")).addTo(win);
|
new Tag("h4").content(t("Contacts and actions")).addTo(win);
|
||||||
list = new Tag("ul");
|
list = new Tag("ul");
|
||||||
for (Contact c : contacts) Plan.addLink(c,c.toString(),list);
|
for (Contact c : contacts) {
|
||||||
|
Tag link = Plan.addLink(c,c.toString(),list);
|
||||||
|
Vector<Action> actions = triggers.get(c.trigger());
|
||||||
|
if (actions != null && !actions.isEmpty()) {
|
||||||
|
Tag ul = new Tag("ul");
|
||||||
|
for (Action action : actions) new Tag("li").content(action.toString()).addTo(ul);
|
||||||
|
ul.addTo(link);
|
||||||
|
}
|
||||||
|
}
|
||||||
list.addTo(win);
|
list.addTo(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import java.lang.reflect.InvocationTargetException;
|
|||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import de.keawe.tools.translations.Translation;
|
||||||
|
import de.srsoftware.web4rail.Application;
|
||||||
import de.srsoftware.web4rail.Plan;
|
import de.srsoftware.web4rail.Plan;
|
||||||
|
|
||||||
public abstract class Action {
|
public abstract class Action {
|
||||||
@@ -37,4 +39,8 @@ public abstract class Action {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String t(String tex,Object...fills) {
|
||||||
|
return Translation.get(Application.class, tex, fills);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,4 +27,9 @@ public class SpeedReduction extends RouteAction {
|
|||||||
json.put(MAX_SPEED, maxSpeed);
|
json.put(MAX_SPEED, maxSpeed);
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return t("Reduce speed to {} km/h",maxSpeed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user