Browse Source

added confirmation before plan analysation

lookup-tables
Stephan Richter 5 years ago
parent
commit
0bd93e8614
  1. 2
      pom.xml
  2. 9
      resources/translations/Application.de.translation
  3. 51
      src/main/java/de/srsoftware/web4rail/Plan.java

2
pom.xml

@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.srsoftware</groupId>
<artifactId>web4rail</artifactId>
<version>1.2.58</version>
<version>1.2.59</version>
<name>Web4Rail</name>
<packaging>jar</packaging>
<description>Java Model Railway Control</description>

9
resources/translations/Application.de.translation

@ -1,3 +1,4 @@ @@ -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 @@ -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 @@ -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 {} @@ -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 @@ -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
Width : Breite
Your plan currently has {} routes. : Ihr Plan hat im Moment {} Fahrstraßen.

51
src/main/java/de/srsoftware/web4rail/Plan.java

@ -136,6 +136,7 @@ public class Plan extends BaseClass{ @@ -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{ @@ -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{ @@ -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<String, String> params) {
List<Route> oldRoutes = BaseClass.listElements(Route.class);
Vector<Route> newRoutes = new Vector<Route>();
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<Route> newRoutes = new Vector<Route>();
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{ @@ -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");

Loading…
Cancel
Save