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>
|
||||
<groupId>de.srsoftware</groupId>
|
||||
<artifactId>web4rail</artifactId>
|
||||
<version>1.3.46</version>
|
||||
<version>1.3.47</version>
|
||||
<name>Web4Rail</name>
|
||||
<packaging>jar</packaging>
|
||||
<description>Java Model Railway Control</description>
|
||||
|
||||
@@ -308,6 +308,7 @@ Setup actions : Vorbereitung-Aktionen
|
||||
ShowText : Text anzeigen
|
||||
Shunting : Rangieren
|
||||
Signals : Signale
|
||||
simplify all names : alle Namen vereinfachen
|
||||
simplify name : Name vereinfachen
|
||||
Simulating movement of {}... : Simuliere Fahrt von {}...
|
||||
Slower (10 {}) : 10 {} langsamer
|
||||
|
||||
@@ -50,7 +50,7 @@ public interface Constants {
|
||||
public static final String REALM_PLAN = "plan";
|
||||
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 COL = ": ";
|
||||
public static final String CONTACT = "contact";
|
||||
|
||||
@@ -797,7 +797,8 @@ public class Plan extends BaseClass{
|
||||
actions);
|
||||
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 {
|
||||
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)) {
|
||||
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:
|
||||
route.remove();
|
||||
plan.stream(t("Removed {}.",route));
|
||||
@@ -414,10 +417,13 @@ public class Route extends BaseClass {
|
||||
add(trigger,new BrakeStart(this));
|
||||
add(trigger,new PreserveRoute(this));
|
||||
|
||||
for (int i=1;i<contacts.size();i++) { // chose second contact, that is not a BlockContact
|
||||
Contact secondContact = contacts.get(i);
|
||||
if (secondContact instanceof BlockContact) continue;
|
||||
trigger = secondContact.trigger();
|
||||
int count = 0;
|
||||
for (int i=0;i<contacts.size();i++) { // chose second contact, that is not a BlockContact
|
||||
Contact contact = contacts.get(i);
|
||||
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));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -93,8 +93,10 @@ public class SetSignal extends Action {
|
||||
};
|
||||
|
||||
@Override
|
||||
public Object update(HashMap<String, String> params) {
|
||||
Tile tile = plan.get(new Id(params.get(SIGNAL)), false);
|
||||
public Object update(HashMap<String, String> params) {
|
||||
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;
|
||||
String st = params.get(Signal.STATE);
|
||||
if (isSet(st)) state = st;
|
||||
|
||||
Reference in New Issue
Block a user