added new action DisableEnableBlock

This commit is contained in:
Stephan Richter
2021-01-15 13:41:32 +01:00
parent c825268b5f
commit 14b7a69d03
9 changed files with 114 additions and 6 deletions

View File

@@ -297,10 +297,12 @@ public abstract class Block extends StretchableTile{
internalContacts.remove(blockContact);
}
public static Select selector(Block preselected,Collection<Block> exclude) {
public static Select selector(Object preset,Collection<Block> exclude) {
Block preselected = preset instanceof Block ? (Block) preset : null;
String firstEntry = preset instanceof String ? (String) preset : t("unset");
if (isNull(exclude)) exclude = new Vector<Block>();
Select select = new Select(Block.class.getSimpleName());
new Tag("option").attr("value","0").content(t("unset")).addTo(select);
new Tag("option").attr("value","0").content(firstEntry).addTo(select);
List<Block> blocks = BaseClass.listElements(Block.class);
Collections.sort(blocks, (b1,b2) -> b1.name.compareTo(b2.name));
for (Block block : blocks) {

View File

@@ -93,7 +93,7 @@ public abstract class Tile extends BaseClass implements Comparable<Tile>{
public Map<Connector,Turnout.State> connections(Direction from){
return new HashMap<>();
}
public int height() {
return 1;
}
@@ -477,6 +477,11 @@ public abstract class Tile extends BaseClass implements Comparable<Tile>{
plan.place(this);
}
public void setEnabled(boolean newState) {
disabled = !newState;
plan.place(this);
}
public void unlock() {
route = null;
train = null;