working on now property dialogs
This commit is contained in:
@@ -47,8 +47,10 @@ Command to send to control unit\: : Kommando, welches zur Zentrale gesendet werd
|
|||||||
ConditionalAction : bedingte Aktion
|
ConditionalAction : bedingte Aktion
|
||||||
Conditions : Bedingungen
|
Conditions : Bedingungen
|
||||||
Condition type\: : Bedingungs-Typ:
|
Condition type\: : Bedingungs-Typ:
|
||||||
|
Connected to {}. : Mit {} verbunden.
|
||||||
Control : Steuerung
|
Control : Steuerung
|
||||||
Control unit : Zentrale
|
Control unit : Zentrale
|
||||||
|
Counterpart : Gegenstück
|
||||||
Create action : Aktion erzeugen
|
Create action : Aktion erzeugen
|
||||||
Current location\: : Aktueller Ort:
|
Current location\: : Aktueller Ort:
|
||||||
Current location : Aufenthaltsort
|
Current location : Aufenthaltsort
|
||||||
@@ -114,13 +116,14 @@ new train : neuer Zug
|
|||||||
No : keine
|
No : keine
|
||||||
No free routes from {} : keine Route von {} frei
|
No free routes from {} : keine Route von {} frei
|
||||||
NORTH : Norden
|
NORTH : Norden
|
||||||
|
Not connected to other bridge part! : Nicht mit anderem Brücken-Teil verbunden!
|
||||||
Notes : Notizen
|
Notes : Notizen
|
||||||
{} now heading for {} : {} ist nun unterweg nach {}
|
{} now heading for {} : {} ist nun unterweg nach {}
|
||||||
{} now in auto-mode : {} ist nun im Automatikmodus
|
{} now in auto-mode : {} ist nun im Automatikmodus
|
||||||
Occupied area\: : Belegte Abschnitte:
|
Occupied area\: : Belegte Abschnitte:
|
||||||
Off : Aus
|
Off : Aus
|
||||||
On : An
|
On : An
|
||||||
One way\: : Richtung:
|
One way : Richtung
|
||||||
Online Documentation : Online-Dokumentation
|
Online Documentation : Online-Dokumentation
|
||||||
OrCondition : Oder-Bedingung
|
OrCondition : Oder-Bedingung
|
||||||
other train properties : andere Zug-Eigenschaften
|
other train properties : andere Zug-Eigenschaften
|
||||||
@@ -139,7 +142,7 @@ Relay/Turnout : Relais/Weiche
|
|||||||
Report Issue : Problem melden
|
Report Issue : Problem melden
|
||||||
RIGHT : rechts
|
RIGHT : rechts
|
||||||
Right port\: : Port für rechts
|
Right port\: : Port für rechts
|
||||||
Routes using this tile\: : Fahrstraßen, die diesen Abschnitt verwenden:
|
Routes using this tile : Fahrstraßen, die diesen Abschnitt verwenden
|
||||||
Route will only be available, if all conditions are fulfilled. : Route ist nur verfügbar, wenn alle Bedingungen erfüllt sind.
|
Route will only be available, if all conditions are fulfilled. : Route ist nur verfügbar, wenn alle Bedingungen erfüllt sind.
|
||||||
Save : speichern
|
Save : speichern
|
||||||
Select block\: : Block auswählen:
|
Select block\: : Block auswählen:
|
||||||
@@ -172,6 +175,7 @@ Speed unit : Geschwindigkeits-Einheit
|
|||||||
Start actions : Start-Aktionen
|
Start actions : Start-Aktionen
|
||||||
Stock ID : Inventarnummer
|
Stock ID : Inventarnummer
|
||||||
Started {} : {} gestartet
|
Started {} : {} gestartet
|
||||||
|
State : Status
|
||||||
StopAllTrains : Alle Züge stoppen
|
StopAllTrains : Alle Züge stoppen
|
||||||
StopAuto : Automatikmodus abschalten
|
StopAuto : Automatikmodus abschalten
|
||||||
{} stopping at next block. : {} hält im nächsten Block.
|
{} stopping at next block. : {} hält im nächsten Block.
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ public abstract class BaseClass implements Constants{
|
|||||||
|
|
||||||
|
|
||||||
public static class Context {
|
public static class Context {
|
||||||
|
|
||||||
private BaseClass main = null;
|
private BaseClass main = null;
|
||||||
private Tile tile;
|
private Tile tile;
|
||||||
private Block block;
|
private Block block;
|
||||||
@@ -125,6 +126,16 @@ public abstract class BaseClass implements Constants{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class FormInput extends ArrayList<Map.Entry<String, Tag>>{
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -2371203388908395216L;
|
||||||
|
|
||||||
|
public FormInput add(String caption,Tag tag) {
|
||||||
|
add(new AbstractMap.SimpleEntry<String,Tag>(caption,tag));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class Id implements CharSequence, Comparable<Id>{
|
public static class Id implements CharSequence, Comparable<Id>{
|
||||||
private String internalId;
|
private String internalId;
|
||||||
|
|
||||||
@@ -296,11 +307,11 @@ public abstract class BaseClass implements Constants{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Window properties() {
|
public Window properties() {
|
||||||
return properties(new ArrayList<>(), new ArrayList<>(), new ArrayList<>());
|
return properties(new ArrayList<>(), new FormInput(), new ArrayList<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected Window properties(List<Fieldset> preForm,List<Map.Entry<String, Tag>> formInputs,List<Fieldset> postForm) {
|
protected Window properties(List<Fieldset> preForm,FormInput formInputs,List<Fieldset> postForm) {
|
||||||
Window win = new Window(getClass().getSimpleName()+"-properties", t("Properties of {}",this));
|
Window win = new Window(getClass().getSimpleName()+"-properties", t("Properties of {}",this));
|
||||||
|
|
||||||
preForm.forEach(fieldset -> fieldset.addTo(win));
|
preForm.forEach(fieldset -> fieldset.addTo(win));
|
||||||
|
|||||||
@@ -611,7 +611,7 @@ public class Plan extends BaseClass{
|
|||||||
private Window properties(HashMap<String, String> params) {
|
private Window properties(HashMap<String, String> params) {
|
||||||
if (params.containsKey(ID)) {
|
if (params.containsKey(ID)) {
|
||||||
Tile tile = get(Id.from(params), true);
|
Tile tile = get(Id.from(params), true);
|
||||||
if (isSet(tile)) return tile.propMenu();
|
if (isSet(tile)) return tile.properties();
|
||||||
}
|
}
|
||||||
|
|
||||||
Window win = new Window("plan-properties", t("Properties"));
|
Window win = new Window("plan-properties", t("Properties"));
|
||||||
@@ -780,7 +780,7 @@ public class Plan extends BaseClass{
|
|||||||
contact.addr(0);
|
contact.addr(0);
|
||||||
LOG.debug("unsibscribed {} from {}",contact,addr);
|
LOG.debug("unsibscribed {} from {}",contact,addr);
|
||||||
}
|
}
|
||||||
stream(learningContact.addr(addr).propMenu().toString());
|
stream(learningContact.addr(addr).properties().toString());
|
||||||
learningContact = null;
|
learningContact = null;
|
||||||
LOG.debug("learned: {} = {}",addr,learningContact);
|
LOG.debug("learned: {} = {}",addr,learningContact);
|
||||||
return;
|
return;
|
||||||
@@ -804,7 +804,7 @@ public class Plan extends BaseClass{
|
|||||||
case REALM_CONTACT:
|
case REALM_CONTACT:
|
||||||
case REALM_PLAN:
|
case REALM_PLAN:
|
||||||
Tile tile = get(id, false);
|
Tile tile = get(id, false);
|
||||||
return isNull(tile) ? null : tile.propMenu();
|
return isNull(tile) ? null : tile.properties();
|
||||||
case REALM_ACTIONS:
|
case REALM_ACTIONS:
|
||||||
Action action = Action.get(id);
|
Action action = Action.get(id);
|
||||||
return (isSet(action)) ? action.properties(params) : null;
|
return (isSet(action)) ? action.properties(params) : null;
|
||||||
@@ -937,7 +937,7 @@ public class Plan extends BaseClass{
|
|||||||
if (tile instanceof Block) {
|
if (tile instanceof Block) {
|
||||||
Block block = (Block) tile;
|
Block block = (Block) tile;
|
||||||
place(block.updateTimes(params));
|
place(block.updateTimes(params));
|
||||||
return tile.propMenu();
|
return tile.properties();
|
||||||
}
|
}
|
||||||
return t("updateTimes called on non-block tile!");
|
return t("updateTimes called on non-block tile!");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import de.srsoftware.web4rail.Constants;
|
|||||||
import de.srsoftware.web4rail.Plan;
|
import de.srsoftware.web4rail.Plan;
|
||||||
import de.srsoftware.web4rail.Window;
|
import de.srsoftware.web4rail.Window;
|
||||||
import de.srsoftware.web4rail.tags.Button;
|
import de.srsoftware.web4rail.tags.Button;
|
||||||
|
import de.srsoftware.web4rail.tags.Fieldset;
|
||||||
import de.srsoftware.web4rail.tags.Form;
|
import de.srsoftware.web4rail.tags.Form;
|
||||||
import de.srsoftware.web4rail.tags.Input;
|
import de.srsoftware.web4rail.tags.Input;
|
||||||
|
|
||||||
@@ -132,6 +133,12 @@ public class ActionList extends Vector<Action> implements Constants{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Fieldset properties() {
|
||||||
|
Fieldset fieldset = new Fieldset(t("Actions"));
|
||||||
|
new Tag("p").content("replace ActionList.addTo(...) by ActionsList.properties()!").addTo(fieldset);
|
||||||
|
return fieldset;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean drop(Id actionId) {
|
public boolean drop(Id actionId) {
|
||||||
for (Action action : this) {
|
for (Action action : this) {
|
||||||
if (action.id().equals(actionId)) {
|
if (action.id().equals(actionId)) {
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import java.io.BufferedWriter;
|
|||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.AbstractMap;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -200,12 +199,12 @@ public class Car extends BaseClass implements Comparable<Car>{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Window properties(List<Fieldset> preForm, List<Entry<String, Tag>> formInputs, List<Fieldset> postForm) {
|
protected Window properties(List<Fieldset> preForm, FormInput formInputs, List<Fieldset> postForm) {
|
||||||
formInputs.add(new AbstractMap.SimpleEntry<>(t("Name"),new Input(NAME,name)));
|
formInputs.add(t("Name"),new Input(NAME,name));
|
||||||
formInputs.add(new AbstractMap.SimpleEntry<>(t("Stock ID"),new Input(STOCK_ID,stockId)));
|
formInputs.add(t("Stock ID"),new Input(STOCK_ID,stockId));
|
||||||
formInputs.add(new AbstractMap.SimpleEntry<>(t("Length"),new Input(LENGTH,length).attr("type", "number").addTo(new Tag("span")).content(NBSP+lengthUnit)));
|
formInputs.add(t("Length"),new Input(LENGTH,length).attr("type", "number").addTo(new Tag("span")).content(NBSP+lengthUnit));
|
||||||
formInputs.add(new AbstractMap.SimpleEntry<>(t("Tag"), new Input(TAGS,String.join(", ", tags))));
|
formInputs.add(t("Tag"), new Input(TAGS,String.join(", ", tags)));
|
||||||
formInputs.add(new AbstractMap.SimpleEntry<>(t("Maximum Speed"),new Input(MAX_SPEED, maxSpeed).numeric().addTo(new Tag("span")).content(NBSP+speedUnit)));
|
formInputs.add(t("Maximum Speed"),new Input(MAX_SPEED, maxSpeed).numeric().addTo(new Tag("span")).content(NBSP+speedUnit));
|
||||||
|
|
||||||
Fieldset fieldset = new Fieldset(t("Train"));
|
Fieldset fieldset = new Fieldset(t("Train"));
|
||||||
if (train != null) train.link().addTo(fieldset);
|
if (train != null) train.link().addTo(fieldset);
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
package de.srsoftware.web4rail.moving;
|
package de.srsoftware.web4rail.moving;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.AbstractMap;
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
@@ -263,14 +261,14 @@ public class Locomotive extends Car implements Constants,Device{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Window properties(List<Fieldset> preForm, List<Entry<String, Tag>> formInputs, List<Fieldset> postForm) {
|
protected Window properties(List<Fieldset> preForm, FormInput formInputs, List<Fieldset> postForm) {
|
||||||
preForm.add(cockpit(this));
|
preForm.add(cockpit(this));
|
||||||
Tag div = new Tag("div");
|
Tag div = new Tag("div");
|
||||||
for (Protocol proto : Protocol.values()) {
|
for (Protocol proto : Protocol.values()) {
|
||||||
new Radio(PROTOCOL, proto.toString(), t(proto.toString()), proto == this.proto).addTo(div);
|
new Radio(PROTOCOL, proto.toString(), t(proto.toString()), proto == this.proto).addTo(div);
|
||||||
}
|
}
|
||||||
formInputs.add(new AbstractMap.SimpleEntry<String,Tag>(t("Protocol"),div));
|
formInputs.add(t("Protocol"),div);
|
||||||
formInputs.add(new AbstractMap.SimpleEntry<String,Tag>(t("Address"),new Input(ADDRESS, address).numeric()));
|
formInputs.add(t("Address"),new Input(ADDRESS, address).numeric());
|
||||||
return super.properties(preForm, formInputs, postForm);
|
return super.properties(preForm, formInputs, postForm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import java.io.BufferedWriter;
|
|||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.AbstractMap;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -505,7 +504,7 @@ public class Train extends BaseClass implements Comparable<Train> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Window properties(List<Fieldset> preForm, List<Entry<String, Tag>> formInputs, List<Fieldset> postForm) {
|
protected Window properties(List<Fieldset> preForm, FormInput formInputs, List<Fieldset> postForm) {
|
||||||
Fieldset otherTrainProsps = new Fieldset(t("other train properties"));
|
Fieldset otherTrainProsps = new Fieldset(t("other train properties"));
|
||||||
|
|
||||||
Tag propList = new Tag("ul").clazz("proplist");
|
Tag propList = new Tag("ul").clazz("proplist");
|
||||||
@@ -546,9 +545,9 @@ public class Train extends BaseClass implements Comparable<Train> {
|
|||||||
|
|
||||||
propList.addTo(otherTrainProsps);
|
propList.addTo(otherTrainProsps);
|
||||||
|
|
||||||
formInputs.add(new AbstractMap.SimpleEntry<>(t("Name"), new Input(NAME,name)));
|
formInputs.add(t("Name"), new Input(NAME,name));
|
||||||
formInputs.add(new AbstractMap.SimpleEntry<>(t("Push-pull train"),new Checkbox(PUSH_PULL, t("Push-pull train"), pushPull)));
|
formInputs.add(t("Push-pull train"),new Checkbox(PUSH_PULL, t("Push-pull train"), pushPull));
|
||||||
formInputs.add(new AbstractMap.SimpleEntry<>(t("Tags"), new Input(TAGS,String.join(", ", tags))));
|
formInputs.add(t("Tags"), new Input(TAGS,String.join(", ", tags)));
|
||||||
|
|
||||||
preForm.add(Locomotive.cockpit(this));
|
preForm.add(Locomotive.cockpit(this));
|
||||||
postForm.add(otherTrainProsps);
|
postForm.add(otherTrainProsps);
|
||||||
|
|||||||
@@ -227,9 +227,8 @@ public abstract class Block extends StretchableTile implements Comparable<Block>
|
|||||||
return form;
|
return form;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Window propMenu() {
|
public Window propMenu() {
|
||||||
Window win = super.propMenu();
|
Window win = new Window("test", "Replace Block.propmenu by Block.properties!");
|
||||||
Form form = new Form("train-wait-form");
|
Form form = new Form("train-wait-form");
|
||||||
new Tag("h4").content(t("Stop settings")).addTo(win);
|
new Tag("h4").content(t("Stop settings")).addTo(win);
|
||||||
new Input(REALM,REALM_PLAN).hideIn(form);
|
new Input(REALM,REALM_PLAN).hideIn(form);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package de.srsoftware.web4rail.tiles;
|
package de.srsoftware.web4rail.tiles;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
@@ -10,6 +11,7 @@ import de.srsoftware.web4rail.Connector;
|
|||||||
import de.srsoftware.web4rail.Route;
|
import de.srsoftware.web4rail.Route;
|
||||||
import de.srsoftware.web4rail.Window;
|
import de.srsoftware.web4rail.Window;
|
||||||
import de.srsoftware.web4rail.moving.Train;
|
import de.srsoftware.web4rail.moving.Train;
|
||||||
|
import de.srsoftware.web4rail.tags.Fieldset;
|
||||||
|
|
||||||
public abstract class Bridge extends Tile {
|
public abstract class Bridge extends Tile {
|
||||||
private static final String COUNTERPART = "counterpart";
|
private static final String COUNTERPART = "counterpart";
|
||||||
@@ -75,10 +77,18 @@ public abstract class Bridge extends Tile {
|
|||||||
if (isSet(counterpart) && counterpart.route != route) counterpart.setRoute(route);
|
if (isSet(counterpart) && counterpart.route != route) counterpart.setRoute(route);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
protected Window properties(List<Fieldset> preForm, FormInput formInputs, List<Fieldset> postForm) {
|
||||||
|
Fieldset fieldset = new Fieldset(t("Counterpart"));
|
||||||
|
new Tag("p").content(isSet(counterpart) ? t("Connected to {}.",counterpart) : t("Not connected to other bridge part!")).addTo(fieldset);
|
||||||
|
button(t("Select counterpart"),Map.of(ACTION,ACTION_CONNECT)).addTo(fieldset);
|
||||||
|
preForm.add(fieldset);
|
||||||
|
return super.properties(preForm, formInputs, postForm);
|
||||||
|
}
|
||||||
|
|
||||||
public Window propMenu() {
|
public Window propMenu() {
|
||||||
Window win = super.propMenu();
|
Window win = new Window("test", "test");
|
||||||
new Tag("h4").content("Counterpart").addTo(win);
|
new Tag("h4").content("Counterpart").addTo(win);
|
||||||
new Tag("p").content(isSet(counterpart) ? t("Connected to {}.",counterpart) : t("Not connected to other bridge part!")).addTo(win);
|
new Tag("p").content(isSet(counterpart) ? t("Connected to {}.",counterpart) : t("Not connected to other bridge part!")).addTo(win);
|
||||||
button(t("Select counterpart"),Map.of(ACTION,ACTION_CONNECT)).addTo(win);
|
button(t("Select counterpart"),Map.of(ACTION,ACTION_CONNECT)).addTo(win);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package de.srsoftware.web4rail.tiles;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
@@ -12,9 +13,8 @@ import org.json.JSONObject;
|
|||||||
import de.srsoftware.tools.Tag;
|
import de.srsoftware.tools.Tag;
|
||||||
import de.srsoftware.web4rail.Window;
|
import de.srsoftware.web4rail.Window;
|
||||||
import de.srsoftware.web4rail.actions.ActionList;
|
import de.srsoftware.web4rail.actions.ActionList;
|
||||||
import de.srsoftware.web4rail.tags.Form;
|
import de.srsoftware.web4rail.tags.Fieldset;
|
||||||
import de.srsoftware.web4rail.tags.Input;
|
import de.srsoftware.web4rail.tags.Input;
|
||||||
import de.srsoftware.web4rail.tags.Label;
|
|
||||||
import de.srsoftware.web4rail.tags.Select;
|
import de.srsoftware.web4rail.tags.Select;
|
||||||
|
|
||||||
public class Contact extends Tile{
|
public class Contact extends Tile{
|
||||||
@@ -140,7 +140,7 @@ public class Contact extends Tile{
|
|||||||
if (id == null) return t("Missing ID on call to {}.process()",Contact.class.getSimpleName());
|
if (id == null) return t("Missing ID on call to {}.process()",Contact.class.getSimpleName());
|
||||||
contact = contactsById.get(id);
|
contact = contactsById.get(id);
|
||||||
if (contact == null) return t("No contact with id {} found!",id);
|
if (contact == null) return t("No contact with id {} found!",id);
|
||||||
Tag propMenu = contact.propMenu();
|
Tag propMenu = contact.properties();
|
||||||
propMenu.children().insertElementAt(new Tag("div").content(t("Trigger a feedback sensor to assign it with this contact!")), 1);
|
propMenu.children().insertElementAt(new Tag("div").content(t("Trigger a feedback sensor to assign it with this contact!")), 1);
|
||||||
plan.learn(contact);
|
plan.learn(contact);
|
||||||
return propMenu;
|
return propMenu;
|
||||||
@@ -148,22 +148,15 @@ public class Contact extends Tile{
|
|||||||
return t("Unknown action: {}",action);
|
return t("Unknown action: {}",action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Form propForm(String formId) {
|
protected Window properties(List<Fieldset> preForm, FormInput formInputs, List<Fieldset> postForm) {
|
||||||
Form form = super.propForm(formId);
|
Tag span = new Tag("span");
|
||||||
new Tag("h4").content(t("Hardware settings")).addTo(form);
|
new Input(ADDRESS, addr).numeric().addTo(span).content(NBSP);
|
||||||
Tag label = new Input(ADDRESS, addr).numeric().addTo(new Label(t("Address:")+NBSP));
|
button(t("learn"),Map.of(ACTION,ACTION_ANALYZE)).addTo(span);
|
||||||
button(t("learn"),Map.of(ACTION,ACTION_ANALYZE)).addTo(label).addTo(form);
|
formInputs.add(t("Hardware settings"),span);
|
||||||
return form;
|
|
||||||
}
|
postForm.add(actions.properties());
|
||||||
|
return super.properties(preForm, formInputs, postForm);
|
||||||
@Override
|
|
||||||
public Window propMenu() {
|
|
||||||
Window win = super.propMenu();
|
|
||||||
new Tag("h4").content(t("Actions")).addTo(win);
|
|
||||||
actions.addTo(win, REALM_PLAN+":"+id());
|
|
||||||
return win;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Select selector(Contact preselect) {
|
public static Select selector(Contact preselect) {
|
||||||
|
|||||||
@@ -127,9 +127,8 @@ public class Relay extends Tile implements Device{
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Form propForm(String id) {
|
public Form propForm(String id) {
|
||||||
Form form = super.propForm(id);
|
Form form = new Form(id);
|
||||||
Fieldset fieldset = new Fieldset(t("Decoder settings"));
|
Fieldset fieldset = new Fieldset(t("Decoder settings"));
|
||||||
Label protocol = new Label(t("Protocol:"));
|
Label protocol = new Label(t("Protocol:"));
|
||||||
for (Protocol proto : Protocol.values()) {
|
for (Protocol proto : Protocol.values()) {
|
||||||
|
|||||||
@@ -34,9 +34,8 @@ public abstract class StretchableTile extends Tile {
|
|||||||
return super.load(json);
|
return super.load(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Form propForm(String id) {
|
public Form propForm(String id) {
|
||||||
Form form = super.propForm(id);
|
Form form = new Form(id);
|
||||||
new Tag("h4").content(stretchType()).addTo(form);
|
new Tag("h4").content(stretchType()).addTo(form);
|
||||||
|
|
||||||
new Input(STRETCH_LENGTH, stretch).numeric().addTo(new Label(stretchType()+":"+NBSP)).addTo(new Tag("p")).addTo(form);
|
new Input(STRETCH_LENGTH, stretch).numeric().addTo(new Label(stretchType()+":"+NBSP)).addTo(new Tag("p")).addTo(form);
|
||||||
|
|||||||
@@ -27,11 +27,9 @@ import de.srsoftware.web4rail.Plan.Direction;
|
|||||||
import de.srsoftware.web4rail.Route;
|
import de.srsoftware.web4rail.Route;
|
||||||
import de.srsoftware.web4rail.Window;
|
import de.srsoftware.web4rail.Window;
|
||||||
import de.srsoftware.web4rail.moving.Train;
|
import de.srsoftware.web4rail.moving.Train;
|
||||||
import de.srsoftware.web4rail.tags.Button;
|
|
||||||
import de.srsoftware.web4rail.tags.Checkbox;
|
import de.srsoftware.web4rail.tags.Checkbox;
|
||||||
import de.srsoftware.web4rail.tags.Form;
|
import de.srsoftware.web4rail.tags.Fieldset;
|
||||||
import de.srsoftware.web4rail.tags.Input;
|
import de.srsoftware.web4rail.tags.Input;
|
||||||
import de.srsoftware.web4rail.tags.Label;
|
|
||||||
import de.srsoftware.web4rail.tags.Radio;
|
import de.srsoftware.web4rail.tags.Radio;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -84,7 +82,7 @@ public abstract class Tile extends BaseClass{
|
|||||||
|
|
||||||
public Object click() throws IOException {
|
public Object click() throws IOException {
|
||||||
LOG.debug("{}.click()",getClass().getSimpleName());
|
LOG.debug("{}.click()",getClass().getSimpleName());
|
||||||
return propMenu();
|
return properties();
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject config() {
|
public JSONObject config() {
|
||||||
@@ -194,73 +192,58 @@ public abstract class Tile extends BaseClass{
|
|||||||
return new Vector<Plan.Direction>();
|
return new Vector<Plan.Direction>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Form propForm(String formId) {
|
@Override
|
||||||
Form form = new Form(formId);
|
protected Window properties(List<Fieldset> preForm, FormInput formInputs, List<Fieldset> postForm) {
|
||||||
new Input(ACTION, ACTION_UPDATE).hideIn(form);
|
Fieldset fieldset = new Fieldset(t("Route and Train"));
|
||||||
new Input(REALM, REALM_PLAN).hideIn(form);
|
|
||||||
new Input(ID,id()).hideIn(form);
|
|
||||||
|
|
||||||
List<Direction> pd = possibleDirections();
|
|
||||||
if (!pd.isEmpty()) {
|
|
||||||
new Tag("h4").content(t("One way:")).addTo(form);
|
|
||||||
new Radio("oneway","none",t("No"),isNull(oneWay)).addTo(form);
|
|
||||||
for (Direction d:pd) {
|
|
||||||
new Radio("oneway",d.toString(),t(d.toString()),d == oneWay).addTo(form);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return form;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Window propMenu() {
|
|
||||||
Window window = new Window("tile-properties",t("Properties of {} @ ({},{})",title(),x,y));
|
|
||||||
|
|
||||||
if (isSet(train)) {
|
if (isSet(train)) {
|
||||||
HashMap<String, Object> props = new HashMap<String,Object>(Map.of(REALM,REALM_TRAIN,ID,train.id()));
|
train.link("span", train+NBSP).addTo(fieldset);
|
||||||
if (isSet(train.route)) {
|
if (isSet(train.route)) {
|
||||||
props.put(ACTION, ACTION_STOP);
|
train.button(t("stop"), contextAction(ACTION_STOP)).addTo(fieldset);
|
||||||
window.children().insertElementAt(new Button(t("stop"),props), 1);
|
|
||||||
} else {
|
} else {
|
||||||
props.put(ACTION, ACTION_START);
|
train.button(t("start"), contextAction(ACTION_START)).addTo(fieldset);
|
||||||
window.children().insertElementAt(new Button(t("start"),props), 1);
|
|
||||||
}
|
}
|
||||||
if (train.usesAutopilot()) {
|
if (train.usesAutopilot()) {
|
||||||
props.put(ACTION, ACTION_QUIT);
|
train.button(t("quit autopilot"), contextAction(ACTION_QUIT)).addTo(fieldset);
|
||||||
window.children().insertElementAt(new Button(t("quit autopilot"),props),2);
|
|
||||||
} else {
|
} else {
|
||||||
props.put(ACTION, ACTION_AUTO);
|
train.button(t("auto"), contextAction(ACTION_AUTO)).addTo(fieldset);
|
||||||
window.children().insertElementAt(new Button(t("auto"),props),2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
window.children().insertElementAt(train.link(), 1);
|
|
||||||
window.children().insertElementAt(new Tag("h4").content(t("Train:")), 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSet(route)) route.link("p",t("Locked by {}",route)).addTo(window);
|
|
||||||
|
|
||||||
Form form = propForm("tile-properties-"+id());
|
|
||||||
if (isTrack) {
|
|
||||||
new Tag("h4").content(t("Length")).addTo(form);
|
|
||||||
new Input(LENGTH,length).numeric().addTo(new Label(t("Length")+":"+NBSP)).content(NBSP+lengthUnit).addTo(form);
|
|
||||||
new Tag("h4").content(t("Availability")).addTo(form);
|
|
||||||
Checkbox cb = new Checkbox(DISABLED, t("disabled"), disabled);
|
|
||||||
if (disabled) cb.clazz("disabled");
|
|
||||||
cb.addTo(form);
|
|
||||||
}
|
|
||||||
new Button(t("Apply"),form).addTo(form);
|
|
||||||
form.addTo(window);
|
|
||||||
|
|
||||||
|
if (isSet(route)) {
|
||||||
|
route.link("span",t("Locked by {}",route)).addTo(fieldset);
|
||||||
|
}
|
||||||
|
preForm.add(fieldset);
|
||||||
|
|
||||||
|
if (isTrack) {
|
||||||
|
formInputs.add(t("Length"),new Input(LENGTH,length).numeric().addTo(new Tag("span")).content(NBSP+lengthUnit));
|
||||||
|
formInputs.add(t("State"),new Checkbox(DISABLED, t("disabled"), disabled));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Direction> pd = possibleDirections();
|
||||||
|
if (!pd.isEmpty()) {
|
||||||
|
Tag div = new Tag("div");
|
||||||
|
new Radio("oneway","none",t("No"),isNull(oneWay)).addTo(div);
|
||||||
|
for (Direction d:pd) {
|
||||||
|
new Radio("oneway",d.toString(),t(d.toString()),d == oneWay).addTo(div);
|
||||||
|
}
|
||||||
|
formInputs.add(t("One way"),div);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!routes.isEmpty()) {
|
if (!routes.isEmpty()) {
|
||||||
new Tag("h4").content(t("Routes using this tile:")).addTo(window);
|
fieldset = new Fieldset(t("Routes using this tile"));
|
||||||
Tag routeList = new Tag("ol");
|
Tag routeList = new Tag("ol");
|
||||||
for (Route route : routes) {
|
for (Route route : routes) {
|
||||||
Tag li = route.link("span", route.name()+(route.isDisabled()?" ["+t("disabled")+"]" : "")+NBSP).addTo(new Tag("li").clazz("link"));
|
Tag li = route.link("span", route.name()+(route.isDisabled()?" ["+t("disabled")+"]" : "")+NBSP).addTo(new Tag("li").clazz("link"));
|
||||||
route.button(t("delete route"),contextAction(ACTION_DROP)).addTo(li);
|
route.button(t("delete route"),contextAction(ACTION_DROP)).addTo(li);
|
||||||
li.addTo(routeList);
|
li.addTo(routeList);
|
||||||
}
|
}
|
||||||
routeList.addTo(window);
|
routeList.addTo(fieldset);
|
||||||
}
|
postForm.add(fieldset);
|
||||||
return window;
|
}
|
||||||
|
|
||||||
|
return super.properties(preForm, formInputs, postForm);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove(Route route) {
|
public void remove(Route route) {
|
||||||
@@ -268,7 +251,7 @@ public abstract class Tile extends BaseClass{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String replace(String line, Entry<String, Object> replacement) {
|
private static String replace(String line, Entry<String, Object> replacement) {
|
||||||
String key = replacement.getKey();
|
String key = replacement.getKey();
|
||||||
Object val = replacement.getValue();
|
Object val = replacement.getValue();
|
||||||
int start = line.indexOf(key);
|
int start = line.indexOf(key);
|
||||||
int len = key.length();
|
int len = key.length();
|
||||||
|
|||||||
@@ -112,9 +112,8 @@ public abstract class Turnout extends Tile implements Device{
|
|||||||
return super.load(json);
|
return super.load(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Form propForm(String id) {
|
public Form propForm(String id) {
|
||||||
Form form = super.propForm(id);
|
Form form = new Form(id);
|
||||||
Fieldset fieldset = new Fieldset(t("Decoder settings"));
|
Fieldset fieldset = new Fieldset(t("Decoder settings"));
|
||||||
Label protocol = new Label(t("Protocol:"));
|
Label protocol = new Label(t("Protocol:"));
|
||||||
for (Protocol proto : Protocol.values()) {
|
for (Protocol proto : Protocol.values()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user