added opßtion to simplify all route names in one step
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.3.46</version>
|
<version>1.3.47</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>
|
||||||
|
|||||||
@@ -308,6 +308,7 @@ Setup actions : Vorbereitung-Aktionen
|
|||||||
ShowText : Text anzeigen
|
ShowText : Text anzeigen
|
||||||
Shunting : Rangieren
|
Shunting : Rangieren
|
||||||
Signals : Signale
|
Signals : Signale
|
||||||
|
simplify all names : alle Namen vereinfachen
|
||||||
simplify name : Name vereinfachen
|
simplify name : Name vereinfachen
|
||||||
Simulating movement of {}... : Simuliere Fahrt von {}...
|
Simulating movement of {}... : Simuliere Fahrt von {}...
|
||||||
Slower (10 {}) : 10 {} langsamer
|
Slower (10 {}) : 10 {} langsamer
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public interface Constants {
|
|||||||
public static final String REALM_PLAN = "plan";
|
public static final String REALM_PLAN = "plan";
|
||||||
public static final String REALM_TRAIN = "train";
|
public static final String REALM_TRAIN = "train";
|
||||||
|
|
||||||
public static final String ASSIGN = "assign";
|
public static final String ASSIGN = "assign";
|
||||||
public static final String BLOCK = "block";
|
public static final String BLOCK = "block";
|
||||||
public static final String COL = ": ";
|
public static final String COL = ": ";
|
||||||
public static final String CONTACT = "contact";
|
public static final String CONTACT = "contact";
|
||||||
|
|||||||
@@ -797,7 +797,8 @@ public class Plan extends BaseClass{
|
|||||||
actions);
|
actions);
|
||||||
if (route.isDisabled()) row.clazz("disabled");
|
if (route.isDisabled()) row.clazz("disabled");
|
||||||
}
|
}
|
||||||
return table.clazz("turnouts").addTo(fieldset);
|
table.clazz("turnouts").addTo(fieldset);
|
||||||
|
return button(t("simplify all names"), Map.of(REALM,REALM_ROUTE,ACTION,ACTION_AUTO,ID,"*")).addTo(fieldset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -240,10 +240,13 @@ public class Route extends BaseClass {
|
|||||||
*/
|
*/
|
||||||
public static Object action(HashMap<String, String> params) throws IOException {
|
public static Object action(HashMap<String, String> params) throws IOException {
|
||||||
Route route = BaseClass.get(Id.from(params));
|
Route route = BaseClass.get(Id.from(params));
|
||||||
if (isNull(route)) return t("Unknown route: {}",params.get(ID));
|
String action = params.get(ACTION);
|
||||||
|
if (isNull(route) && !ACTION_AUTO.equals(action)) return t("Unknown route: {}",params.get(ID));
|
||||||
switch (params.get(ACTION)) {
|
switch (params.get(ACTION)) {
|
||||||
case ACTION_AUTO:
|
case ACTION_AUTO:
|
||||||
return route.simplyfyName().properties();
|
if (isSet(route)) return route.simplyfyName().properties();
|
||||||
|
for (Route rt : BaseClass.listElements(Route.class)) rt.simplyfyName();
|
||||||
|
return plan.properties(new HashMap<String, String>());
|
||||||
case ACTION_DROP:
|
case ACTION_DROP:
|
||||||
route.remove();
|
route.remove();
|
||||||
plan.stream(t("Removed {}.",route));
|
plan.stream(t("Removed {}.",route));
|
||||||
@@ -414,10 +417,13 @@ public class Route extends BaseClass {
|
|||||||
add(trigger,new BrakeStart(this));
|
add(trigger,new BrakeStart(this));
|
||||||
add(trigger,new PreserveRoute(this));
|
add(trigger,new PreserveRoute(this));
|
||||||
|
|
||||||
for (int i=1;i<contacts.size();i++) { // chose second contact, that is not a BlockContact
|
int count = 0;
|
||||||
Contact secondContact = contacts.get(i);
|
for (int i=0;i<contacts.size();i++) { // chose second contact, that is not a BlockContact
|
||||||
if (secondContact instanceof BlockContact) continue;
|
Contact contact = contacts.get(i);
|
||||||
trigger = secondContact.trigger();
|
if (contact instanceof BlockContact) continue;
|
||||||
|
if (count++<1) continue;
|
||||||
|
|
||||||
|
trigger = contact.trigger(); // second contact, that is not a BlockContact
|
||||||
for (Signal signal : signals) add(trigger,new SetSignal(this).set(signal).to(Signal.RED));
|
for (Signal signal : signals) add(trigger,new SetSignal(this).set(signal).to(Signal.RED));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,9 @@ public class SetSignal extends Action {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object update(HashMap<String, String> params) {
|
public Object update(HashMap<String, String> params) {
|
||||||
Tile tile = plan.get(new Id(params.get(SIGNAL)), false);
|
String signalId = params.get(SIGNAL);
|
||||||
|
Id tileId = isSet(signalId) ? new Id(signalId) : null;
|
||||||
|
Tile tile = isSet(tileId) ? plan.get(tileId, false) : null;
|
||||||
if (tile instanceof Signal) signal = (Signal) tile;
|
if (tile instanceof Signal) signal = (Signal) tile;
|
||||||
String st = params.get(Signal.STATE);
|
String st = params.get(Signal.STATE);
|
||||||
if (isSet(st)) state = st;
|
if (isSet(st)) state = st;
|
||||||
|
|||||||
Reference in New Issue
Block a user