improved code related to tag condition
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>0.9.8</version>
|
<version>0.9.9</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>
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ fieldset{
|
|||||||
background: red;
|
background: red;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul{
|
h4,ul{
|
||||||
clear: both;
|
clear: both;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ Properties of {} : Eigenschaften von {}
|
|||||||
Properties of {} @ ({},{}) : Eigenschaften von {} @ ({},{})
|
Properties of {} @ ({},{}) : Eigenschaften von {} @ ({},{})
|
||||||
Reduce speed to {} km/h : Geschwindigkeit auf {} km/h reduzieren
|
Reduce speed to {} km/h : Geschwindigkeit auf {} km/h reduzieren
|
||||||
Routes using this tile\: : Fahrstraßen, die diesen Abschnitt verwenden:
|
Routes using this tile\: : Fahrstraßen, die diesen Abschnitt verwenden:
|
||||||
|
Route will only be available to trains fulfilling all conditions. : Route ist nur für Züge verfügbar, die alle Bedingungen erfüllen.
|
||||||
save : speichern
|
save : speichern
|
||||||
Save plan : Plan speichern
|
Save plan : Plan speichern
|
||||||
SetRelay : Relais schalten
|
SetRelay : Relais schalten
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import de.srsoftware.web4rail.actions.SetSpeed;
|
|||||||
import de.srsoftware.web4rail.conditions.Condition;
|
import de.srsoftware.web4rail.conditions.Condition;
|
||||||
import de.srsoftware.web4rail.moving.Train;
|
import de.srsoftware.web4rail.moving.Train;
|
||||||
import de.srsoftware.web4rail.tags.Button;
|
import de.srsoftware.web4rail.tags.Button;
|
||||||
|
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.tiles.Block;
|
import de.srsoftware.web4rail.tiles.Block;
|
||||||
@@ -196,13 +197,15 @@ public class Route implements Constants{
|
|||||||
list.addTo(win);
|
list.addTo(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
new Tag("div").content(t("Route will only be available to trains fulfilling all conditions.")).addTo(win);
|
||||||
Form form = new Form("action-prop-form-"+id);
|
Form form = new Form("action-prop-form-"+id);
|
||||||
|
Fieldset fieldset = new Fieldset(t("Add condition"));
|
||||||
new Input(REALM,REALM_ROUTE).hideIn(form);
|
new Input(REALM,REALM_ROUTE).hideIn(form);
|
||||||
new Input(ID,id()).hideIn(form);
|
new Input(ID,id()).hideIn(form);
|
||||||
new Input(ACTION,ACTION_UPDATE).hideIn(form);
|
new Input(ACTION,ACTION_UPDATE).hideIn(form);
|
||||||
|
|
||||||
Condition.selector().addTo(form);
|
Condition.selector().addTo(fieldset);
|
||||||
new Button(t("Add condition"),form).addTo(form).addTo(win);
|
new Button(t("Add condition"),form).addTo(fieldset).addTo(form).addTo(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addContactsTo(Window win) {
|
private void addContactsTo(Window win) {
|
||||||
@@ -475,8 +478,8 @@ public class Route implements Constants{
|
|||||||
private void loadConditions(JSONArray arr) {
|
private void loadConditions(JSONArray arr) {
|
||||||
for (int i=0; i<arr.length(); i++) {
|
for (int i=0; i<arr.length(); i++) {
|
||||||
JSONObject json = arr.getJSONObject(i);
|
JSONObject json = arr.getJSONObject(i);
|
||||||
Condition condition = Condition.load(json);
|
Condition condition = Condition.create(json.getString(TYPE));
|
||||||
if (condition != null) conditions.add(condition);
|
if (condition != null) conditions.add(condition.load(json));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,8 +74,9 @@ public class ConditionalAction extends Action {
|
|||||||
super.load(json);
|
super.load(json);
|
||||||
for (Object o : json.getJSONArray(CONDITIONS)) {
|
for (Object o : json.getJSONArray(CONDITIONS)) {
|
||||||
if (o instanceof JSONObject) {
|
if (o instanceof JSONObject) {
|
||||||
Condition condition = Condition.load((JSONObject)o);
|
JSONObject j = (JSONObject) o;
|
||||||
if (condition != null) conditions.add(condition);
|
Condition condition = Condition.create(j.getString(TYPE));
|
||||||
|
if (condition != null) conditions.add(condition.load(j));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
actions = ActionList.load(json.getJSONArray(ACTIONS));
|
actions = ActionList.load(json.getJSONArray(ACTIONS));
|
||||||
|
|||||||
@@ -80,11 +80,9 @@ public abstract class Condition implements Constants {
|
|||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Condition load(JSONObject json) {
|
public Condition load(JSONObject json) {
|
||||||
String type = json.getString(TYPE);
|
inverted = json.has(INVERTED) && json.getBoolean(INVERTED);
|
||||||
Condition condition = Condition.create(type);
|
return this;
|
||||||
if (condition != null) condition.inverted = json.has(INVERTED) && json.getBoolean(INVERTED);
|
|
||||||
return condition;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tag link(String tagClass,String context) {
|
public Tag link(String tagClass,String context) {
|
||||||
|
|||||||
@@ -25,10 +25,10 @@ public class TrainHasTag extends Condition {
|
|||||||
return super.json().put(TAG, tag);
|
return super.json().put(TAG, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TrainHasTag load(JSONObject json) {
|
public Condition load(JSONObject json) {
|
||||||
TrainHasTag tl = new TrainHasTag();
|
super.load(json);
|
||||||
if (json.has(TAG)) tl.tag = json.getString(TAG);
|
if (json.has(TAG)) tag = json.getString(TAG);
|
||||||
return tl;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -25,10 +25,10 @@ public class TrainLength extends Condition {
|
|||||||
return super.json().put(MAX_LENGTH, maxLength);
|
return super.json().put(MAX_LENGTH, maxLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TrainLength load(JSONObject json) {
|
public Condition load(JSONObject json) {
|
||||||
TrainLength tl = new TrainLength();
|
super.load(json);
|
||||||
if (json.has(MAX_LENGTH)) tl.maxLength = json.getInt(MAX_LENGTH);
|
if (json.has(MAX_LENGTH)) maxLength = json.getInt(MAX_LENGTH);
|
||||||
return tl;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -24,9 +24,10 @@ public class TrainSelect extends Condition {
|
|||||||
return super.json().put(REALM_TRAIN, train.id);
|
return super.json().put(REALM_TRAIN, train.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TrainSelect load(JSONObject json) {
|
public Condition load(JSONObject json) {
|
||||||
int trainId = json.getInt(REALM_TRAIN);
|
super.load(json);
|
||||||
return new TrainSelect().train(Train.get(trainId));
|
train(Train.get(json.getInt(REALM_TRAIN)));
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user