added option to drop destination
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.11.6</version>
|
<version>0.11.7</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>
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ Destination\: {} from {} : Ziel: {} von {}
|
|||||||
Direction : Richtung
|
Direction : Richtung
|
||||||
Direction\: heading {} : Richtung: nach {}
|
Direction\: heading {} : Richtung: nach {}
|
||||||
disabled : deaktiviert
|
disabled : deaktiviert
|
||||||
|
Drop : Verwerfen
|
||||||
|
Dropped destination of {}. : Ziel von {} verworfen.
|
||||||
EAST : Osten
|
EAST : Osten
|
||||||
editable train properties : veränderliche Zug-Eigenschaften
|
editable train properties : veränderliche Zug-Eigenschaften
|
||||||
Emergency : Notfall
|
Emergency : Notfall
|
||||||
|
|||||||
@@ -636,6 +636,11 @@ public class Route extends BaseClass{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String shortName() {
|
||||||
|
String[] parts = name().split("-");
|
||||||
|
return parts[0].trim()+"–"+parts[parts.length-1].trim();
|
||||||
|
}
|
||||||
|
|
||||||
public Block startBlock() {
|
public Block startBlock() {
|
||||||
return startBlock;
|
return startBlock;
|
||||||
}
|
}
|
||||||
@@ -688,9 +693,4 @@ public class Route extends BaseClass{
|
|||||||
}
|
}
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String shortName() {
|
|
||||||
String[] parts = name().split("-");
|
|
||||||
return parts[0].trim()+"–"+parts[parts.length-1].trim();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -485,6 +485,7 @@ public class Train extends BaseClass implements Comparable<Train> {
|
|||||||
new Button(t("Select from plan"),"return selectDest("+id+");").addTo(dest);
|
new Button(t("Select from plan"),"return selectDest("+id+");").addTo(dest);
|
||||||
} else {
|
} else {
|
||||||
link("span",Map.of(REALM,REALM_PLAN,ID,destination.id(),ACTION,ACTION_CLICK),destination.toString()).addTo(dest);
|
link("span",Map.of(REALM,REALM_PLAN,ID,destination.id(),ACTION,ACTION_CLICK),destination.toString()).addTo(dest);
|
||||||
|
new Button(t("Drop"),Map.of(REALM,REALM_TRAIN,ID,id,ACTION,ACTION_MOVE,DESTINATION,"")).addTo(dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
dest.addTo(propList);
|
dest.addTo(propList);
|
||||||
@@ -553,6 +554,10 @@ public class Train extends BaseClass implements Comparable<Train> {
|
|||||||
private String setDestination(HashMap<String, String> params) {
|
private String setDestination(HashMap<String, String> params) {
|
||||||
String dest = params.get(DESTINATION);
|
String dest = params.get(DESTINATION);
|
||||||
if (isNull(dest)) return t("No destination supplied!");
|
if (isNull(dest)) return t("No destination supplied!");
|
||||||
|
if (dest.isEmpty()) {
|
||||||
|
destination = null;
|
||||||
|
return t("Dropped destination of {}.",this);
|
||||||
|
}
|
||||||
Tile tile = plan.get(dest, true);
|
Tile tile = plan.get(dest, true);
|
||||||
if (isNull(tile)) return t("Tile {} not known!",dest);
|
if (isNull(tile)) return t("Tile {} not known!",dest);
|
||||||
if (tile instanceof Block) {
|
if (tile instanceof Block) {
|
||||||
|
|||||||
@@ -216,10 +216,13 @@ public abstract class Tile extends BaseClass{
|
|||||||
|
|
||||||
if (isSet(train)) {
|
if (isSet(train)) {
|
||||||
HashMap<String, Object> props = new HashMap<String,Object>(Map.of(REALM,REALM_TRAIN,ID,train.id));
|
HashMap<String, Object> props = new HashMap<String,Object>(Map.of(REALM,REALM_TRAIN,ID,train.id));
|
||||||
|
if (isSet(train.route)) {
|
||||||
props.put(ACTION, ACTION_STOP);
|
props.put(ACTION, ACTION_STOP);
|
||||||
window.children().insertElementAt(new Button(t("stop"),props), 1);
|
window.children().insertElementAt(new Button(t("stop"),props), 1);
|
||||||
|
} else {
|
||||||
props.put(ACTION, ACTION_START);
|
props.put(ACTION, ACTION_START);
|
||||||
window.children().insertElementAt(new Button(t("start"),props), 1);
|
window.children().insertElementAt(new Button(t("start"),props), 1);
|
||||||
|
}
|
||||||
window.children().insertElementAt(train.link("span"), 1);
|
window.children().insertElementAt(train.link("span"), 1);
|
||||||
window.children().insertElementAt(new Tag("h4").content(t("Train:")), 1);
|
window.children().insertElementAt(new Tag("h4").content(t("Train:")), 1);
|
||||||
}
|
}
|
||||||
@@ -240,7 +243,7 @@ public abstract class Tile extends BaseClass{
|
|||||||
Tag routeList = new Tag("ol");
|
Tag routeList = new Tag("ol");
|
||||||
for (Route route : routes) {
|
for (Route route : routes) {
|
||||||
String json = new JSONObject(Map.of(REALM,ROUTE,ID,route.id(),ACTION,ACTION_PROPS,CONTEXT,REALM_PLAN+":"+id())).toString().replace("\"", "'");
|
String json = new JSONObject(Map.of(REALM,ROUTE,ID,route.id(),ACTION,ACTION_PROPS,CONTEXT,REALM_PLAN+":"+id())).toString().replace("\"", "'");
|
||||||
Tag li = new Tag("span").attr("onclick","return request("+json+");").content(route.shortName()+(route.isDisabled()?" ["+t("disabled")+"]" : "")+NBSP).addTo(new Tag("li").clazz("link"));
|
Tag li = new Tag("span").attr("onclick","return request("+json+");").content(route.name()+(route.isDisabled()?" ["+t("disabled")+"]" : "")+NBSP).addTo(new Tag("li").clazz("link"));
|
||||||
Map<String, Object> params = Map.of(REALM,REALM_ROUTE,ID,route.id(),ACTION,ACTION_DROP,Tile.class.getSimpleName(),id());
|
Map<String, Object> params = Map.of(REALM,REALM_ROUTE,ID,route.id(),ACTION,ACTION_DROP,Tile.class.getSimpleName(),id());
|
||||||
new Button(t("delete route"),params).addTo(li);
|
new Button(t("delete route"),params).addTo(li);
|
||||||
li.addTo(routeList);
|
li.addTo(routeList);
|
||||||
|
|||||||
Reference in New Issue
Block a user