bugfixes, added new Condition AutopilotActive, extended StopAutopilot action to StartStopAutopilot, implemented ActionList export
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.2.23</version>
|
||||
<version>1.2.24</version>
|
||||
<name>Web4Rail</name>
|
||||
<packaging>jar</packaging>
|
||||
<description>Java Model Railway Control</description>
|
||||
|
||||
@@ -20,6 +20,9 @@ Analyze : analysieren
|
||||
and : und
|
||||
Apply : Übernehmen
|
||||
Auto pilot : Autopilot
|
||||
AutopilotActive : Autopilot aktiv
|
||||
autopilot active for train : Autopilot für Zug aktiviert
|
||||
autopilot inactive for train : Autopilot nicht aktiv für Zug
|
||||
Availability : Verfügbarkeit
|
||||
Back : zurück
|
||||
Basic properties : Grundlegende Eigenschaften
|
||||
@@ -80,6 +83,7 @@ EAST : Osten
|
||||
Editable properties : veränderliche Eigenschaften
|
||||
editable train properties : veränderliche Zug-Eigenschaften
|
||||
Emergency : Notfall
|
||||
export : exportieren
|
||||
Faster (10 {}) : 10 {} schneller
|
||||
Firing {} : starte {}
|
||||
FinishRoute : Route abschließen
|
||||
@@ -183,10 +187,12 @@ Speed unit : Geschwindigkeits-Einheit
|
||||
Start actions : Start-Aktionen
|
||||
Stock ID : Inventarnummer
|
||||
Stop settings : Halte-Einstellungen
|
||||
Start autopilot : Autopilot starten
|
||||
Started {} : {} gestartet
|
||||
State : Status
|
||||
StopAllTrains : Alle Züge stoppen
|
||||
StopAuto : Automatikmodus abschalten
|
||||
StartStopAuto : Automatikmodus an/abschalten
|
||||
Stop autopilot : Autopilot abschalten
|
||||
{} stopping at next block. : {} hält im nächsten Block.
|
||||
Stopsettings : Halte-Einstellungen
|
||||
Straight port\: : Port für gerade
|
||||
|
||||
@@ -81,7 +81,7 @@ public abstract class Action extends BaseClass {
|
||||
SetTurnout.class,
|
||||
ShowText.class,
|
||||
StopAllTrains.class,
|
||||
StopAuto.class,
|
||||
StartStopAuto.class,
|
||||
TriggerContact.class,
|
||||
TurnTrain.class
|
||||
);
|
||||
@@ -97,7 +97,7 @@ public abstract class Action extends BaseClass {
|
||||
ActionList actionList = (ActionList) parent;
|
||||
return actionList.moveUp(this);
|
||||
}
|
||||
LOG.error("Action.drop() called on Action ({}) whose parent ({}) is not an ActionList!",this,parent);
|
||||
LOG.error("Action.moveUp() called on Action ({}) whose parent ({}) is not an ActionList!",this,parent);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -116,16 +116,13 @@ public class ActionList extends Action implements Iterable<Action>{
|
||||
public Tag list() {
|
||||
Tag span = new Tag("span");
|
||||
button(t("add action"), Map.of(ACTION, ACTION_ADD)).addTo(span);
|
||||
|
||||
button(t("export"), Map.of(ACTION, ACTION_SAVE)).addTo(span);
|
||||
if (!isEmpty()) {
|
||||
Tag list = new Tag("ol");
|
||||
boolean first = true;
|
||||
for (Action action : actions) {
|
||||
Tag item = action.link("span",action).addTo(new Tag("li")).content(NBSP);
|
||||
action.button("-", Map.of(ACTION,ACTION_DROP)).addTo(item);
|
||||
if (first) {
|
||||
first = false;
|
||||
} else action.button("↑", Map.of(ACTION,ACTION_MOVE)).addTo(item);
|
||||
action.button("↑", Map.of(ACTION,ACTION_MOVE)).addTo(item);
|
||||
if (action instanceof ActionList) ((ActionList) action).list().addTo(item);
|
||||
item.addTo(list);
|
||||
}
|
||||
@@ -151,10 +148,25 @@ public class ActionList extends Action implements Iterable<Action>{
|
||||
}
|
||||
|
||||
public boolean moveUp(Action action) {
|
||||
if (isNull(action)) return false;
|
||||
if (actions.firstElement() == action && parent() instanceof ActionList) {
|
||||
ActionList parentList = (ActionList) parent();
|
||||
for (int i=0; i<parentList.actions.size(); i++) {
|
||||
if (parentList.actions.get(i) == this) {
|
||||
actions.remove(0);
|
||||
parentList.actions.insertElementAt(action, i);
|
||||
action.parent(parentList);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i=1; i<actions.size(); i++) {
|
||||
if (actions.elementAt(i) == action) {
|
||||
actions.remove(i);
|
||||
actions.insertElementAt(action, i-1);
|
||||
Action aboveAction = actions.get(i-1);
|
||||
if (aboveAction instanceof ActionList) {
|
||||
((ActionList)aboveAction).add(action);
|
||||
} else actions.insertElementAt(action, i-1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -180,9 +192,16 @@ public class ActionList extends Action implements Iterable<Action>{
|
||||
action.remove();
|
||||
return context.properties();
|
||||
case ACTION_MOVE:
|
||||
return action.moveUp() ? action.context().properties() : t("No action with id {} found!",actionId);
|
||||
if (isNull(action)) return t("No action with id {} found!",actionId);
|
||||
if (action.moveUp()) return action.context().properties();
|
||||
Window result = action.context().properties();
|
||||
return new Tag("fieldset").content(t("Was not able to move \"{}\" up!",action)).addTo(result);
|
||||
case ACTION_PROPS:
|
||||
return action.properties();
|
||||
case ACTION_SAVE:
|
||||
Window win = new Window("action-export", t("Export of {}",action));
|
||||
new Tag("textarea").content(action.json().toString()).addTo(win);
|
||||
return win;
|
||||
case ACTION_UPDATE:
|
||||
return action.update(params);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package de.srsoftware.web4rail.actions;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import de.srsoftware.web4rail.BaseClass;
|
||||
import de.srsoftware.web4rail.Window;
|
||||
import de.srsoftware.web4rail.tags.Checkbox;
|
||||
import de.srsoftware.web4rail.tags.Fieldset;
|
||||
|
||||
public class StartStopAuto extends Action {
|
||||
|
||||
private static final String INVERTED = "inverted";
|
||||
public boolean inverted = false;
|
||||
|
||||
public StartStopAuto(BaseClass parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context) {
|
||||
if (isNull(context.train())) return false;
|
||||
context.train().quitAutopilot();
|
||||
return true;
|
||||
}
|
||||
|
||||
public JSONObject json() {
|
||||
JSONObject json = new JSONObject().put(TYPE, getClass().getSimpleName());
|
||||
if (inverted) json.put(INVERTED, true);
|
||||
return json;
|
||||
}
|
||||
|
||||
public StartStopAuto load(JSONObject json) {
|
||||
inverted = json.has(INVERTED) && json.getBoolean(INVERTED);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Window properties(List<Fieldset> preForm, FormInput formInputs, List<Fieldset> postForm) {
|
||||
formInputs.add(t("inverted"),new Checkbox(INVERTED, t("inverted"), inverted));
|
||||
return super.properties(preForm, formInputs, postForm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return inverted ? t("Start autopilot") : t("Stop autopilot");
|
||||
}
|
||||
|
||||
protected Object update(HashMap<String, String> params) {
|
||||
inverted = "on".equals(params.get(INVERTED));
|
||||
return super.update(params);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package de.srsoftware.web4rail.actions;
|
||||
|
||||
import de.srsoftware.web4rail.BaseClass;
|
||||
|
||||
public class StopAuto extends Action {
|
||||
|
||||
public StopAuto(BaseClass parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context) {
|
||||
if (isNull(context.train())) return false;
|
||||
context.train().quitAutopilot();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package de.srsoftware.web4rail.conditions;
|
||||
|
||||
public class AutopilotActive extends Condition {
|
||||
|
||||
@Override
|
||||
public boolean fulfilledBy(Context context) {
|
||||
if (isNull(context.train())) return false;
|
||||
return context.train().usesAutopilot() != inverted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return t(inverted ? "autopilot inactive for train":"autopilot active for train") ;
|
||||
}
|
||||
}
|
||||
@@ -114,6 +114,7 @@ public abstract class Condition extends BaseClass {
|
||||
|
||||
private static List<Class<? extends Condition>> list() {
|
||||
return List.of(
|
||||
AutopilotActive.class,
|
||||
BlockFree.class,
|
||||
OrCondition.class,
|
||||
PushPullTrain.class,
|
||||
@@ -157,6 +158,6 @@ public abstract class Condition extends BaseClass {
|
||||
|
||||
protected Object update(HashMap<String, String> params) {
|
||||
inverted = "on".equals(params.get(INVERTED));
|
||||
return this;
|
||||
return super.update(params);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package de.srsoftware.web4rail.conditions;
|
||||
|
||||
import de.srsoftware.web4rail.BaseClass;
|
||||
|
||||
public class PushPullTrain extends Condition {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.util.List;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import de.srsoftware.web4rail.BaseClass;
|
||||
import de.srsoftware.web4rail.Window;
|
||||
import de.srsoftware.web4rail.tags.Fieldset;
|
||||
import de.srsoftware.web4rail.tags.Input;
|
||||
|
||||
@@ -6,7 +6,6 @@ import java.util.List;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import de.srsoftware.tools.Tag;
|
||||
import de.srsoftware.web4rail.BaseClass;
|
||||
import de.srsoftware.web4rail.Window;
|
||||
import de.srsoftware.web4rail.tags.Fieldset;
|
||||
import de.srsoftware.web4rail.tags.Input;
|
||||
|
||||
Reference in New Issue
Block a user