added AndCondition
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.2.55</version>
|
<version>1.2.56</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>
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ Address : Adresse
|
|||||||
Address\: : Adresse:
|
Address\: : Adresse:
|
||||||
Analyze : analysieren
|
Analyze : analysieren
|
||||||
and : und
|
and : und
|
||||||
|
AndCondition : Und-Bedingung
|
||||||
Apply : Übernehmen
|
Apply : Übernehmen
|
||||||
Auto pilot : Autopilot
|
Auto pilot : Autopilot
|
||||||
AutopilotActive : Autopilot aktiv
|
AutopilotActive : Autopilot aktiv
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ public class BrakeStop extends Action {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean fire(Context context) {
|
public boolean fire(Context context) {
|
||||||
if (isNull(context.route())) return false;
|
if (isNull(context.route()) || isNull(context.route().train())) return false;
|
||||||
context.route().brakeStop();
|
context.route().brakeStop();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package de.srsoftware.web4rail.conditions;
|
||||||
|
|
||||||
|
public class AndCondition extends ConditionList{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean fulfilledBy(Context context) {
|
||||||
|
for (Condition condition : this) {
|
||||||
|
if (!condition.fulfilledBy(context)) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String glue() {
|
||||||
|
return t("and");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -114,6 +114,7 @@ public abstract class Condition extends BaseClass {
|
|||||||
|
|
||||||
private static List<Class<? extends Condition>> list() {
|
private static List<Class<? extends Condition>> list() {
|
||||||
return List.of(
|
return List.of(
|
||||||
|
AndCondition.class,
|
||||||
AutopilotActive.class,
|
AutopilotActive.class,
|
||||||
BlockFree.class,
|
BlockFree.class,
|
||||||
CarInTrain.class,
|
CarInTrain.class,
|
||||||
|
|||||||
@@ -148,7 +148,11 @@ public class ConditionList extends Condition implements Iterable<Condition>{
|
|||||||
if (conditions.isEmpty()) return "["+t("Click here to add conditions")+"]";
|
if (conditions.isEmpty()) return "["+t("Click here to add conditions")+"]";
|
||||||
StringBuffer sb = new StringBuffer(conditions.firstElement().toString());
|
StringBuffer sb = new StringBuffer(conditions.firstElement().toString());
|
||||||
String glue = glue();
|
String glue = glue();
|
||||||
for (int i=1; i<conditions.size(); i++) sb.append(" ").append(glue).append(" "+conditions.get(i));
|
for (int i=1; i<conditions.size(); i++) {
|
||||||
|
Condition condition = conditions.get(i);
|
||||||
|
String cString = condition instanceof ConditionList ? " ("+condition+")" : " "+condition;
|
||||||
|
sb.append(" ").append(glue).append(cString);
|
||||||
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user