added device table
This commit is contained in:
@@ -4,4 +4,6 @@ public interface Device {
|
||||
public static final String ADDRESS = "address";
|
||||
public static final String PORT = "port";
|
||||
public static final String PROTOCOL = "proto";
|
||||
|
||||
public int address();
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.nio.file.Files;
|
||||
import java.security.InvalidParameterException;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -35,6 +36,7 @@ import de.srsoftware.web4rail.tags.Div;
|
||||
import de.srsoftware.web4rail.tags.Form;
|
||||
import de.srsoftware.web4rail.tags.Input;
|
||||
import de.srsoftware.web4rail.tags.Label;
|
||||
import de.srsoftware.web4rail.tags.Table;
|
||||
import de.srsoftware.web4rail.tiles.Block;
|
||||
import de.srsoftware.web4rail.tiles.BlockH;
|
||||
import de.srsoftware.web4rail.tiles.BlockV;
|
||||
@@ -601,6 +603,8 @@ public class Plan extends BaseClass{
|
||||
}
|
||||
|
||||
Window win = new Window("plan-properties", t("Properties"));
|
||||
|
||||
new Tag("h4").content(t("Editable properties")).addTo(win);
|
||||
Form form = new Form("plan-properties-form");
|
||||
new Input(REALM,REALM_PLAN).hideIn(form);
|
||||
new Input(ACTION,ACTION_UPDATE).hideIn(form);
|
||||
@@ -608,6 +612,21 @@ public class Plan extends BaseClass{
|
||||
new Input(SPEED_UNIT, speedUnit).addTo(new Label(t("Speed unit")+":"+NBSP)).addTo(form);
|
||||
new Button(t("Save"), form).addTo(form);
|
||||
form.addTo(win);
|
||||
|
||||
new Tag("h4").content(t("turnout properties")).addTo(win);
|
||||
Table table = new Table();
|
||||
table.addHead(t("Address"),t("Relay/Turnout"));
|
||||
tiles.values()
|
||||
.stream()
|
||||
.filter(tile -> tile instanceof Device )
|
||||
.map(tile -> (Device) tile)
|
||||
.sorted(Comparator.comparing(Device::address))
|
||||
.forEach(turnout -> {
|
||||
table.addRow(turnout.address(),turnout);
|
||||
if (turnout.address() % 4 == 1) table.children().lastElement().clazz("group");
|
||||
});
|
||||
table.clazz("turnouts").addTo(win);
|
||||
|
||||
return win;
|
||||
}
|
||||
|
||||
|
||||
@@ -76,6 +76,11 @@ public class Locomotive extends Car implements Constants,Device{
|
||||
return t("Unknown action: {}",params.get(ACTION));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int address() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public static Tag cockpit(Object locoOrTrain) {
|
||||
int id = 0;
|
||||
int speed = 0;
|
||||
|
||||
@@ -44,6 +44,10 @@ public class Relay extends Tile implements Device{
|
||||
private static final String LABEL_B = "label_b";
|
||||
private static final String NAME = "name";
|
||||
|
||||
public int address() {
|
||||
return address;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object click() throws IOException {
|
||||
Object o = super.click();
|
||||
|
||||
@@ -41,6 +41,10 @@ public abstract class Turnout extends Tile implements Device{
|
||||
LEFT,STRAIGHT,RIGHT,UNDEF;
|
||||
}
|
||||
|
||||
public int address() {
|
||||
return address;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object click() throws IOException {
|
||||
LOG.debug(getClass().getSimpleName()+".click()");
|
||||
|
||||
Reference in New Issue
Block a user