GUI improvements
This commit is contained in:
@@ -493,6 +493,7 @@ public class Train implements Comparable<Train>,Constants {
|
||||
|
||||
if (!route.lock()) return t("Was not able to lock {}",route);
|
||||
String error = null;
|
||||
if (direction != route.startDirection) turn();
|
||||
if (!route.setTurnouts()) error = t("Was not able to set all turnouts!");
|
||||
route.fireSetupActions(context);
|
||||
if (error == null && !route.setSignals(null)) error = t("Was not able to set all signals!");
|
||||
|
||||
@@ -61,8 +61,9 @@ public abstract class Block extends StretchableTile{
|
||||
@Override
|
||||
public Tag propForm(String id) {
|
||||
Tag form = super.propForm(id);
|
||||
new Tag("h4").content(t("Block properties")).addTo(form);
|
||||
|
||||
new Input(NAME, name).addTo(new Label(t("name:")+" ")).addTo(new Tag("p")).addTo(form);
|
||||
new Input(NAME, name).addTo(new Label(t("name:")+NBSP)).addTo(new Tag("p")).addTo(form);
|
||||
|
||||
new Checkbox(ALLOW_TURN,t("Turn allowed"),turnAllowed).addTo(new Tag("p")).addTo(form);
|
||||
|
||||
@@ -114,8 +115,7 @@ public abstract class Block extends StretchableTile{
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tile update(HashMap<String, String> params) throws IOException {
|
||||
super.update(params);
|
||||
public Tile update(HashMap<String, String> params) throws IOException {
|
||||
if (params.containsKey(NAME)) name=params.get(NAME);
|
||||
if (params.containsKey(TRAIN)) {
|
||||
int trainId = Integer.parseInt(params.get(TRAIN));
|
||||
@@ -127,6 +127,6 @@ public abstract class Block extends StretchableTile{
|
||||
}
|
||||
}
|
||||
turnAllowed = params.containsKey(ALLOW_TURN) && params.get(ALLOW_TURN).equals("on");
|
||||
return this;
|
||||
return super.update(params);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,8 +36,8 @@ public abstract class StretchableTile extends Tile {
|
||||
@Override
|
||||
public Tag propForm(String id) {
|
||||
Tag form = super.propForm(id);
|
||||
|
||||
Tag label = new Tag("label").content(t("length:"));
|
||||
new Tag("h4").content(t("Length")).addTo(form);
|
||||
Tag label = new Tag("label").content(t("length:")+NBSP);
|
||||
new Tag("input").attr("type", "number").attr("name","length").attr("value", length).addTo(label);
|
||||
label.addTo(new Tag("p")).addTo(form);
|
||||
|
||||
@@ -58,7 +58,6 @@ public abstract class StretchableTile extends Tile {
|
||||
|
||||
@Override
|
||||
public Tile update(HashMap<String, String> params) throws IOException {
|
||||
super.update(params);
|
||||
for (Entry<String, String> entry : params.entrySet()) {
|
||||
switch (entry.getKey()) {
|
||||
case LENGTH:
|
||||
@@ -66,6 +65,6 @@ public abstract class StretchableTile extends Tile {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
return super.update(params);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,14 +207,10 @@ public abstract class Tile implements Constants{
|
||||
Window window = new Window("tile-properties",t("Properties of {} @ ({},{})",title(),x,y));
|
||||
String formId = "tile-properties-"+id();
|
||||
Tag form = propForm(formId);
|
||||
if (form!=null && form.children().size()>3) {
|
||||
new Checkbox(DISABLED, t("disabled"), disabled).addTo(form);
|
||||
|
||||
new Button(t("Apply"),"submitForm('"+formId+"')").addTo(form);
|
||||
form.addTo(window);
|
||||
} else {
|
||||
window.content(t("This tile ({}) has no editable properties",getClass().getSimpleName()));
|
||||
}
|
||||
new Tag("h4").content(t("Availability")).addTo(form);
|
||||
new Checkbox(DISABLED, t("disabled"), disabled).addTo(form);
|
||||
new Button(t("Apply"),"submitForm('"+formId+"')").addTo(form);
|
||||
form.addTo(window);
|
||||
|
||||
if (route != null) {
|
||||
new Tag("p").content(t("Locked by {}",route)).addTo(window);
|
||||
|
||||
@@ -56,6 +56,7 @@ public abstract class Turnout extends Tile implements Device{
|
||||
}
|
||||
|
||||
protected Reply init() {
|
||||
if (address == 0) return new Reply(200,"OK");
|
||||
if (!initialized) {
|
||||
Command command = new Command("INIT {} GA "+address+" "+proto()) {
|
||||
|
||||
@@ -109,7 +110,7 @@ public abstract class Turnout extends Tile implements Device{
|
||||
new Radio(PROTOCOL, proto.toString(), t(proto.toString()), proto == this.protocol).addTo(protocol);
|
||||
}
|
||||
protocol.addTo(fieldset).addTo(form);
|
||||
new Input(ADDRESS, address).numeric().addTo(new Label(t("Address"))).addTo(fieldset);
|
||||
new Input(ADDRESS, address).numeric().addTo(new Label(t("Address:")+NBSP)).addTo(fieldset);
|
||||
return form;
|
||||
}
|
||||
|
||||
@@ -137,9 +138,13 @@ public abstract class Turnout extends Tile implements Device{
|
||||
Reply reply = init();
|
||||
if (reply != null && !reply.succeeded()) return reply;
|
||||
LOG.debug("Setting {} to {}",this,newState);
|
||||
if (address == 0) {
|
||||
state = newState;
|
||||
plan.place(this);
|
||||
return new Reply(200,"OK");
|
||||
}
|
||||
try {
|
||||
String cmd = commandFor(newState);
|
||||
return plan.queue(new Command(cmd) {
|
||||
return plan.queue(new Command(commandFor(newState)) {
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
|
||||
@@ -43,8 +43,8 @@ public class TurnoutL extends Turnout {
|
||||
break;
|
||||
}
|
||||
}
|
||||
new Input(STRAIGHT, portA).numeric().addTo(new Label(t("Straight port"))).addTo(fieldset);
|
||||
new Input(LEFT, portB).numeric().addTo(new Label(t("Left port"))).addTo(fieldset);
|
||||
new Input(STRAIGHT, portA).numeric().addTo(new Label(t("Straight port:")+NBSP)).addTo(fieldset);
|
||||
new Input(LEFT, portB).numeric().addTo(new Label(t("Left port:")+NBSP)).addTo(fieldset);
|
||||
return form;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,8 +44,8 @@ public class TurnoutR extends Turnout {
|
||||
break;
|
||||
}
|
||||
}
|
||||
new Input(STRAIGHT, portA).numeric().addTo(new Label(t("Straight port"))).addTo(fieldset);
|
||||
new Input(RIGHT, portB).numeric().addTo(new Label(t("Right port"))).addTo(fieldset);
|
||||
new Input(STRAIGHT, portA).numeric().addTo(new Label(t("Straight port:")+NBSP)).addTo(fieldset);
|
||||
new Input(RIGHT, portB).numeric().addTo(new Label(t("Right port:")+NBSP)).addTo(fieldset);
|
||||
return form;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user