refactoring...
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.5</version>
|
||||
<version>1.2.6</version>
|
||||
<name>Web4Rail</name>
|
||||
<packaging>jar</packaging>
|
||||
<description>Java Model Railway Control</description>
|
||||
|
||||
@@ -11,6 +11,8 @@ import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import de.keawe.tools.translations.Translation;
|
||||
import de.srsoftware.tools.Tag;
|
||||
@@ -37,6 +39,8 @@ public abstract class BaseClass implements Constants{
|
||||
private static final char[] HEX_CHARS = "0123456789ABCDEF".toCharArray();
|
||||
protected Id id = null;
|
||||
protected String notes;
|
||||
|
||||
public static final Logger LOG = LoggerFactory.getLogger(BaseClass.class);
|
||||
private BaseClass parent;
|
||||
|
||||
public static class Context {
|
||||
@@ -145,7 +149,7 @@ public abstract class BaseClass implements Constants{
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
internalId = md5sum(new Date());
|
||||
internalId = ""+new Date().getTime();
|
||||
}
|
||||
|
||||
|
||||
@@ -351,6 +355,7 @@ public abstract class BaseClass implements Constants{
|
||||
}
|
||||
|
||||
protected Object update(HashMap<String, String> params) {
|
||||
LOG.debug("update: {}",params);
|
||||
if (params.containsKey(NOTES)) notes = params.get(NOTES).trim();
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user