implemented highlighting of tiles on action edit

This commit is contained in:
Stephan Richter
2021-05-28 13:18:23 +02:00
parent 029222ffa2
commit 19b1b3ed01
24 changed files with 102 additions and 20 deletions

View File

@@ -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());

View File

@@ -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);

View File

@@ -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();

View File

@@ -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();

View File

@@ -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);

View File

@@ -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();

View File

@@ -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();

View File

@@ -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();

View File

@@ -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();

View File

@@ -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();

View File

@@ -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();