minor improvements/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>1.2.31</version>
|
||||
<version>1.2.32</version>
|
||||
<name>Web4Rail</name>
|
||||
<packaging>jar</packaging>
|
||||
<description>Java Model Railway Control</description>
|
||||
|
||||
@@ -70,8 +70,7 @@ public class Car extends BaseClass implements Comparable<Car>{
|
||||
case ACTION_PROPS:
|
||||
return car == null ? Car.manager() : car.properties();
|
||||
case ACTION_UPDATE:
|
||||
car.update(params);
|
||||
return Car.manager();
|
||||
return car.update(params);
|
||||
}
|
||||
if (car instanceof Locomotive) return Locomotive.action(params,plan);
|
||||
return t("Unknown action: {}",params.get(ACTION));
|
||||
@@ -84,6 +83,7 @@ public class Car extends BaseClass implements Comparable<Car>{
|
||||
clone.tags = new HashSet<String>(tags);
|
||||
clone.notes = notes;
|
||||
clone.parent(parent());
|
||||
clone.register();
|
||||
return clone;
|
||||
}
|
||||
|
||||
@@ -152,13 +152,20 @@ public class Car extends BaseClass implements Comparable<Car>{
|
||||
cars.values()
|
||||
.stream()
|
||||
.filter(car -> !(car instanceof Locomotive))
|
||||
.sorted((c1,c2)->c2.stockId.compareTo(c1.stockId))
|
||||
.sorted((c1,c2)->{
|
||||
try {
|
||||
return Integer.parseInt(c1.stockId)-Integer.parseInt(c2.stockId);
|
||||
} catch (NumberFormatException nfe) {
|
||||
return c1.stockId.compareTo(c2.stockId);
|
||||
}
|
||||
|
||||
})
|
||||
.forEach(car -> table.addRow(
|
||||
car.stockId,
|
||||
car.link(),
|
||||
car.maxSpeed == 0 ? "–":(car.maxSpeed+NBSP+speedUnit),
|
||||
car.length+NBSP+lengthUnit,
|
||||
car.train,
|
||||
isSet(car.train) ? car.train.link("span", car.train) : "",
|
||||
String.join(", ", car.tags()),
|
||||
car.cloneButton()
|
||||
));
|
||||
@@ -232,7 +239,7 @@ public class Car extends BaseClass implements Comparable<Car>{
|
||||
this.train = train;
|
||||
}
|
||||
|
||||
protected Car update(HashMap<String, String> params) {
|
||||
protected Window update(HashMap<String, String> params) {
|
||||
super.update(params);
|
||||
if (params.containsKey(NAME)) name = params.get(NAME).trim();
|
||||
if (params.containsKey(LENGTH)) length = Integer.parseInt(params.get(LENGTH));
|
||||
@@ -246,7 +253,7 @@ public class Car extends BaseClass implements Comparable<Car>{
|
||||
if (!tag.isEmpty()) tags.add(tag);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
return properties();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -48,7 +48,7 @@ public class Locomotive extends Car implements Constants,Device{
|
||||
Locomotive loco = id == null ? null : Locomotive.get(id);
|
||||
switch (params.get(ACTION)) {
|
||||
case ACTION_ADD:
|
||||
new Locomotive(params.get(Locomotive.NAME)).parent(plan);
|
||||
new Locomotive(params.get(Locomotive.NAME)).parent(plan).register();
|
||||
return Locomotive.manager();
|
||||
case ACTION_FASTER10:
|
||||
return loco.faster(10);
|
||||
@@ -329,10 +329,10 @@ public class Locomotive extends Car implements Constants,Device{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Car update(HashMap<String, String> params) {
|
||||
protected Window update(HashMap<String, String> params) {
|
||||
super.update(params);
|
||||
if (params.containsKey(PROTOCOL)) proto = Protocol.valueOf(params.get(PROTOCOL));
|
||||
if (params.containsKey(ADDRESS)) address = Integer.parseInt(params.get(ADDRESS));
|
||||
return this;
|
||||
return properties();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -795,12 +795,12 @@ public class Train extends BaseClass implements Comparable<Train> {
|
||||
|
||||
public Tag turn() {
|
||||
LOG.debug("train.turn()");
|
||||
for (Locomotive loco : locos) loco.turn();
|
||||
if (isSet(direction)) {
|
||||
direction = direction.inverse();
|
||||
for (Locomotive loco : locos) loco.turn();
|
||||
reverseTrace();
|
||||
if (isSet(currentBlock)) plan.place(currentBlock);
|
||||
}
|
||||
if (isSet(currentBlock)) plan.place(currentBlock);
|
||||
return properties();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user