more GUI improvements
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -4,7 +4,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>de.srsoftware</groupId>
|
<groupId>de.srsoftware</groupId>
|
||||||
<artifactId>web4rail</artifactId>
|
<artifactId>web4rail</artifactId>
|
||||||
<version>1.2.42</version>
|
<version>1.2.43</version>
|
||||||
<name>Web4Rail</name>
|
<name>Web4Rail</name>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<description>Java Model Railway Control</description>
|
<description>Java Model Railway Control</description>
|
||||||
|
|||||||
@@ -163,6 +163,10 @@ function request(data){
|
|||||||
method : POST,
|
method : POST,
|
||||||
data : data,
|
data : data,
|
||||||
success: function(resp){
|
success: function(resp){
|
||||||
|
var win = $('.window');
|
||||||
|
var scroll = win.scrollTop();
|
||||||
|
var winId = win.attr('id');
|
||||||
|
|
||||||
if (data.realm != 'car' && data.realm != 'loco') closeWindows();
|
if (data.realm != 'car' && data.realm != 'loco') closeWindows();
|
||||||
if (resp.startsWith('<html')) return;
|
if (resp.startsWith('<html')) return;
|
||||||
if (resp.startsWith('<svg')){
|
if (resp.startsWith('<svg')){
|
||||||
@@ -171,10 +175,15 @@ function request(data){
|
|||||||
var isWindow = $(resp).attr('class') == 'window';
|
var isWindow = $(resp).attr('class') == 'window';
|
||||||
if (isWindow) $('.window').remove();
|
if (isWindow) $('.window').remove();
|
||||||
$(BODY).append($(resp));
|
$(BODY).append($(resp));
|
||||||
if (isWindow) tileWindow();
|
if (isWindow) {
|
||||||
|
tileWindow();
|
||||||
|
var win = $('.window');
|
||||||
|
if (win.attr('id')==winId) win.scrollTop(scroll);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
addMessage(resp);
|
addMessage(resp);
|
||||||
}
|
}
|
||||||
|
$("html").scrollTop(scroll);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ public interface Constants {
|
|||||||
public static final String PARENT = "parent";
|
public static final String PARENT = "parent";
|
||||||
public static final String PORT = "port";
|
public static final String PORT = "port";
|
||||||
public static final String RELAY = "relay";
|
public static final String RELAY = "relay";
|
||||||
|
public static final String ROUTE = "route";
|
||||||
public static final String TURNOUT = "turnout";
|
public static final String TURNOUT = "turnout";
|
||||||
public static final String TYPE = "type";
|
public static final String TYPE = "type";
|
||||||
public static final Charset UTF8 = StandardCharsets.UTF_8;
|
public static final Charset UTF8 = StandardCharsets.UTF_8;
|
||||||
|
|||||||
@@ -165,6 +165,8 @@ public class Plan extends BaseClass{
|
|||||||
return addTile(params.get(TILE),params.get(X),params.get(Y),null);
|
return addTile(params.get(TILE),params.get(X),params.get(Y),null);
|
||||||
case ACTION_ANALYZE:
|
case ACTION_ANALYZE:
|
||||||
return analyze();
|
return analyze();
|
||||||
|
case ACTION_AUTO:
|
||||||
|
return simplyfyRouteName(params);
|
||||||
case ACTION_CLICK:
|
case ACTION_CLICK:
|
||||||
return click(get(Id.from(params),true));
|
return click(get(Id.from(params),true));
|
||||||
case ACTION_CONNECT:
|
case ACTION_CONNECT:
|
||||||
@@ -615,10 +617,10 @@ public class Plan extends BaseClass{
|
|||||||
|
|
||||||
new Tag("h4").content(t("Routes")).addTo(win);
|
new Tag("h4").content(t("Routes")).addTo(win);
|
||||||
table = new Table();
|
table = new Table();
|
||||||
table.addHead(t("Name"),t("Start"),t("End"));
|
table.addHead(t("Name"),t("Start"),t("End"),t("Actions"));
|
||||||
List<Route> routes = BaseClass.listElements(Route.class);
|
List<Route> routes = BaseClass.listElements(Route.class);
|
||||||
for (Route route : routes) {
|
for (Route route : routes) {
|
||||||
table.addRow(route.link("span",route.name()),route.link("span", route.startBlock()),route.link("span", route.endBlock()));
|
table.addRow(route.link("span",route.name()),route.link("span", route.startBlock()),route.link("span", route.endBlock()),plan.button(t("simplyfy name"), Map.of(ACTION,ACTION_AUTO,ROUTE,route.id().toString())));
|
||||||
}
|
}
|
||||||
table.clazz("turnouts").addTo(win);
|
table.clazz("turnouts").addTo(win);
|
||||||
|
|
||||||
@@ -709,6 +711,19 @@ public class Plan extends BaseClass{
|
|||||||
if (isSet(contact)) contact.activate(active);
|
if (isSet(contact)) contact.activate(active);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Object simplyfyRouteName(HashMap<String, String> params) {
|
||||||
|
String routeId = params.get(ROUTE);
|
||||||
|
if (isSet(routeId)) {
|
||||||
|
Route route = BaseClass.get(new Id(routeId));
|
||||||
|
if (isSet(route)) route.simplyfyName();
|
||||||
|
}
|
||||||
|
Id tileId = Id.from(params);
|
||||||
|
Tile tile = isSet(tileId)? BaseClass.get(tileId) : null;
|
||||||
|
if (isSet(tile)) return tile.properties();
|
||||||
|
params.remove(ID);
|
||||||
|
return plan.properties(params);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sends some data to the clients
|
* sends some data to the clients
|
||||||
* @param data
|
* @param data
|
||||||
|
|||||||
@@ -748,7 +748,11 @@ public class Route extends BaseClass {
|
|||||||
preForm.add(contactsAndActions());
|
preForm.add(contactsAndActions());
|
||||||
|
|
||||||
formInputs.add(t("Name"),new Input(NAME, name()));
|
formInputs.add(t("Name"),new Input(NAME, name()));
|
||||||
formInputs.add(t("State"),new Checkbox(DISABLED, t("disabled"), disabled));
|
Checkbox checkbox = new Checkbox(DISABLED, t("disabled"), disabled);
|
||||||
|
if (disabled) checkbox.clazz("disabled");
|
||||||
|
formInputs.add(t("State"),checkbox);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
postForm.add(basicProperties());
|
postForm.add(basicProperties());
|
||||||
if (!turnouts.isEmpty()) postForm.add(turnouts());
|
if (!turnouts.isEmpty()) postForm.add(turnouts());
|
||||||
@@ -848,6 +852,11 @@ public class Route extends BaseClass {
|
|||||||
return parts[0].trim()+"–"+parts[parts.length-1].trim();
|
return parts[0].trim()+"–"+parts[parts.length-1].trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void simplyfyName() {
|
||||||
|
String[] parts = name().split("-");
|
||||||
|
if (parts.length>1) name(parts[0]+" - "+parts[parts.length-1]);
|
||||||
|
}
|
||||||
|
|
||||||
public Route.State state(){
|
public Route.State state(){
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,8 +24,9 @@ public class SetTurnout extends Action {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean fire(Context context) {
|
public boolean fire(Context context) {
|
||||||
if (isNull(turnout)) return false;
|
if (isNull(turnout)) return false;
|
||||||
if (!turnout.state(state).succeeded()) return false;
|
if (!turnout.state(state).succeeded()) return false;
|
||||||
|
if (turnout.address() == 0) return true;
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ public abstract class Tile extends BaseClass implements Comparable<Tile>{
|
|||||||
private static final String OCCUPIED = "occupied";
|
private static final String OCCUPIED = "occupied";
|
||||||
private static final String ONEW_WAY = "one_way";
|
private static final String ONEW_WAY = "one_way";
|
||||||
private static final String POS = "pos";
|
private static final String POS = "pos";
|
||||||
private static final String ROUTE = "route";
|
|
||||||
private static final String TYPE = "type";
|
private static final String TYPE = "type";
|
||||||
private static final String X = "x";
|
private static final String X = "x";
|
||||||
private static final String Y = "y";
|
private static final String Y = "y";
|
||||||
@@ -246,6 +245,7 @@ public abstract class Tile extends BaseClass implements Comparable<Tile>{
|
|||||||
for (Route route : routes) {
|
for (Route route : routes) {
|
||||||
Tag li = route.link("span", route.name()+(route.isDisabled()?" ["+t("disabled")+"]" : "")+NBSP).addTo(new Tag("li").clazz("link"));
|
Tag li = route.link("span", route.name()+(route.isDisabled()?" ["+t("disabled")+"]" : "")+NBSP).addTo(new Tag("li").clazz("link"));
|
||||||
route.button(t("delete route"),Map.of(ACTION,ACTION_DROP)).addTo(li);
|
route.button(t("delete route"),Map.of(ACTION,ACTION_DROP)).addTo(li);
|
||||||
|
button(t("simplify name"), Map.of(ACTION,ACTION_AUTO,ROUTE,route.id().toString())).addTo(li);
|
||||||
li.addTo(routeList);
|
li.addTo(routeList);
|
||||||
}
|
}
|
||||||
routeList.addTo(fieldset);
|
routeList.addTo(fieldset);
|
||||||
|
|||||||
Reference in New Issue
Block a user