diff --git a/pom.xml b/pom.xml
index eb1ae21..3f82a6c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
4.0.0
de.srsoftware
web4rail
- 1.2.7
+ 1.2.8
Web4Rail
jar
Java Model Railway Control
diff --git a/src/main/java/de/srsoftware/web4rail/Plan.java b/src/main/java/de/srsoftware/web4rail/Plan.java
index 4059c7d..91ddcdc 100644
--- a/src/main/java/de/srsoftware/web4rail/Plan.java
+++ b/src/main/java/de/srsoftware/web4rail/Plan.java
@@ -240,6 +240,7 @@ public class Plan extends BaseClass{
}
//if (configJson != null) tile.configure(new JSONObject(configJson));
set(x, y, tile);
+ tile.parent(this);
return t("Added {}",tile.getClass().getSimpleName());
}
@@ -647,7 +648,7 @@ public class Plan extends BaseClass{
newRoute.path().stream().filter(Tile::isSet).forEach(tile -> tile.add(newRoute));
Route existingRoute = BaseClass.get(newRoute.id());
if (isSet(existingRoute)) newRoute.addPropertiesFrom(existingRoute);
- newRoute.register();
+ newRoute.parent(this).register();
return newRoute;
}
@@ -655,6 +656,7 @@ public class Plan extends BaseClass{
protected void removeChild(BaseClass child) {
if (child instanceof Tile) {
Tile tile = (Tile) child;
+ stream("remove "+tile.id());
for (int i=1; i{
postForm.add(brakeTimes());
return super.properties(preForm, formInputs, postForm);
}
+
+ @Override
+ public BaseClass remove() {
+ super.remove();
+ if (isSet(train)) train.removeChild(this);
+ path.forEach(tile -> tile.removeChild(this));
+ conditions.remove();
+ for (String key : new Vector(triggers.keySet())){
+ ActionList actionList = triggers.remove(key);
+ if (isSet(actionList)) actionList.remove();
+ };
+ setupActions.remove();
+ startActions.remove();
+ return this;
+ }
@Override
- protected void removeChild(BaseClass child) {
+ public void removeChild(BaseClass child) {
conditions.remove(child);
contacts.remove(child);
if (child == endBlock) endBlock = null;
diff --git a/src/main/java/de/srsoftware/web4rail/actions/ActionList.java b/src/main/java/de/srsoftware/web4rail/actions/ActionList.java
index 1151838..4ff7131 100644
--- a/src/main/java/de/srsoftware/web4rail/actions/ActionList.java
+++ b/src/main/java/de/srsoftware/web4rail/actions/ActionList.java
@@ -193,6 +193,13 @@ public class ActionList extends Action implements Iterable{
return super.properties(preForm, formInputs, postForm);
}
+ @Override
+ public BaseClass remove() {
+ super.remove();
+ while (!actions.isEmpty()) actions.lastElement().remove();
+ return this;
+ }
+
@Override
public void removeChild(BaseClass child) {
actions.remove(child);
diff --git a/src/main/java/de/srsoftware/web4rail/conditions/ConditionList.java b/src/main/java/de/srsoftware/web4rail/conditions/ConditionList.java
index be186df..67a0968 100644
--- a/src/main/java/de/srsoftware/web4rail/conditions/ConditionList.java
+++ b/src/main/java/de/srsoftware/web4rail/conditions/ConditionList.java
@@ -90,6 +90,13 @@ public class ConditionList extends Condition implements Iterable{
return form;
}
+ @Override
+ public BaseClass remove() {
+ super.remove();
+ while (!conditions.isEmpty()) conditions.lastElement().remove();
+ return this;
+ }
+
public boolean remove(Object condition) {
return conditions.remove(condition);
}
diff --git a/src/main/java/de/srsoftware/web4rail/moving/Car.java b/src/main/java/de/srsoftware/web4rail/moving/Car.java
index 98d24a6..8a020a4 100644
--- a/src/main/java/de/srsoftware/web4rail/moving/Car.java
+++ b/src/main/java/de/srsoftware/web4rail/moving/Car.java
@@ -45,7 +45,6 @@ public class Car extends BaseClass implements Comparable{
public int length;
protected String stockId = "";
private Train train;
- protected Plan plan;
protected int maxSpeed = 0;
public Car(String name) {
@@ -66,8 +65,8 @@ public class Car extends BaseClass implements Comparable{
switch (params.get(ACTION)) {
case ACTION_ADD:
if (isSet(car)) {
- car.clone().plan(plan);
- } else new Car(params.get(Car.NAME)).plan(plan);
+ car.clone();
+ } else new Car(params.get(Car.NAME)).parent(plan);
return Car.manager();
case ACTION_PROPS:
return car == null ? Car.manager() : car.properties();
@@ -85,6 +84,7 @@ public class Car extends BaseClass implements Comparable{
clone.length = length;
clone.tags = new HashSet(tags);
clone.notes = notes;
+ clone.parent(parent());
return clone;
}
@@ -136,7 +136,7 @@ public class Car extends BaseClass implements Comparable{
String name = json.getString(Car.NAME);
Id id = Id.from(json);
Car car = json.has(Locomotive.LOCOMOTIVE) ? new Locomotive(name, id) : new Car(name,id);
- car.load(json).plan(plan);
+ car.load(json).parent(plan);
line = file.readLine();
}
@@ -189,15 +189,6 @@ public class Car extends BaseClass implements Comparable{
return name;
}
- public Plan plan() {
- return plan;
- }
-
- public Car plan(Plan plan) {
- this.plan = plan;
- return this;
- }
-
@Override
protected Window properties(List