working on route properties
This commit is contained in:
@@ -2,21 +2,17 @@ package de.srsoftware.web4rail.tiles;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import de.srsoftware.tools.Tag;
|
||||
import de.srsoftware.web4rail.Connector;
|
||||
import de.srsoftware.web4rail.Route;
|
||||
|
||||
public abstract class Block extends StretchableTile{
|
||||
private static final String NAME = "name";
|
||||
public String name = "Block";
|
||||
private HashSet<Route> routes = new HashSet<Route>();
|
||||
|
||||
@Override
|
||||
public JSONObject config() {
|
||||
@@ -31,16 +27,8 @@ public abstract class Block extends StretchableTile{
|
||||
if (config.has(NAME)) name = config.getString(NAME);
|
||||
}
|
||||
|
||||
public Set<Route> routes(){
|
||||
return routes;
|
||||
}
|
||||
|
||||
public abstract List<Connector> startPoints();
|
||||
|
||||
public void add(Route route) {
|
||||
routes.add(route);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tag propForm() {
|
||||
Tag form = super.propForm();
|
||||
@@ -49,13 +37,6 @@ public abstract class Block extends StretchableTile{
|
||||
new Tag("input").attr("type", "text").attr(NAME,"name").attr("value", name).addTo(label);
|
||||
label.addTo(form);
|
||||
|
||||
new Tag("h4").content(t("Routes from here:")).addTo(form);
|
||||
Tag routeList = new Tag("ul");
|
||||
for (Route route : routes) {
|
||||
new Tag("li").content(route.id()).attr("onclick","openRoute('"+route.id()+"')").addTo(routeList);
|
||||
}
|
||||
routeList.addTo(form);
|
||||
|
||||
return form;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import java.util.Map.Entry;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import de.srsoftware.tools.Tag;
|
||||
import de.srsoftware.web4rail.tags.Form;
|
||||
|
||||
public abstract class StretchableTile extends Tile {
|
||||
private static final String LENGTH = "length";
|
||||
@@ -27,10 +26,7 @@ public abstract class StretchableTile extends Tile {
|
||||
|
||||
@Override
|
||||
public Tag propForm() {
|
||||
Form form = new Form();
|
||||
new Tag("input").attr("type", "hidden").attr("name","action").attr("value", "update").addTo(form);
|
||||
new Tag("input").attr("type", "hidden").attr("name","x").attr("value", x).addTo(form);
|
||||
new Tag("input").attr("type", "hidden").attr("name","y").attr("value", y).addTo(form);
|
||||
Tag form = super.propForm();
|
||||
|
||||
Tag label = new Tag("label").content(t("length:"));
|
||||
new Tag("input").attr("type", "number").attr("name","length").attr("value", length).addTo(label);
|
||||
|
||||
@@ -5,11 +5,9 @@ import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Scanner;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
@@ -19,14 +17,18 @@ import de.keawe.tools.translations.Translation;
|
||||
import de.srsoftware.tools.Tag;
|
||||
import de.srsoftware.web4rail.Application;
|
||||
import de.srsoftware.web4rail.Connector;
|
||||
import de.srsoftware.web4rail.Window;
|
||||
import de.srsoftware.web4rail.Plan.Direction;
|
||||
import de.srsoftware.web4rail.tags.Form;
|
||||
import de.srsoftware.web4rail.Route;
|
||||
import de.srsoftware.web4rail.Window;
|
||||
|
||||
public abstract class Tile {
|
||||
|
||||
public int x = -1,y = -1;
|
||||
protected HashSet<String> classes = new HashSet<String>();
|
||||
protected HashSet<Shadow> shadows = new HashSet<Shadow>();
|
||||
protected HashSet<String> classes = new HashSet<>();
|
||||
protected HashSet<Shadow> shadows = new HashSet<>();
|
||||
private HashSet<Route> routes = new HashSet<>();
|
||||
|
||||
protected static Logger LOG = LoggerFactory.getLogger(Tile.class);
|
||||
|
||||
public Tile() {
|
||||
@@ -64,7 +66,21 @@ public abstract class Tile {
|
||||
}
|
||||
|
||||
public Tag propForm() {
|
||||
return null;
|
||||
Form form = new Form();
|
||||
new Tag("input").attr("type", "hidden").attr("name","action").attr("value", "update").addTo(form);
|
||||
new Tag("input").attr("type", "hidden").attr("name","x").attr("value", x).addTo(form);
|
||||
new Tag("input").attr("type", "hidden").attr("name","y").attr("value", y).addTo(form);
|
||||
|
||||
if (!routes.isEmpty()) {
|
||||
new Tag("h4").content(t("Routes using this tile:")).addTo(form);
|
||||
Tag routeList = new Tag("ul");
|
||||
for (Route route : routes) {
|
||||
new Tag("li").clazz("link").attr("onclick","openRoute('"+route.id()+"')").content(route.id()).addTo(routeList);
|
||||
}
|
||||
routeList.addTo(form);
|
||||
}
|
||||
|
||||
return form;
|
||||
}
|
||||
|
||||
public Tag propMenu() {
|
||||
@@ -153,5 +169,13 @@ public abstract class Tile {
|
||||
public Tile update(HashMap<String, String> params) {
|
||||
LOG.debug("{}.update({})",getClass().getSimpleName(),params);
|
||||
return this;
|
||||
}
|
||||
|
||||
public HashSet<Route> routes() {
|
||||
return routes;
|
||||
}
|
||||
|
||||
public void add(Route route) {
|
||||
this.routes.add(route);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user