bugfixes
This commit is contained in:
@@ -43,7 +43,7 @@ public class ActionList extends Action implements Iterable<Action>{
|
||||
|
||||
public ActionList add(Action action) {
|
||||
action.parent(this);
|
||||
actions.add(action);
|
||||
actions.add(action);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class ActionList extends Action implements Iterable<Action>{
|
||||
if (isNull(type)) return actionTypeForm();
|
||||
Action action = Action.create(type,this);
|
||||
if (action instanceof Action) {
|
||||
add(action);
|
||||
prepend(action);
|
||||
return context().properties();
|
||||
}
|
||||
return new Tag("span").content(t("Unknown action type: {}",type)).addTo(actionTypeForm());
|
||||
@@ -200,6 +200,12 @@ public class ActionList extends Action implements Iterable<Action>{
|
||||
return false;
|
||||
}
|
||||
|
||||
public ActionList prepend(Action action) {
|
||||
action.parent(this);
|
||||
actions.insertElementAt(action, 0);
|
||||
return this;
|
||||
}
|
||||
|
||||
public static Object process(HashMap<String, String> params, Plan plan) {
|
||||
String command = params.get(ACTION);
|
||||
if (command == null) return t("No action passed to ActionList.process()!");
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.List;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import de.srsoftware.web4rail.Application;
|
||||
import de.srsoftware.web4rail.BaseClass;
|
||||
import de.srsoftware.web4rail.Window;
|
||||
import de.srsoftware.web4rail.tags.Fieldset;
|
||||
@@ -36,7 +37,21 @@ public class DetermineTrainInBlock extends Action {
|
||||
public Action load(JSONObject json) {
|
||||
super.load(json);
|
||||
Id blockId = Id.from(json,BLOCK);
|
||||
if (isSet(blockId)) block = Block.get(blockId);
|
||||
if (isSet(blockId)) {
|
||||
block = Block.get(blockId);
|
||||
if (isNull(block)) {
|
||||
Application.threadPool.execute(new Thread() {
|
||||
public void run() {
|
||||
try {
|
||||
sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
block = Block.get(blockId);
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ public class SetDisplayText extends TextAction{
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return isNull(display) ? t("[Click here to select display!]") : t("Display \"{}\" on {}.",text,display);
|
||||
return isNull(display) ? "["+t("Click here to select display!")+"]" : t("Display \"{}\" on {}.",text,display);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -85,7 +85,7 @@ public class SetRelay extends Action {
|
||||
protected Object update(HashMap<String, String> params) {
|
||||
LOG.debug("update: {}",params);
|
||||
Id relayId = new Id(params.get(Relay.class.getSimpleName()));
|
||||
relay = Relay.get(relayId);
|
||||
relay = BaseClass.get(relayId);
|
||||
String st = params.get(Relay.STATE);
|
||||
if (isSet(st)) state = st.equals("true");
|
||||
return context().properties();
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.util.List;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import de.srsoftware.tools.Tag;
|
||||
import de.srsoftware.web4rail.Application;
|
||||
import de.srsoftware.web4rail.BaseClass;
|
||||
import de.srsoftware.web4rail.Window;
|
||||
import de.srsoftware.web4rail.tags.Fieldset;
|
||||
@@ -47,12 +48,25 @@ public class SetTurnout extends Action {
|
||||
|
||||
@Override
|
||||
public Action load(JSONObject json) {
|
||||
super.load(json);
|
||||
String turnoutId = json.getString(TURNOUT);
|
||||
super.load(json);
|
||||
Id turnoutId = json.has(TURNOUT) ? new Id(json.getString(TURNOUT)) : null;
|
||||
if (isSet(turnoutId)) {
|
||||
turnout = BaseClass.get(new Id(turnoutId));
|
||||
state = Turnout.State.valueOf(json.getString(Turnout.STATE));
|
||||
turnout = BaseClass.get(turnoutId);
|
||||
if (isNull(turnout)) {
|
||||
Application.threadPool.execute(new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
turnout = BaseClass.get(turnoutId);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
if (json.has(Turnout.STATE)) state = Turnout.State.valueOf(json.getString(Turnout.STATE));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.List;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import de.srsoftware.web4rail.Application;
|
||||
import de.srsoftware.web4rail.BaseClass;
|
||||
import de.srsoftware.web4rail.Window;
|
||||
import de.srsoftware.web4rail.tags.Fieldset;
|
||||
@@ -32,7 +33,23 @@ public class BlockFree extends Condition {
|
||||
|
||||
public Condition load(JSONObject json) {
|
||||
super.load(json);
|
||||
if (json.has(BLOCK)) block(Block.get(new Id(json.getString(BLOCK))));
|
||||
if (json.has(BLOCK)) {
|
||||
Id bid = new Id(json.getString(BLOCK));
|
||||
block(BaseClass.get(bid));
|
||||
if (isNull(block)) {
|
||||
Application.threadPool.execute(new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
block(BaseClass.get(bid));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -186,12 +186,6 @@ public abstract class Block extends StretchableTile{
|
||||
return this;
|
||||
}
|
||||
|
||||
public static Block get(Id blockId) {
|
||||
Tile tile = plan.get(blockId, false);
|
||||
if (tile instanceof Block) return (Block) tile;
|
||||
return null;
|
||||
}
|
||||
|
||||
private WaitTime getWaitTime(String tag) {
|
||||
if (tag == null) return null;
|
||||
for (WaitTime wt : waitTimes) {
|
||||
|
||||
@@ -187,6 +187,7 @@ public class Contact extends Tile{
|
||||
formInputs.add(t("Address"),span);
|
||||
|
||||
Fieldset fieldset = new Fieldset(t("Actions"));
|
||||
fieldset.id("actions");
|
||||
actions.list().addTo(fieldset);
|
||||
postForm.add(fieldset);
|
||||
return super.properties(preForm, formInputs, postForm);
|
||||
|
||||
Reference in New Issue
Block a user