bugfixes
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.10.4</version>
|
||||
<version>0.10.5</version>
|
||||
<name>Web4Rail</name>
|
||||
<packaging>jar</packaging>
|
||||
<description>Java Model Railway Control</description>
|
||||
|
||||
@@ -148,11 +148,13 @@ public class Route extends BaseClass{
|
||||
}
|
||||
|
||||
private void addBasicPropertiesTo(Window win) {
|
||||
if (isSet(train)) link("span",Map.of(REALM,REALM_TRAIN,ID,train.id,ACTION,ACTION_PROPS),t("Train: {}",train)).addTo(win);
|
||||
new Tag("h4").content(t("Origin and destination")).addTo(win);
|
||||
Tag list = new Tag("ul");
|
||||
Plan.addLink(startBlock, t("Origin: {} to {}",startBlock.name,startDirection), list);
|
||||
Plan.addLink(endBlock, t("Destination: {} from {}",endBlock.name,endDirection), list);
|
||||
list.addTo(win);
|
||||
|
||||
|
||||
if (!signals.isEmpty()) {
|
||||
new Tag("h4").content(t("Signals")).addTo(win);
|
||||
@@ -341,6 +343,7 @@ public class Route extends BaseClass{
|
||||
train.set(endBlock);
|
||||
train.heading(endDirection.inverse());
|
||||
if (train.route == this) train.route = null;
|
||||
train = null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ public class ActionList extends Vector<Action> implements Constants{
|
||||
boolean first = true;
|
||||
for (Action action : this) {
|
||||
props.put(ID, id+"/"+action.id());
|
||||
Tag act = BaseClass.link("span", Map.of(REALM,REALM_ACTIONS,ID,id+"/"+action.id(),ACTION,ACTION_PROPS,CONTEXT,context), this+NBSP).addTo(new Tag("li"));;
|
||||
Tag act = BaseClass.link("span", Map.of(REALM,REALM_ACTIONS,ID,id+"/"+action.id(),ACTION,ACTION_PROPS,CONTEXT,context), action+NBSP).addTo(new Tag("li"));;
|
||||
if (!first) {
|
||||
props.put(ACTION, ACTION_MOVE);
|
||||
new Button("↑",props).addTo(act);
|
||||
|
||||
@@ -2,7 +2,6 @@ package de.srsoftware.web4rail.conditions;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.TreeMap;
|
||||
|
||||
@@ -14,7 +13,6 @@ import de.keawe.tools.translations.Translation;
|
||||
import de.srsoftware.tools.Tag;
|
||||
import de.srsoftware.web4rail.Application;
|
||||
import de.srsoftware.web4rail.BaseClass;
|
||||
import de.srsoftware.web4rail.Constants;
|
||||
import de.srsoftware.web4rail.Plan;
|
||||
import de.srsoftware.web4rail.Window;
|
||||
import de.srsoftware.web4rail.actions.Action.Context;
|
||||
|
||||
@@ -195,14 +195,6 @@ public class Train extends BaseClass implements Comparable<Train> {
|
||||
return result;
|
||||
}
|
||||
|
||||
private Object dropCar(HashMap<String, String> params) {
|
||||
String carId = params.get(CAR_ID);
|
||||
if (isSet(carId)) cars.remove(Car.get(carId));
|
||||
String locoId = params.get(LOCO_ID);
|
||||
if (isSet(locoId)) locos.remove(Car.get(locoId));
|
||||
return props();
|
||||
}
|
||||
|
||||
private Object addCar(HashMap<String, String> params) {
|
||||
LOG.debug("addCar({})",params);
|
||||
if (!params.containsKey(CAR_ID)) return t("No car id passed to Train.addCar!");
|
||||
@@ -266,6 +258,18 @@ public class Train extends BaseClass implements Comparable<Train> {
|
||||
return train;
|
||||
}
|
||||
|
||||
public Direction direction() {
|
||||
return direction;
|
||||
}
|
||||
|
||||
private Object dropCar(HashMap<String, String> params) {
|
||||
String carId = params.get(CAR_ID);
|
||||
if (isSet(carId)) cars.remove(Car.get(carId));
|
||||
String locoId = params.get(LOCO_ID);
|
||||
if (isSet(locoId)) locos.remove(Car.get(locoId));
|
||||
return props();
|
||||
}
|
||||
|
||||
public static Train get(int id) {
|
||||
return trains.get(id);
|
||||
}
|
||||
@@ -429,7 +433,9 @@ public class Train extends BaseClass implements Comparable<Train> {
|
||||
new Input(TAGS,String.join(", ", tags)).addTo(new Label(t("Tags")+NBSP)).addTo(form);
|
||||
new Button(t("Apply")).addTo(form).addTo(fieldset);
|
||||
|
||||
new Button(t("Turn"), "train("+id+",'"+ACTION_TURN+"')").addTo(fieldset).addTo(window);
|
||||
HashMap<String, Object> props = new HashMap<String,Object>(Map.of(REALM,REALM_TRAIN,ID,id));
|
||||
props.put(ACTION, ACTION_TURN);
|
||||
new Button(t("Turn"), props).addTo(fieldset).addTo(window);
|
||||
|
||||
fieldset = new Fieldset(t("other train properties"));
|
||||
|
||||
@@ -439,20 +445,30 @@ public class Train extends BaseClass implements Comparable<Train> {
|
||||
carList().addTo(propList);
|
||||
new Tag("li").content(t("length: {}",length())).addTo(propList);
|
||||
|
||||
if (!trace.isEmpty()) {
|
||||
Tag li = new Tag("li").content(t("Occupied area:"));
|
||||
Tag ul = new Tag("ul");
|
||||
for (Tile tile : trace) new Tag("li").content(tile.toString()).addTo(ul);
|
||||
ul.addTo(li).addTo(propList);
|
||||
}
|
||||
|
||||
if (isSet(block)) {
|
||||
new Tag("li").content(t("Current location: {}",block)).addTo(propList);
|
||||
link("li",Map.of(REALM,REALM_PLAN,ID,block.id(),ACTION,ACTION_CLICK),t("Current location: {}",block)).addTo(propList);
|
||||
Tag actions = new Tag("li").clazz().content(t("Actions:")+NBSP);
|
||||
new Button(t("start"),"train("+id+",'"+ACTION_START+"')").addTo(actions);
|
||||
props.put(ACTION, ACTION_START);
|
||||
new Button(t("start"),props).addTo(actions);
|
||||
if (isNull(autopilot)) {
|
||||
new Button(t("auto"),"train("+id+",'"+ACTION_AUTO+"')").addTo(actions);
|
||||
props.put(ACTION, ACTION_AUTO);
|
||||
new Button(t("auto"),props).addTo(actions);
|
||||
} else {
|
||||
new Button(t("quit autopilot"),"train("+id+",'"+ACTION_QUIT+"')").addTo(actions);
|
||||
props.put(ACTION, ACTION_QUIT);
|
||||
new Button(t("quit autopilot"),props).addTo(actions);
|
||||
}
|
||||
actions.addTo(propList);
|
||||
|
||||
}
|
||||
|
||||
if (isSet(route)) {
|
||||
new Tag("li").content(t("Current route: {}",route)).addTo(propList);
|
||||
link("li", Map.of(REALM,REALM_ROUTE,ID,route.id(),ACTION,ACTION_PROPS), route).addTo(propList);
|
||||
}
|
||||
if (isSet(direction)) new Tag("li").content(t("Direction: heading {}",direction)).addTo(propList);
|
||||
|
||||
@@ -587,12 +603,9 @@ public class Train extends BaseClass implements Comparable<Train> {
|
||||
for (Tile tile : newTiles) {
|
||||
if (active) {
|
||||
trace.addFirst(tile);
|
||||
System.err.println(trace);
|
||||
} else {
|
||||
Tile dummy = trace.getFirst();
|
||||
if (dummy == tile) {
|
||||
active = true;
|
||||
};
|
||||
if (dummy == tile) active = true;
|
||||
}
|
||||
}
|
||||
showTrace();
|
||||
|
||||
@@ -99,6 +99,9 @@ public abstract class Block extends StretchableTile{
|
||||
Train newTrain = Train.get(trainId);
|
||||
if (isSet(newTrain) && newTrain != train) {
|
||||
newTrain.dropTrace();
|
||||
if (connections(newTrain.direction()).isEmpty()) {
|
||||
newTrain.heading(null);
|
||||
}
|
||||
newTrain.set(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,12 +216,17 @@ public abstract class Tile extends BaseClass{
|
||||
Window window = new Window("tile-properties",t("Properties of {} @ ({},{})",title(),x,y));
|
||||
|
||||
if (isSet(train)) {
|
||||
window.children().insertElementAt(new Button(t("stop"),"train("+train.id+",'"+ACTION_STOP+"')"), 1);
|
||||
window.children().insertElementAt(new Button(t("start"),"train("+train.id+",'"+ACTION_START+"')"), 1);
|
||||
HashMap<String, Object> props = new HashMap<String,Object>(Map.of(REALM,REALM_TRAIN,ID,train.id));
|
||||
props.put(ACTION, ACTION_STOP);
|
||||
window.children().insertElementAt(new Button(t("stop"),props), 1);
|
||||
props.put(ACTION, ACTION_START);
|
||||
window.children().insertElementAt(new Button(t("start"),props), 1);
|
||||
window.children().insertElementAt(train.link("span"), 1);
|
||||
window.children().insertElementAt(new Tag("h4").content(t("Train:")), 1);
|
||||
}
|
||||
|
||||
if (isSet(route)) link("p",Map.of(REALM,REALM_ROUTE,ID,route.id(),ACTION,ACTION_PROPS),t("Locked by {}",route)).addTo(window);
|
||||
|
||||
Form form = propForm("tile-properties-"+id());
|
||||
new Tag("h4").content(t("Length")).addTo(form);
|
||||
new Input(LENGTH,length).numeric().addTo(new Label(t("Length")+":"+NBSP)).addTo(form);
|
||||
@@ -230,9 +235,6 @@ public abstract class Tile extends BaseClass{
|
||||
new Button(t("Apply"),form).addTo(form);
|
||||
form.addTo(window);
|
||||
|
||||
if (isSet(route)) {
|
||||
new Tag("p").content(t("Locked by {}",route)).addTo(window);
|
||||
}
|
||||
|
||||
if (!routes.isEmpty()) {
|
||||
new Tag("h4").content(t("Routes using this tile:")).addTo(window);
|
||||
|
||||
Reference in New Issue
Block a user