preparing actions on routes
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.6.10</version>
|
||||
<version>0.6.11</version>
|
||||
<name>Web4Rail</name>
|
||||
<packaging>jar</packaging>
|
||||
<description>Java Model Railway Control</description>
|
||||
|
||||
@@ -2,13 +2,17 @@ Actions : Aktionen
|
||||
Added {} : {} hinzugefügt
|
||||
Add tile : Kachel hinzufügen
|
||||
Analyze plan : Plan analysieren
|
||||
Contacts : Kontakte
|
||||
Contacts and actions : Kontakte und Aktionen
|
||||
Destination\: {} from {} : Ziel: {} von {}
|
||||
length\: : Länge:
|
||||
name\: : Name:
|
||||
Origin and destination : Start und Ziel
|
||||
Origin\: {} to {} : Start: {} nach {}
|
||||
Plan saved as "{}". : Plan als „{}“ gespeichert.
|
||||
Properties : Eigenschaften
|
||||
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:
|
||||
save : speichern
|
||||
Save plan : Plan speichern
|
||||
|
||||
@@ -105,10 +105,25 @@ public class Plan implements Constants{
|
||||
new Heartbeat().start();
|
||||
}
|
||||
|
||||
public ControlUnit controlUnit() {
|
||||
return controlUnit;
|
||||
public Object action(HashMap<String, String> params) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
|
||||
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 {
|
||||
Tag actionMenu = new Tag("div").clazz("actions").content(t("Actions"));
|
||||
Tag actions = new Tag("div").clazz("list").content("");
|
||||
@@ -124,8 +139,10 @@ public class Plan implements Constants{
|
||||
clients.put(client, 0);
|
||||
}
|
||||
|
||||
public static void addLink(Tile tile,String content,Tag list) {
|
||||
new Tag("li").clazz("link").attr("onclick", "return clickTile("+tile.x+","+tile.y+");").content(content).addTo(list);
|
||||
public static Tag addLink(Tile tile,String content,Tag 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 {
|
||||
@@ -167,6 +184,10 @@ public class Plan implements Constants{
|
||||
if (tile == null) return null;
|
||||
return tile.click();
|
||||
}
|
||||
|
||||
public ControlUnit controlUnit() {
|
||||
return controlUnit;
|
||||
}
|
||||
|
||||
private Collection<Route> follow(Route route, Connector connector) {
|
||||
Tile tile = get(Tile.id(connector.x,connector.y),false);
|
||||
@@ -356,23 +377,8 @@ public class Plan implements Constants{
|
||||
return tile;
|
||||
}
|
||||
|
||||
public Object action(HashMap<String, String> params) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
|
||||
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));
|
||||
public Command queue(Command command) {
|
||||
return controlUnit.queue(command);
|
||||
}
|
||||
|
||||
public Route route(int routeId) {
|
||||
@@ -518,8 +524,4 @@ public class Plan implements Constants{
|
||||
public void warn(Contact 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()) {
|
||||
new Tag("h4").content(t("Contacts")).addTo(win);
|
||||
new Tag("h4").content(t("Contacts and actions")).addTo(win);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import de.keawe.tools.translations.Translation;
|
||||
import de.srsoftware.web4rail.Application;
|
||||
import de.srsoftware.web4rail.Plan;
|
||||
|
||||
public abstract class Action {
|
||||
@@ -37,4 +39,8 @@ public abstract class Action {
|
||||
}
|
||||
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);
|
||||
return json;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return t("Reduce speed to {} km/h",maxSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user