Browse Source

added confirmation before plan analysation

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

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.58</version> <version>1.2.59</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>

7
resources/translations/Application.de.translation

@ -1,3 +1,4 @@
abort : abbrechen
Actions : Aktionen Actions : Aktionen
Actions\: : Aktionen: Actions\: : Aktionen:
Actions and contacts : Aktionen und Kontakte Actions and contacts : Aktionen und Kontakte
@ -18,7 +19,9 @@ add new train : neuen Zug anlegen
Add tile : Kachel hinzufügen Add tile : Kachel hinzufügen
Address : Adresse Address : Adresse
Address\: : Adresse: Address\: : Adresse:
analyze : analysieren
Analyze : analysieren Analyze : analysieren
Analyze may overwrite these routes! : Durch die Analyse können diese Fahrstraßen überschrieben werden!
and : und and : und
AndCondition : Und-Bedingung AndCondition : Und-Bedingung
Apply : Übernehmen Apply : Übernehmen
@ -60,6 +63,7 @@ ConditionalAction : bedingte Aktion
Conditions : Bedingungen Conditions : Bedingungen
Condition type\: : Bedingungs-Typ: Condition type\: : Bedingungs-Typ:
Connected to {}. : Mit {} verbunden. Connected to {}. : Mit {} verbunden.
Confirmation required : Bestätigung erforderlich
Contact : Kontakt Contact : Kontakt
Control : Steuerung Control : Steuerung
Control unit : Zentrale Control unit : Zentrale
@ -167,7 +171,7 @@ Origin\: {} to {} : Start: {} nach {}
Plan saved as "{}". : Plan als „{}“ gespeichert. Plan saved as "{}". : Plan als „{}“ gespeichert.
Port for state {} : Anschluss für Status {} Port for state {} : Anschluss für Status {}
PreserveRoute : Anschlußroute vorwählen PreserveRoute : Anschlußroute vorwählen
Properties : Eigenschaften Properties of plan : Plan-Eigenschaften
Properties of {} : Eigenschaften von {} Properties of {} : Eigenschaften von {}
Properties of {} @ ({},{}) : Eigenschaften von {} @ ({},{}) Properties of {} @ ({},{}) : Eigenschaften von {} @ ({},{})
PushPullTrain : Wendezug PushPullTrain : Wendezug
@ -296,3 +300,4 @@ Was not able to set all signals! : Konnte nicht alle Signale stellen!
Was not able to set all turnouts! : Konnte nicht alle Weichen stellen! Was not able to set all turnouts! : Konnte nicht alle Weichen stellen!
WEST : Westen WEST : Westen
Width : Breite Width : Breite
Your plan currently has {} routes. : Ihr Plan hat im Moment {} Fahrstraßen.

27
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 FULLSCREEN = "fullscreen";
private static final String SPEED_UNIT = "speed_unit"; private static final String SPEED_UNIT = "speed_unit";
private static final String LENGTH_UNIT = "length_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 ControlUnit controlUnit = new ControlUnit(this); // the control unit, to which the plan is connected
private Contact learningContact; private Contact learningContact;
@ -168,7 +169,7 @@ public class Plan extends BaseClass{
Block block = get(Id.from(params)); Block block = get(Id.from(params));
return block.addContact(); return block.addContact();
case ACTION_ANALYZE: case ACTION_ANALYZE:
return analyze(); return analyze(params);
case ACTION_AUTO: case ACTION_AUTO:
return simplifyRouteName(params); return simplifyRouteName(params);
case ACTION_CLICK: case ACTION_CLICK:
@ -253,10 +254,23 @@ public class Plan extends BaseClass{
/** /**
* search all possible routes in the plan * search all possible routes in the plan
* @param params
* @return a string giving information how many routes have been found * @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); List<Route> oldRoutes = BaseClass.listElements(Route.class);
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;
}
new Thread() {
public void run() {
Vector<Route> newRoutes = new Vector<Route>(); Vector<Route> newRoutes = new Vector<Route>();
for (Block block : BaseClass.listElements(Block.class)) { for (Block block : BaseClass.listElements(Block.class)) {
for (Connector con : block.startPoints()) { for (Connector con : block.startPoints()) {
@ -269,7 +283,12 @@ public class Plan extends BaseClass{
oldRoute.id = new Id("test"); // new routes may have the same ids and shall not be deleted in the next step! oldRoute.id = new Id("test"); // new routes may have the same ids and shall not be deleted in the next step!
oldRoute.remove(); oldRoute.remove();
} }
return t("Found {} routes.",newRoutes.size());
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(); 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); new Tag("h4").content(t("Editable properties")).addTo(win);
Form form = new Form("plan-properties-form"); Form form = new Form("plan-properties-form");

Loading…
Cancel
Save