|
|
@ -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); |
|
|
|
if (isSet(route)) { |
|
|
|
|
|
|
|
route.link("span",t("Locked by {}",route)).addTo(fieldset); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
preForm.add(fieldset); |
|
|
|
|
|
|
|
|
|
|
|
Form form = propForm("tile-properties-"+id()); |
|
|
|
|
|
|
|
if (isTrack) { |
|
|
|
if (isTrack) { |
|
|
|
new Tag("h4").content(t("Length")).addTo(form); |
|
|
|
formInputs.add(t("Length"),new Input(LENGTH,length).numeric().addTo(new Tag("span")).content(NBSP+lengthUnit)); |
|
|
|
new Input(LENGTH,length).numeric().addTo(new Label(t("Length")+":"+NBSP)).content(NBSP+lengthUnit).addTo(form); |
|
|
|
formInputs.add(t("State"),new Checkbox(DISABLED, t("disabled"), disabled)); |
|
|
|
new Tag("h4").content(t("Availability")).addTo(form); |
|
|
|
} |
|
|
|
Checkbox cb = new Checkbox(DISABLED, t("disabled"), disabled); |
|
|
|
|
|
|
|
if (disabled) cb.clazz("disabled"); |
|
|
|
List<Direction> pd = possibleDirections(); |
|
|
|
cb.addTo(form); |
|
|
|
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); |
|
|
|
} |
|
|
|
} |
|
|
|
new Button(t("Apply"),form).addTo(form); |
|
|
|
|
|
|
|
form.addTo(window); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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) { |
|
|
|