diff --git a/pom.xml b/pom.xml
index 06ccca4..847570f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
4.0.0
de.srsoftware
web4rail
- 1.2.58
+ 1.2.59
Web4Rail
jar
Java Model Railway Control
diff --git a/resources/translations/Application.de.translation b/resources/translations/Application.de.translation
index 1e913e2..be4f09b 100644
--- a/resources/translations/Application.de.translation
+++ b/resources/translations/Application.de.translation
@@ -1,3 +1,4 @@
+abort : abbrechen
Actions : Aktionen
Actions\: : Aktionen:
Actions and contacts : Aktionen und Kontakte
@@ -18,7 +19,9 @@ add new train : neuen Zug anlegen
Add tile : Kachel hinzufügen
Address : Adresse
Address\: : Adresse:
+analyze : analysieren
Analyze : analysieren
+Analyze may overwrite these routes! : Durch die Analyse können diese Fahrstraßen überschrieben werden!
and : und
AndCondition : Und-Bedingung
Apply : Übernehmen
@@ -60,6 +63,7 @@ ConditionalAction : bedingte Aktion
Conditions : Bedingungen
Condition type\: : Bedingungs-Typ:
Connected to {}. : Mit {} verbunden.
+Confirmation required : Bestätigung erforderlich
Contact : Kontakt
Control : Steuerung
Control unit : Zentrale
@@ -167,7 +171,7 @@ Origin\: {} to {} : Start: {} nach {}
Plan saved as "{}". : Plan als „{}“ gespeichert.
Port for state {} : Anschluss für Status {}
PreserveRoute : Anschlußroute vorwählen
-Properties : Eigenschaften
+Properties of plan : Plan-Eigenschaften
Properties of {} : Eigenschaften von {}
Properties of {} @ ({},{}) : Eigenschaften von {} @ ({},{})
PushPullTrain : Wendezug
@@ -295,4 +299,5 @@ Was not able to lock {} : Konnte {} nicht reservieren
Was not able to set all signals! : Konnte nicht alle Signale stellen!
Was not able to set all turnouts! : Konnte nicht alle Weichen stellen!
WEST : Westen
-Width : Breite
\ No newline at end of file
+Width : Breite
+Your plan currently has {} routes. : Ihr Plan hat im Moment {} Fahrstraßen.
\ No newline at end of file
diff --git a/src/main/java/de/srsoftware/web4rail/Plan.java b/src/main/java/de/srsoftware/web4rail/Plan.java
index 72c4c3c..e4ddadd 100644
--- a/src/main/java/de/srsoftware/web4rail/Plan.java
+++ b/src/main/java/de/srsoftware/web4rail/Plan.java
@@ -136,6 +136,7 @@ public class Plan extends BaseClass{
private static final String FULLSCREEN = "fullscreen";
private static final String SPEED_UNIT = "speed_unit";
private static final String LENGTH_UNIT = "length_unit";
+ private static final String CONFIRM = "confirm";
private ControlUnit controlUnit = new ControlUnit(this); // the control unit, to which the plan is connected
private Contact learningContact;
@@ -167,8 +168,8 @@ public class Plan extends BaseClass{
case Block.ACTION_ADD_CONTACT:
Block block = get(Id.from(params));
return block.addContact();
- case ACTION_ANALYZE:
- return analyze();
+ case ACTION_ANALYZE:
+ return analyze(params);
case ACTION_AUTO:
return simplifyRouteName(params);
case ACTION_CLICK:
@@ -253,23 +254,41 @@ public class Plan extends BaseClass{
/**
* search all possible routes in the plan
+ * @param params
* @return a string giving information how many routes have been found
*/
- private String analyze() {
+ private Object analyze(HashMap params) {
List oldRoutes = BaseClass.listElements(Route.class);
- Vector newRoutes = new Vector();
- for (Block block : BaseClass.listElements(Block.class)) {
- for (Connector con : block.startPoints()) {
- newRoutes.addAll(follow(new Route().begin(block,con.from.inverse()),con));
- }
- }
- for (Tile tile : BaseClass.listElements(Tile.class)) tile.routes().clear();
- for (Route route : newRoutes) registerRoute(route.complete());
- for (Route oldRoute : oldRoutes) {
- oldRoute.id = new Id("test"); // new routes may have the same ids and shall not be deleted in the next step!
- oldRoute.remove();
+
+ if (!oldRoutes.isEmpty() && !"yes".equals(params.get(CONFIRM))) {
+ Window win = new Window("confirm-analyze", t("Confirmation required"));
+ new Tag("p").content(t("Your plan currently has {} routes.",oldRoutes.size())).addTo(win);
+ new Tag("p").content(t("Analyze may overwrite these routes!")).addTo(win);
+ button(t("analyze"), Map.of(ACTION,ACTION_ANALYZE,CONFIRM,"yes")).addTo(win);
+ button(t("abort")).addTo(win);
+ return win;
}
- return t("Found {} routes.",newRoutes.size());
+
+ new Thread() {
+ public void run() {
+ Vector newRoutes = new Vector();
+ for (Block block : BaseClass.listElements(Block.class)) {
+ for (Connector con : block.startPoints()) {
+ newRoutes.addAll(follow(new Route().begin(block,con.from.inverse()),con));
+ }
+ }
+ for (Tile tile : BaseClass.listElements(Tile.class)) tile.routes().clear();
+ for (Route route : newRoutes) registerRoute(route.complete());
+ for (Route oldRoute : oldRoutes) {
+ oldRoute.id = new Id("test"); // new routes may have the same ids and shall not be deleted in the next step!
+ oldRoute.remove();
+ }
+
+ stream(t("Found {} routes.",newRoutes.size()));
+ }
+ }.start();
+
+ return t("Analyzing plan...");
}
/**
@@ -591,7 +610,7 @@ public class Plan extends BaseClass{
if (isSet(tile)) return tile.properties();
}
- Window win = new Window("plan-properties", t("Properties"));
+ Window win = new Window("plan-properties", t("Properties of plan"));
new Tag("h4").content(t("Editable properties")).addTo(win);
Form form = new Form("plan-properties-form");