improved analyze-plan form
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.4.22</version>
|
<version>1.4.23</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>
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ ActivateRoute : Route aktivieren
|
|||||||
add : hinzufügen
|
add : hinzufügen
|
||||||
add command for {} : Kommando für {} hinzufügen
|
add command for {} : Kommando für {} hinzufügen
|
||||||
Added {} : {} hinzugefügt
|
Added {} : {} hinzugefügt
|
||||||
|
Added {} routes. : {} Routen hinzugefügt.
|
||||||
add action : Aktion hinzufügen
|
add action : Aktion hinzufügen
|
||||||
Add action to action list : Aktion zur Liste hinzufügen
|
Add action to action list : Aktion zur Liste hinzufügen
|
||||||
add car : Waggon hinzufügen
|
add car : Waggon hinzufügen
|
||||||
@@ -296,6 +297,8 @@ Route will only be available, if all conditions are fulfilled. : Route ist nur v
|
|||||||
Save "{}" : „{}“ speichern
|
Save "{}" : „{}“ speichern
|
||||||
Save : speichern
|
Save : speichern
|
||||||
SavePlan : Plan speichern
|
SavePlan : Plan speichern
|
||||||
|
Search new routes, do not update existing : Neue Routen suchen, bestehende nicht verändern
|
||||||
|
Search new routes, update existing : Neue Routen suchen, bestehende Aktualisieren
|
||||||
Seek in last : Durchsuche letzte
|
Seek in last : Durchsuche letzte
|
||||||
Select block : Block auswählen
|
Select block : Block auswählen
|
||||||
Select car : Fahrzeug auswählen
|
Select car : Fahrzeug auswählen
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import de.srsoftware.web4rail.tags.Fieldset;
|
|||||||
import de.srsoftware.web4rail.tags.Form;
|
import de.srsoftware.web4rail.tags.Form;
|
||||||
import de.srsoftware.web4rail.tags.Input;
|
import de.srsoftware.web4rail.tags.Input;
|
||||||
import de.srsoftware.web4rail.tags.Label;
|
import de.srsoftware.web4rail.tags.Label;
|
||||||
|
import de.srsoftware.web4rail.tags.Radio;
|
||||||
import de.srsoftware.web4rail.tags.Table;
|
import de.srsoftware.web4rail.tags.Table;
|
||||||
import de.srsoftware.web4rail.tags.Window;
|
import de.srsoftware.web4rail.tags.Window;
|
||||||
import de.srsoftware.web4rail.threads.ControlUnit;
|
import de.srsoftware.web4rail.threads.ControlUnit;
|
||||||
@@ -158,6 +159,9 @@ public class Plan extends BaseClass{
|
|||||||
private static final String RENAME = "rename";
|
private static final String RENAME = "rename";
|
||||||
private static final String SPEED_STEP = "speed_step";
|
private static final String SPEED_STEP = "speed_step";
|
||||||
private static final String ALLOW_JSON_EDIT = "allow_json_edit";
|
private static final String ALLOW_JSON_EDIT = "allow_json_edit";
|
||||||
|
private static final String DISCOVERY_MODE = "discovery_mode";
|
||||||
|
private static final String DISCOVER_NEW = "discover_new";
|
||||||
|
private static final String DISCOVER_UPDATE = "discover_update";
|
||||||
private String name = DEFAULT_NAME;
|
private String name = DEFAULT_NAME;
|
||||||
|
|
||||||
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
|
||||||
@@ -309,27 +313,54 @@ public class Plan extends BaseClass{
|
|||||||
Window win = new Window("confirm-analyze", t("Confirmation required"));
|
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("Your plan currently has {} routes.",oldRoutes.size())).addTo(win);
|
||||||
new Tag("p").content(t("Analyze may overwrite these routes!")).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);
|
Form form = new Form("plan-analyze-form");
|
||||||
|
|
||||||
|
Tag p = new Tag("p");
|
||||||
|
new Input(REALM,REALM_PLAN).hideIn(form);
|
||||||
|
new Input(ACTION,ACTION_ANALYZE).hideIn(form);
|
||||||
|
new Input(CONFIRM,"yes").hideIn(form);
|
||||||
|
new Radio(DISCOVERY_MODE, DISCOVER_UPDATE, t("Search new routes, update existing"), true).addTo(p);
|
||||||
|
new Radio(DISCOVERY_MODE, DISCOVER_NEW, t("Search new routes, do not update existing"), false).addTo(p);
|
||||||
|
p.addTo(form);
|
||||||
|
|
||||||
|
new Button(t("analyze"),form).addTo(form);
|
||||||
|
button(t("abort")).addTo(form);
|
||||||
|
|
||||||
|
form.addTo(win);
|
||||||
return win;
|
return win;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean keepExisting = DISCOVER_NEW.equals(params.get(DISCOVERY_MODE));
|
||||||
|
|
||||||
new Thread(Application.threadName("Plan.Analyzer")) {
|
new Thread(Application.threadName("Plan.Analyzer")) {
|
||||||
public void run() {
|
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()) newRoutes.addAll(follow(new Route().begin(block,con.from.inverse()),con));
|
||||||
newRoutes.addAll(follow(new Route().begin(block,con.from.inverse()),con));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for (Tile tile : BaseClass.listElements(Tile.class)) tile.routes().clear();
|
for (Tile tile : BaseClass.listElements(Tile.class)) tile.routes().clear();
|
||||||
for (Route route : newRoutes) registerRoute(route.complete());
|
int count = 0;
|
||||||
|
for (Route newRoute : newRoutes) {
|
||||||
|
newRoute.complete();
|
||||||
|
Route replacedRoute = BaseClass.get(newRoute.id());
|
||||||
|
if (isSet(replacedRoute)) {
|
||||||
|
if (keepExisting) continue;
|
||||||
|
newRoute.addPropertiesFrom(replacedRoute);
|
||||||
|
}
|
||||||
|
registerRoute(newRoute);
|
||||||
|
count ++;
|
||||||
|
}
|
||||||
for (Route oldRoute : oldRoutes) {
|
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!
|
if (keepExisting) {
|
||||||
oldRoute.remove();
|
registerRoute(oldRoute);
|
||||||
|
} else {
|
||||||
|
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()));
|
stream(t(keepExisting?"Added {} routes.":"Found {} routes.",count));
|
||||||
}
|
}
|
||||||
}.start();
|
}.start();
|
||||||
|
|
||||||
@@ -736,16 +767,14 @@ public class Plan extends BaseClass{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* adds a new route to the plan
|
* adds a route to the plan
|
||||||
* @param newRoute
|
* @param route
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Route registerRoute(Route newRoute) {
|
Route registerRoute(Route route) {
|
||||||
newRoute.path().stream().filter(Tile::isSet).forEach(tile -> tile.add(newRoute));
|
route.path().stream().filter(Tile::isSet).forEach(tile -> tile.add(route));
|
||||||
Route existingRoute = BaseClass.get(newRoute.id());
|
route.parent(this).register();
|
||||||
if (isSet(existingRoute)) newRoute.addPropertiesFrom(existingRoute);
|
return route;
|
||||||
newRoute.parent(this).register();
|
|
||||||
return newRoute;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Fieldset relayProperties() {
|
private Fieldset relayProperties() {
|
||||||
|
|||||||
Reference in New Issue
Block a user