implemented disabling of blocks and routes
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>0.9.15</version>
|
||||
<version>0.9.16</version>
|
||||
<name>Web4Rail</name>
|
||||
<packaging>jar</packaging>
|
||||
<description>Java Model Railway Control</description>
|
||||
|
||||
@@ -22,6 +22,7 @@ DelayedAction : verzögerte Aktion
|
||||
delete : entfernen
|
||||
delete route : Route löschen
|
||||
Destination\: {} from {} : Ziel: {} von {}
|
||||
disabled : deaktiviert
|
||||
editable train properties : veränderliche Zug-Eigenschaften
|
||||
Emergency : Notfall
|
||||
FinishRoute : Route abschließen
|
||||
@@ -38,6 +39,7 @@ Manage trains : Züge verwalten
|
||||
Maximum train length\: : maximale Zug-Länge
|
||||
Move tiles : Kacheln verschieben
|
||||
name\: : Name:
|
||||
No free routes from {} : keine Route von {} frei
|
||||
Online Documentation : Online-Dokumentation
|
||||
other train properties : andere Zug-Eigenschaften
|
||||
Origin and destination : Start und Ziel
|
||||
@@ -61,6 +63,7 @@ SetSignalsToStop : Signale auf Halt stellen
|
||||
SetSpeed : Geschwindigkeit ändern
|
||||
Setup actions : Aktivierungs-Aktionen
|
||||
Signals : Signale
|
||||
Started {} : {} gestartet
|
||||
StopAuto : Automatikmodus abschalten
|
||||
STRAIGHT : gerade
|
||||
Tags : Markierungen
|
||||
@@ -82,3 +85,7 @@ Turnouts : Weichen
|
||||
TurnTrain : Fahrtrichtung umkehren
|
||||
Unknown action\: {} : Unbekannte Aktion: {}
|
||||
unset : ungesetzt
|
||||
Was not able to assign {} to {}! : Konnte {} nicht an {} zuweisen!
|
||||
Was not able to lock {} : Konnte {} nicht reservieren
|
||||
Was not able to set all signals! : Konnte nicht alle Signale stellen!
|
||||
Was not able to set all turnouts! : Konnte nicht alle Weichen stellen!
|
||||
|
||||
@@ -54,4 +54,5 @@ public interface Constants {
|
||||
public static final String NBSP = " ";
|
||||
public static final String CONTEXT = "context";
|
||||
public static final String GITHUB_URL = "https://github.com/srsoftware-de/Web4Rail";
|
||||
public static final String DISABLED = "disabled";
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import de.srsoftware.web4rail.actions.SetSpeed;
|
||||
import de.srsoftware.web4rail.conditions.Condition;
|
||||
import de.srsoftware.web4rail.moving.Train;
|
||||
import de.srsoftware.web4rail.tags.Button;
|
||||
import de.srsoftware.web4rail.tags.Checkbox;
|
||||
import de.srsoftware.web4rail.tags.Fieldset;
|
||||
import de.srsoftware.web4rail.tags.Form;
|
||||
import de.srsoftware.web4rail.tags.Input;
|
||||
@@ -71,6 +72,7 @@ public class Route implements Constants{
|
||||
|
||||
public Direction startDirection;
|
||||
private Direction endDirection;
|
||||
private boolean disabled = false;
|
||||
|
||||
private static final String TRIGGER = "trigger";
|
||||
private static final String ACTIONS = "actions";
|
||||
@@ -236,8 +238,9 @@ public class Route implements Constants{
|
||||
new Input(ID,id()).hideIn(form);
|
||||
if (params.containsKey(CONTEXT)) new Input(CONTEXT,params.get(CONTEXT)).hideIn(form);
|
||||
Tag label = new Tag("label").content(t("name:")+NBSP);
|
||||
new Tag("input").attr("type", "text").attr(NAME,"name").attr("value", name()).style("width: 80%").addTo(label);
|
||||
new Input(NAME, name()).style("width: 80%").addTo(label);
|
||||
label.addTo(form);
|
||||
new Checkbox(DISABLED, t("disabled"), disabled).addTo(form);
|
||||
|
||||
new Button(t("Apply"),form).addTo(form).addTo(win);
|
||||
}
|
||||
@@ -268,6 +271,7 @@ public class Route implements Constants{
|
||||
* @return false, if any of the associated conditions is not fulfilled
|
||||
*/
|
||||
public boolean allowed(Context context) {
|
||||
if (disabled) return false;
|
||||
for (Condition condition : conditions) {
|
||||
if (!condition.fulfilledBy(context)) return false;
|
||||
}
|
||||
@@ -416,6 +420,8 @@ public class Route implements Constants{
|
||||
String name = name();
|
||||
if (name != null) json.put(NAME, name);
|
||||
|
||||
if (disabled) json.put(DISABLED, true);
|
||||
|
||||
return json.toString();
|
||||
}
|
||||
|
||||
@@ -451,6 +457,7 @@ public class Route implements Constants{
|
||||
if (json.has(ACTIONS)) {
|
||||
setupActions = ActionList.load(json.getJSONArray(ACTIONS));
|
||||
}
|
||||
if (json.has(DISABLED)) disabled = json.getBoolean(DISABLED);
|
||||
return plan.registerRoute(this);
|
||||
}
|
||||
|
||||
@@ -618,6 +625,8 @@ public class Route implements Constants{
|
||||
String name = params.get(NAME);
|
||||
if (name != null) name(name);
|
||||
|
||||
disabled = "on".equals(params.get(DISABLED));
|
||||
|
||||
Condition condition = Condition.create(params.get(REALM_CONDITION));
|
||||
if (condition != null) {
|
||||
conditions.add(condition);
|
||||
|
||||
@@ -61,6 +61,7 @@ public abstract class Condition implements Constants {
|
||||
}
|
||||
|
||||
public static Condition create(String type) {
|
||||
if (type == null) return null;
|
||||
try {
|
||||
return (Condition) Class.forName(PREFIX+"."+type).getDeclaredConstructor().newInstance();
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -31,6 +31,7 @@ import de.srsoftware.web4rail.Route;
|
||||
import de.srsoftware.web4rail.Window;
|
||||
import de.srsoftware.web4rail.moving.Train;
|
||||
import de.srsoftware.web4rail.tags.Button;
|
||||
import de.srsoftware.web4rail.tags.Checkbox;
|
||||
import de.srsoftware.web4rail.tags.Form;
|
||||
import de.srsoftware.web4rail.tags.Input;
|
||||
import de.srsoftware.web4rail.tags.Radio;
|
||||
@@ -58,6 +59,7 @@ public abstract class Tile implements Constants{
|
||||
protected HashSet<Shadow> shadows = new HashSet<>();
|
||||
private HashSet<Route> routes = new HashSet<>();
|
||||
protected Plan plan;
|
||||
private boolean disabled = false;
|
||||
|
||||
protected static Logger LOG = LoggerFactory.getLogger(Tile.class);
|
||||
|
||||
@@ -92,7 +94,7 @@ public abstract class Tile implements Constants{
|
||||
}
|
||||
|
||||
public boolean free() {
|
||||
return route == null;
|
||||
return (!disabled) && route == null;
|
||||
}
|
||||
|
||||
public int height() {
|
||||
@@ -122,6 +124,7 @@ public abstract class Tile implements Constants{
|
||||
json.put(POS, pos);
|
||||
if (route != null) json.put(ROUTE, route.id());
|
||||
if (oneWay != null) json.put(ONEW_WAY, oneWay);
|
||||
if (disabled) json.put(DISABLED, true);
|
||||
return json;
|
||||
}
|
||||
|
||||
@@ -152,6 +155,7 @@ public abstract class Tile implements Constants{
|
||||
x = pos.getInt(X);
|
||||
y = pos.getInt(Y);
|
||||
if (json.has(ONEW_WAY)) oneWay = Direction.valueOf(json.getString(ONEW_WAY));
|
||||
if (json.has(DISABLED)) disabled = json.getBoolean(DISABLED);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -186,6 +190,7 @@ public abstract class Tile implements Constants{
|
||||
new Input(REALM, REALM_PLAN).hideIn(form);
|
||||
new Input(ID,id()).hideIn(form);
|
||||
|
||||
|
||||
List<Direction> pd = possibleDirections();
|
||||
if (!pd.isEmpty()) {
|
||||
new Tag("h4").content(t("One way:")).addTo(form);
|
||||
@@ -202,6 +207,8 @@ public abstract class Tile implements Constants{
|
||||
String formId = "tile-properties-"+id();
|
||||
Tag form = propForm(formId);
|
||||
if (form!=null && form.children().size()>3) {
|
||||
new Checkbox(DISABLED, t("disabled"), disabled).addTo(form);
|
||||
|
||||
new Button(t("Apply"),"submitForm('"+formId+"')").addTo(form);
|
||||
form.addTo(window);
|
||||
} else {
|
||||
@@ -370,6 +377,7 @@ public abstract class Tile implements Constants{
|
||||
oneWay = null;
|
||||
}
|
||||
}
|
||||
disabled = "on".equals(params.get(DISABLED));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user