implemented highlighting of tiles on action edit
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>de.srsoftware</groupId>
|
||||
<artifactId>web4rail</artifactId>
|
||||
<version>1.4.31</version>
|
||||
<version>1.4.32</version>
|
||||
<name>Web4Rail</name>
|
||||
<packaging>jar</packaging>
|
||||
<description>Java Model Railway Control</description>
|
||||
|
||||
@@ -538,3 +538,8 @@ input[type=range]:focus::-ms-fill-lower {
|
||||
input[type=range]:focus::-ms-fill-upper {
|
||||
background: #3071A9;
|
||||
}
|
||||
|
||||
.highlight{
|
||||
margin: -6px;
|
||||
border: 6px solid purple;
|
||||
}
|
||||
@@ -197,6 +197,14 @@ function heartbeat(data){
|
||||
return false;
|
||||
}
|
||||
|
||||
function highlight(id,enable = true){
|
||||
if (enable) {
|
||||
$('#'+id).addClass('highlight');
|
||||
} else {
|
||||
$('#'+id).removeClass('highlight');
|
||||
}
|
||||
}
|
||||
|
||||
function keypress(ev){
|
||||
if (ev.code === 'Escape') return request({realm:"cu",action:"emergency"});
|
||||
if (ev.code === 'Enter') {
|
||||
|
||||
@@ -445,7 +445,7 @@ value : Wert
|
||||
WaitForContact : Auf Kontakt warten
|
||||
Wait for {}, then : auf {} warten, dann
|
||||
Wait {} ms, then : {} ms warten, dann
|
||||
{} waiting {} secs... : {} wartet {} Sekunden...
|
||||
{} waiting {} secs. : {} wartet {} Sekunden.
|
||||
Wait times : Wartezeiten
|
||||
Was not able to assign {} to {}! : Konnte {} nicht an {} zuweisen!
|
||||
Was not able to lock {} : Konnte {} nicht reservieren
|
||||
|
||||
@@ -403,18 +403,29 @@ public abstract class BaseClass implements Constants{
|
||||
}
|
||||
|
||||
public Tag link(String tagClass,Object caption) {
|
||||
return link(tagClass,caption,null);
|
||||
String highlightId = (caption instanceof BaseClass) ? ((BaseClass)caption).id().toString() : null;
|
||||
return link(tagClass,caption,highlightId);
|
||||
}
|
||||
|
||||
public Tag link(String tagClass,Object caption,Map<String,String> additionalProps) {
|
||||
public Tag link(String tagClass,Object caption, String highlightId) {
|
||||
return link(tagClass,caption,null,highlightId);
|
||||
}
|
||||
|
||||
|
||||
public Tag link(String tagClass,Object caption,Map<String,String> additionalProps,String highlightId) {
|
||||
Tag link = link(tagClass,caption.toString(),props(additionalProps));
|
||||
if (isSet(highlightId)) link.attr("onmouseover", "highlight('"+highlightId+"',true);").attr("onmouseout", "highlight('"+highlightId+"',false);");
|
||||
|
||||
if (isSet(notes) && !notes.isEmpty()) link.title(notes);
|
||||
return link;
|
||||
}
|
||||
|
||||
public static Tag link(String tagClass,String caption,Map<String,String> props) {
|
||||
String json = new JSONObject(props).toString().replace("\"", "'");
|
||||
return new Tag(tagClass).clazz("link").attr("onclick","request("+json+")").content(caption.toString());
|
||||
return new Tag(tagClass)
|
||||
.clazz("link")
|
||||
.attr("onclick","request("+json+");")
|
||||
.content(caption.toString());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@@ -330,7 +330,7 @@ public class Route extends BaseClass {
|
||||
if (isNull(actions)) return context;
|
||||
actions.fire(context,"Route.Contact("+contact.addr()+")");
|
||||
Context previousContext = context;
|
||||
if (context.invalidated()) context = null; // route has been freed in between.
|
||||
if (isSet(context) && context.invalidated()) context = null; // route has been freed in between.
|
||||
return previousContext;
|
||||
}
|
||||
|
||||
@@ -358,12 +358,12 @@ public class Route extends BaseClass {
|
||||
}
|
||||
startActions.listAt(start).addTo(list);
|
||||
|
||||
for (Contact c : contacts) {
|
||||
Tag item = c.link("span", c).addTo(new Tag("li")).content(NBSP);
|
||||
ActionList actions = triggeredActions.get(c.trigger());
|
||||
for (Contact contact : contacts) {
|
||||
Tag item = contact.link("span", contact).addTo(new Tag("li")).content(NBSP);
|
||||
ActionList actions = triggeredActions.get(contact.trigger());
|
||||
if (isNull(actions)) {
|
||||
actions = new ActionList(this);
|
||||
triggeredActions.put(c.trigger(), actions);
|
||||
triggeredActions.put(contact.trigger(), actions);
|
||||
}
|
||||
actions.listAt(item).addTo(list);
|
||||
}
|
||||
|
||||
@@ -98,6 +98,10 @@ public abstract class Action extends BaseClass {
|
||||
public static Action get(Id actionId) {
|
||||
return actions.get(actionId);
|
||||
}
|
||||
|
||||
protected String highlightId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public JSONObject json() {
|
||||
return new JSONObject().put(TYPE, getClass().getSimpleName());
|
||||
|
||||
@@ -129,7 +129,7 @@ public class ActionList extends Action implements Iterable<Action>{
|
||||
if (!isEmpty()) {
|
||||
Tag list = new Tag("ol");
|
||||
for (Action action : actions) {
|
||||
Tag item = action.link("span",action).addTo(new Tag("li")).content(NBSP);
|
||||
Tag item = action.link("span",action, action.highlightId()).addTo(new Tag("li")).content(NBSP);
|
||||
action.button("↑", Map.of(ACTION,ACTION_MOVE)).title(t("move up")).addTo(item);
|
||||
action.button("-", Map.of(ACTION,ACTION_DROP)).title(t("delete")).addTo(item);
|
||||
if (action instanceof ActionList) ((ActionList) action).listAt(item);
|
||||
|
||||
@@ -56,6 +56,12 @@ public class AddRemoveDestination extends Action {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String highlightId() {
|
||||
return isSet(destination) ? destination.id().toString() : null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public JSONObject json() {
|
||||
JSONObject json = super.json();
|
||||
|
||||
@@ -34,6 +34,11 @@ public class DetermineTrainInBlock extends Action {
|
||||
return (isSet(train));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String highlightId() {
|
||||
return isSet(block) ? block.id().toString() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject json() {
|
||||
JSONObject json = super.json();
|
||||
|
||||
@@ -41,6 +41,12 @@ public class DisableEnableBlock extends Action {
|
||||
return json;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String highlightId() {
|
||||
return isSet(block) ? block.id().toString() : null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Action load(JSONObject json) {
|
||||
if (json.has(STATE)) disable = !json.getBoolean(STATE);
|
||||
|
||||
@@ -29,6 +29,12 @@ public class SetDisplayText extends TextAction{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String highlightId() {
|
||||
return isSet(display) ? display.id().toString() : null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public JSONObject json() {
|
||||
JSONObject json = super.json();
|
||||
|
||||
@@ -35,6 +35,12 @@ public class SetRelayOrSwitch extends Action {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String highlightId() {
|
||||
return isSet(relayOrSwitch) ? relayOrSwitch.id().toString() : null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public JSONObject json() {
|
||||
JSONObject json = super.json();
|
||||
|
||||
@@ -40,6 +40,11 @@ public class SetSignal extends Action {
|
||||
return signal.state(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String highlightId() {
|
||||
return isSet(signal) ? signal.id().toString() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject json() {
|
||||
JSONObject json = super.json();
|
||||
|
||||
@@ -34,6 +34,11 @@ public class SetTurnout extends Action {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String highlightId() {
|
||||
return isSet(turnout) ? turnout.id().toString() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject json() {
|
||||
JSONObject json = super.json();
|
||||
|
||||
@@ -25,6 +25,12 @@ public class TriggerContact extends Action {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String highlightId() {
|
||||
return isSet(contact) ? contact.id().toString() : null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public JSONObject json() {
|
||||
JSONObject json = super.json();
|
||||
|
||||
@@ -57,6 +57,12 @@ public class WaitForContact extends ActionList {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String highlightId() {
|
||||
return isSet(contact) ? contact.id().toString() : null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public JSONObject json() {
|
||||
JSONObject json = super.json();
|
||||
|
||||
@@ -79,7 +79,7 @@ public class ConditionList extends Condition implements Iterable<Condition>{
|
||||
Tag list = new Tag("ul");
|
||||
for (Condition condition : conditions) {
|
||||
Tag item = new Tag("li");
|
||||
condition.link("span", condition).addTo(item);
|
||||
condition.link("span", condition, null).addTo(item);
|
||||
condition.button(t("delete"), Map.of(ACTION,ACTION_DROP)).addTo(item.content(NBSP)).addTo(list);
|
||||
if (condition instanceof ConditionList) {
|
||||
((ConditionList)condition).listInternal().addTo(item);
|
||||
|
||||
@@ -274,7 +274,7 @@ public class Car extends BaseClass implements Comparable<Car>{
|
||||
car.link(),
|
||||
maxSpeed+speedUnit,
|
||||
car.length+NBSP+lengthUnit,
|
||||
isSet(car.train) ? car.train.link("span", car.train) : "",
|
||||
isSet(car.train) ? car.train.link("span", car.train, null) : "",
|
||||
String.join(", ", car.tags()),
|
||||
car.distanceCounter,
|
||||
actions
|
||||
|
||||
@@ -435,7 +435,7 @@ public class Locomotive extends Car implements Constants,Device{
|
||||
if (speed < 0) speed = 0;
|
||||
|
||||
queue();
|
||||
plan.stream(t("Speed of {} set to {} {}.",this,speed,BaseClass.speedUnit));
|
||||
//plan.stream(t("Speed of {} set to {} {}.",this,speed,BaseClass.speedUnit));
|
||||
return properties();
|
||||
|
||||
}
|
||||
|
||||
@@ -770,7 +770,7 @@ public class Train extends BaseClass implements Comparable<Train> {
|
||||
|
||||
Tag dest = new Tag("li").content(t("Destination")+COL);
|
||||
if (isSet(destination)) {
|
||||
link("span",destination,Map.of(REALM,REALM_PLAN,ID,destination.id().toString(),ACTION,ACTION_CLICK)).addTo(dest);
|
||||
link("span",destination,Map.of(REALM,REALM_PLAN,ID,destination.id().toString(),ACTION,ACTION_CLICK),null).addTo(dest);
|
||||
new Button(t("Drop"),Map.of(REALM,REALM_TRAIN,ID,id,ACTION,ACTION_MOVE,DESTINATION,"")).addTo(dest);
|
||||
}
|
||||
button(t("Select from plan"),Map.of(ACTION,ACTION_MOVE,ASSIGN,DESTINATION)).addTo(dest);
|
||||
@@ -812,7 +812,10 @@ public class Train extends BaseClass implements Comparable<Train> {
|
||||
}
|
||||
|
||||
public String quitAutopilot() {
|
||||
if (isSet(routePrepper)) routePrepper.stop();
|
||||
if (isSet(routePrepper)) {
|
||||
routePrepper.stop();
|
||||
routePrepper = null;
|
||||
}
|
||||
if (autopilot) {
|
||||
autopilot = false;
|
||||
if (isSet(currentBlock)) plan.place(currentBlock);
|
||||
|
||||
@@ -227,7 +227,7 @@ public abstract class Block extends StretchableTile{
|
||||
if (!internalContacts.isEmpty()) {
|
||||
Tag ul = new Tag("ul");
|
||||
for (BlockContact contact : internalContacts) {
|
||||
Tag li = contact.link("span", contact).content(NBSP).addTo(new Tag("li"));
|
||||
Tag li = contact.link("span", contact, contact.id().toString()).content(NBSP).addTo(new Tag("li"));
|
||||
contact.button(t("learn"),Map.of(ACTION,ACTION_ANALYZE)).addTo(li);
|
||||
contact.button(t("delete"),Map.of(ACTION,ACTION_DROP)).addTo(li);
|
||||
li.addTo(ul);
|
||||
@@ -490,7 +490,7 @@ public abstract class Block extends StretchableTile{
|
||||
Fieldset fieldset = new Fieldset(t("Trains"));
|
||||
Tag list = new Tag("ul");
|
||||
for (Train t : parkedTrains) {
|
||||
if (isSet(t)) t.link("li", t).addTo(list);
|
||||
if (isSet(t)) t.link("li", t, null).addTo(list);
|
||||
}
|
||||
list.addTo(fieldset);
|
||||
return fieldset;
|
||||
|
||||
@@ -139,7 +139,7 @@ public abstract class Signal extends Tile {
|
||||
for (String aspect : knownStates) {
|
||||
HashSet<int[]> commands = aspects.get(aspect);
|
||||
if (isSet(commands)) {
|
||||
Tag link = this.link("span", (Object)aspect, Map.of(ACTION,ACTION_POWER,STATE,aspect));
|
||||
Tag link = this.link("span", (Object)aspect, Map.of(ACTION,ACTION_POWER,STATE,aspect),null);
|
||||
for (int[] command : aspects.get(aspect)) {
|
||||
Button delete = this.button(t("delete"), Map.of(ACTION,ACTION_UPDATE,ACTION_DROP+"-"+aspect,command[0]+"-"+command[1]+"-"+command[2]));
|
||||
table.addRow(link,command[0],command[1],command[2],command[3]==1?"✓":"",delete);
|
||||
|
||||
@@ -199,7 +199,7 @@ public abstract class Tile extends BaseClass implements Comparable<Tile> {
|
||||
public Tag link(String... args) {
|
||||
String tx = args.length < 1 ? id() + NBSP : args[0];
|
||||
String type = args.length < 2 ? "span" : args[1];
|
||||
return super.link(type, (Object) tx, Map.of(ACTION, ACTION_CLICK));
|
||||
return super.link(type, (Object) tx, Map.of(ACTION, ACTION_CLICK),this.id().toString());
|
||||
}
|
||||
|
||||
public static void load(Object object, Plan plan) {
|
||||
|
||||
Reference in New Issue
Block a user