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