refactoring...

This commit is contained in:
Stephan Richter
2020-12-03 02:18:33 +01:00
parent 8764d35a97
commit 559538d55e
5 changed files with 22 additions and 13 deletions

View File

@@ -125,8 +125,17 @@ public abstract class Action extends BaseClass {
public String toString() {
return t(getClass().getSimpleName());
}
@Override
protected Object update(HashMap<String, String> params) {
return t("Nothing changed");
super.update(params);
BaseClass parent = parent();
if (isNull(parent)) return properties();
if (parent instanceof ActionList) {
ActionList al = (ActionList) parent;
return al.parent().properties();
}
return parent.properties();
}
}

View File

@@ -83,14 +83,11 @@ public class SetSignal extends Action {
};
@Override
protected Object update(HashMap<String, String> params) {
LOG.debug("update: {}",params);
public Object update(HashMap<String, String> params) {
Tile tile = plan.get(new Id(params.get(SIGNAL)), false);
if (tile instanceof Signal) signal = (Signal) tile;
String st = params.get(Signal.STATE);
if (isSet(st)) state = st;
return properties();
return super.update(params);
}
}

View File

@@ -5,7 +5,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;
@@ -59,7 +58,6 @@ public class SetSpeed extends Action{
@Override
protected Object update(HashMap<String, String> params) {
LOG.debug("update: {}",params);
String error = null;
String ms = params.get(MAX_SPEED);
if (ms == null) {
@@ -76,7 +74,7 @@ public class SetSpeed extends Action{
error = t("Not a valid number!");
}
}
Window win = properties();
return new Tag("span").content(error).addTo(win);
if (isSet(error)) return error;
return super.update(params);
}
}