working on now property dialogs
This commit is contained in:
@@ -227,9 +227,8 @@ public abstract class Block extends StretchableTile implements Comparable<Block>
|
||||
return form;
|
||||
}
|
||||
|
||||
@Override
|
||||
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");
|
||||
new Tag("h4").content(t("Stop settings")).addTo(win);
|
||||
new Input(REALM,REALM_PLAN).hideIn(form);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.srsoftware.web4rail.tiles;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.json.JSONObject;
|
||||
@@ -10,6 +11,7 @@ import de.srsoftware.web4rail.Connector;
|
||||
import de.srsoftware.web4rail.Route;
|
||||
import de.srsoftware.web4rail.Window;
|
||||
import de.srsoftware.web4rail.moving.Train;
|
||||
import de.srsoftware.web4rail.tags.Fieldset;
|
||||
|
||||
public abstract class Bridge extends Tile {
|
||||
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);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@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() {
|
||||
Window win = super.propMenu();
|
||||
Window win = new Window("test", "test");
|
||||
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);
|
||||
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.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.TreeMap;
|
||||
@@ -12,9 +13,8 @@ import org.json.JSONObject;
|
||||
import de.srsoftware.tools.Tag;
|
||||
import de.srsoftware.web4rail.Window;
|
||||
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.Label;
|
||||
import de.srsoftware.web4rail.tags.Select;
|
||||
|
||||
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());
|
||||
contact = contactsById.get(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);
|
||||
plan.learn(contact);
|
||||
return propMenu;
|
||||
@@ -148,22 +148,15 @@ public class Contact extends Tile{
|
||||
return t("Unknown action: {}",action);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Form propForm(String formId) {
|
||||
Form form = super.propForm(formId);
|
||||
new Tag("h4").content(t("Hardware settings")).addTo(form);
|
||||
Tag label = new Input(ADDRESS, addr).numeric().addTo(new Label(t("Address:")+NBSP));
|
||||
button(t("learn"),Map.of(ACTION,ACTION_ANALYZE)).addTo(label).addTo(form);
|
||||
return form;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Window propMenu() {
|
||||
Window win = super.propMenu();
|
||||
new Tag("h4").content(t("Actions")).addTo(win);
|
||||
actions.addTo(win, REALM_PLAN+":"+id());
|
||||
return win;
|
||||
protected Window properties(List<Fieldset> preForm, FormInput formInputs, List<Fieldset> postForm) {
|
||||
Tag span = new Tag("span");
|
||||
new Input(ADDRESS, addr).numeric().addTo(span).content(NBSP);
|
||||
button(t("learn"),Map.of(ACTION,ACTION_ANALYZE)).addTo(span);
|
||||
formInputs.add(t("Hardware settings"),span);
|
||||
|
||||
postForm.add(actions.properties());
|
||||
return super.properties(preForm, formInputs, postForm);
|
||||
}
|
||||
|
||||
public static Select selector(Contact preselect) {
|
||||
|
||||
@@ -127,9 +127,8 @@ public class Relay extends Tile implements Device{
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Form propForm(String id) {
|
||||
Form form = super.propForm(id);
|
||||
Form form = new Form(id);
|
||||
Fieldset fieldset = new Fieldset(t("Decoder settings"));
|
||||
Label protocol = new Label(t("Protocol:"));
|
||||
for (Protocol proto : Protocol.values()) {
|
||||
|
||||
@@ -34,9 +34,8 @@ public abstract class StretchableTile extends Tile {
|
||||
return super.load(json);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Form propForm(String id) {
|
||||
Form form = super.propForm(id);
|
||||
Form form = new Form(id);
|
||||
new Tag("h4").content(stretchType()).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.Window;
|
||||
import de.srsoftware.web4rail.moving.Train;
|
||||
import de.srsoftware.web4rail.tags.Button;
|
||||
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.Label;
|
||||
import de.srsoftware.web4rail.tags.Radio;
|
||||
|
||||
/**
|
||||
@@ -84,7 +82,7 @@ public abstract class Tile extends BaseClass{
|
||||
|
||||
public Object click() throws IOException {
|
||||
LOG.debug("{}.click()",getClass().getSimpleName());
|
||||
return propMenu();
|
||||
return properties();
|
||||
}
|
||||
|
||||
public JSONObject config() {
|
||||
@@ -194,73 +192,58 @@ public abstract class Tile extends BaseClass{
|
||||
return new Vector<Plan.Direction>();
|
||||
}
|
||||
|
||||
public Form propForm(String formId) {
|
||||
Form form = new Form(formId);
|
||||
new Input(ACTION, ACTION_UPDATE).hideIn(form);
|
||||
new Input(REALM, REALM_PLAN).hideIn(form);
|
||||
new Input(ID,id()).hideIn(form);
|
||||
@Override
|
||||
protected Window properties(List<Fieldset> preForm, FormInput formInputs, List<Fieldset> postForm) {
|
||||
Fieldset fieldset = new Fieldset(t("Route and Train"));
|
||||
|
||||
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)) {
|
||||
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)) {
|
||||
props.put(ACTION, ACTION_STOP);
|
||||
window.children().insertElementAt(new Button(t("stop"),props), 1);
|
||||
train.button(t("stop"), contextAction(ACTION_STOP)).addTo(fieldset);
|
||||
} else {
|
||||
props.put(ACTION, ACTION_START);
|
||||
window.children().insertElementAt(new Button(t("start"),props), 1);
|
||||
train.button(t("start"), contextAction(ACTION_START)).addTo(fieldset);
|
||||
}
|
||||
if (train.usesAutopilot()) {
|
||||
props.put(ACTION, ACTION_QUIT);
|
||||
window.children().insertElementAt(new Button(t("quit autopilot"),props),2);
|
||||
train.button(t("quit autopilot"), contextAction(ACTION_QUIT)).addTo(fieldset);
|
||||
} else {
|
||||
props.put(ACTION, ACTION_AUTO);
|
||||
window.children().insertElementAt(new Button(t("auto"),props),2);
|
||||
train.button(t("auto"), contextAction(ACTION_AUTO)).addTo(fieldset);
|
||||
}
|
||||
|
||||
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()) {
|
||||
new Tag("h4").content(t("Routes using this tile:")).addTo(window);
|
||||
fieldset = new Fieldset(t("Routes using this tile"));
|
||||
Tag routeList = new Tag("ol");
|
||||
for (Route route : routes) {
|
||||
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);
|
||||
li.addTo(routeList);
|
||||
}
|
||||
routeList.addTo(window);
|
||||
}
|
||||
return window;
|
||||
routeList.addTo(fieldset);
|
||||
postForm.add(fieldset);
|
||||
}
|
||||
|
||||
return super.properties(preForm, formInputs, postForm);
|
||||
}
|
||||
|
||||
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) {
|
||||
String key = replacement.getKey();
|
||||
String key = replacement.getKey();
|
||||
Object val = replacement.getValue();
|
||||
int start = line.indexOf(key);
|
||||
int len = key.length();
|
||||
|
||||
@@ -112,9 +112,8 @@ public abstract class Turnout extends Tile implements Device{
|
||||
return super.load(json);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Form propForm(String id) {
|
||||
Form form = super.propForm(id);
|
||||
Form form = new Form(id);
|
||||
Fieldset fieldset = new Fieldset(t("Decoder settings"));
|
||||
Label protocol = new Label(t("Protocol:"));
|
||||
for (Protocol proto : Protocol.values()) {
|
||||
|
||||
Reference in New Issue
Block a user