setting turnouts for route now handeled by the setup actions

This commit is contained in:
Stephan Richter
2020-12-10 23:38:30 +01:00
parent 49185e79a2
commit 1e2edabcb1
10 changed files with 52 additions and 54 deletions

View File

@@ -159,6 +159,18 @@ public class Relay extends Tile implements Device{
return 'P';
}
}
public static Select selector(Relay preselected, Collection<Relay> exclude) {
if (isNull(exclude)) exclude = new Vector<Relay>();
Select select = new Select(Relay.class.getSimpleName());
new Tag("option").attr("value","0").content(t("unset")).addTo(select);
for (Relay relay : BaseClass.listElements(Relay.class)) {
if (exclude.contains(relay)) continue;
Tag opt = select.addOption(relay.id(), relay);
if (relay == preselected) opt.attr("selected", "selected");
}
return select;
}
public Relay setLabel(boolean state, String tx) {
if (state) {
@@ -222,6 +234,11 @@ public class Relay extends Tile implements Device{
return name;
}
@Override
public String toString() {
return getClass().getSimpleName()+" ("+(isSet(name) && !name.isEmpty() ? name+")" : "")+" @("+x+", "+y+")";
}
@Override
public Tile update(HashMap<String, String> params) {
if (params.containsKey(PROTOCOL)) protocol = Protocol.valueOf(params.get(PROTOCOL));
@@ -233,16 +250,4 @@ public class Relay extends Tile implements Device{
if (params.containsKey(NAME)) name = params.get(NAME);
return super.update(params);
}
public static Select selector(Relay preselected, Collection<Relay> exclude) {
if (isNull(exclude)) exclude = new Vector<Relay>();
Select select = new Select(Relay.class.getSimpleName());
new Tag("option").attr("value","0").content(t("unset")).addTo(select);
for (Relay relay : BaseClass.listElements(Relay.class)) {
if (exclude.contains(relay)) continue;
Tag opt = select.addOption(relay.id(), relay);
if (relay == preselected) opt.attr("selected", "selected");
}
return select;
}
}