preparing lookup tables
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.5.17</version>
|
||||
<version>1.5.18</version>
|
||||
<name>Web4Rail</name>
|
||||
<packaging>jar</packaging>
|
||||
<description>Java Model Railway Control</description>
|
||||
|
||||
@@ -24,6 +24,7 @@ Add condition : Bedingung hinzufügen
|
||||
Add entry : Eintrag hinzufügen
|
||||
Add function : Funktion hinzufügen
|
||||
add locomotive : Lok hinzufügen
|
||||
add lookup table : Wertetabelle hinzufügen
|
||||
add new aspect : neues Signalbild hinzufügen
|
||||
add new car : neuen Waggon anlegen
|
||||
Add new custom field : neues benutzerdefiniertes Feld hinzufügen
|
||||
@@ -94,6 +95,7 @@ click here to setup signal : Hier klicken, um Signal einzurichten
|
||||
Click here to setup tag : Hier klicken, um Markierung anzugeben
|
||||
click here to setup turnout : Hier klicken, um Weiche einzurichten
|
||||
Click on a name to edit the entry. : Klicke auf einen Namen, um einen Eintrag zu bearbeiten.
|
||||
columns : Spalten
|
||||
Command to send : Kommando, welches gesendet werden soll
|
||||
ConditionalAction : bedingte Aktion
|
||||
Condition : Bedingung
|
||||
@@ -224,6 +226,7 @@ Locked by {} : Durch {} besetzt
|
||||
Locomotive manager : Lok-Verwaltung
|
||||
Locomotives : Lokomotiven
|
||||
Locomotives and cars : Lokomotiven und Waggons
|
||||
lookup tables : Wertetabellen
|
||||
Loop : Wiederholung
|
||||
Lower speed limit : Minimale Geschwindigkeit
|
||||
Maintenance : Wartung
|
||||
@@ -323,6 +326,7 @@ Route properties : Routen-Eigenschaften
|
||||
Routes : Fahrstraßen
|
||||
Routes using this tile : Fahrstraßen, die diesen Abschnitt verwenden
|
||||
Route will only be available, if all conditions are fulfilled. : Route ist nur verfügbar, wenn alle Bedingungen erfüllt sind.
|
||||
rows : Zeilen
|
||||
Save "{}" : „{}“ speichern
|
||||
Save : speichern
|
||||
SavePlan : Plan speichern
|
||||
|
||||
@@ -135,6 +135,8 @@ public class Application extends BaseClass{
|
||||
return History.action(params);
|
||||
case REALM_LOCO:
|
||||
return Locomotive.action(params,plan);
|
||||
case REALM_LOOKUP:
|
||||
return LookupTable.action(params);
|
||||
case REALM_MAINTENANCE:
|
||||
return MaintnanceTask.action(params);
|
||||
case REALM_PLAN:
|
||||
|
||||
@@ -226,7 +226,7 @@ public abstract class BaseClass implements Constants{
|
||||
}
|
||||
}
|
||||
|
||||
public class FormInput extends ArrayList<Map.Entry<String, Tag>>{
|
||||
public static class FormInput extends ArrayList<Map.Entry<String, Tag>>{
|
||||
|
||||
private static final long serialVersionUID = -2371203388908395216L;
|
||||
|
||||
@@ -352,7 +352,7 @@ public abstract class BaseClass implements Constants{
|
||||
return l+NBSP+unit;
|
||||
}
|
||||
|
||||
public Form form(String id,List<Map.Entry<String, Tag>> elements) {
|
||||
public static Form form(String id,List<Map.Entry<String, Tag>> elements) {
|
||||
Form form = new Form(id);
|
||||
|
||||
Table table = new Table();
|
||||
@@ -383,8 +383,11 @@ public abstract class BaseClass implements Constants{
|
||||
return o==null;
|
||||
}
|
||||
|
||||
public static boolean isSet(Object o) {
|
||||
return o != null;
|
||||
public static boolean isSet(Object...o) {
|
||||
for (Object x : o) {
|
||||
if (x == null) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public JSONObject json() {
|
||||
|
||||
@@ -49,6 +49,7 @@ public interface Constants {
|
||||
public static final String REALM_FUNCTION = "function";
|
||||
public static final String REALM_HISTORY = "history";
|
||||
public static final String REALM_LOCO = "loco";
|
||||
public static final String REALM_LOOKUP = "lookup";
|
||||
public static final String REALM_MAINTENANCE = "maintenance";
|
||||
public static final String REALM_ROUTE = "route";
|
||||
public static final String REALM_PLAN = "plan";
|
||||
|
||||
56
src/main/java/de/srsoftware/web4rail/LookupTable.java
Normal file
56
src/main/java/de/srsoftware/web4rail/LookupTable.java
Normal file
@@ -0,0 +1,56 @@
|
||||
package de.srsoftware.web4rail;
|
||||
|
||||
import de.srsoftware.web4rail.tags.Form;
|
||||
import de.srsoftware.web4rail.tags.Input;
|
||||
import de.srsoftware.web4rail.tags.Select;
|
||||
import de.srsoftware.web4rail.tags.Window;
|
||||
|
||||
public class LookupTable extends BaseClass{
|
||||
|
||||
private static final String ADD_FORM = "add_lookup";
|
||||
private static final String COLUMNS = "columns";
|
||||
private static final String ROWS = "rows";
|
||||
|
||||
public static Object action(Params params) {
|
||||
String action = params.getString(ACTION);
|
||||
if (isNull(action)) throw new NullPointerException(ACTION+" should not be null!");
|
||||
|
||||
switch (action) {
|
||||
case ACTION_ADD:
|
||||
return addForm(params);
|
||||
}
|
||||
return plan.properties(t("Unknown action: {}",action));
|
||||
}
|
||||
|
||||
private static Object addForm(Params params) {
|
||||
String name = params.getString(NAME);
|
||||
String cols = params.getString(COLUMNS);
|
||||
String rows = params.getString(ROWS);
|
||||
if (isSet(name,cols,rows)) return create(name,cols,rows);
|
||||
Window win = new Window(ADD_FORM, t("add lookup table"));
|
||||
FormInput formInputs = new FormInput();
|
||||
|
||||
formInputs.add(t(NAME), new Input(NAME, t("lookup")+'-'+timestamp()));
|
||||
|
||||
formInputs.add(t(ROWS), selector(ROWS));
|
||||
formInputs.add(t(COLUMNS), selector(COLUMNS));
|
||||
Form form = form(ADD_FORM+"_form", formInputs);
|
||||
new Input(REALM, REALM_LOOKUP).hideIn(form);
|
||||
new Input(ACTION, ACTION_ADD).hideIn(form);
|
||||
return form.addTo(win);
|
||||
}
|
||||
|
||||
private static Object create(String name, String cols, String rows2) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Select selector(String name) {
|
||||
Select selector = new Select(name);
|
||||
selector.addOption(REALM_LOCO, t("Locomotives"));
|
||||
selector.addOption(REALM_TRAIN, t("Trains"));
|
||||
selector.addOption(REALM_TRAIN+"_length", t("TrainLength"));
|
||||
return selector;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -609,6 +609,13 @@ public class Plan extends BaseClass{
|
||||
LoadCallback.fire();
|
||||
}
|
||||
|
||||
private Fieldset lookupTables() {
|
||||
Fieldset fieldset = new Fieldset(t("lookup tables"));
|
||||
Button button = button(t("add"),Map.of(REALM,REALM_LOOKUP,ACTION,ACTION_ADD));
|
||||
button.addTo(fieldset);
|
||||
return fieldset;
|
||||
}
|
||||
|
||||
/**
|
||||
* creates the main menu attached to the plan
|
||||
* @return
|
||||
@@ -763,6 +770,7 @@ public class Plan extends BaseClass{
|
||||
|
||||
postForm.add(relayProperties());
|
||||
postForm.add(routeProperties());
|
||||
postForm.add(lookupTables());
|
||||
return super.properties(preForm, formInputs, postForm, errorMessages);
|
||||
}
|
||||
|
||||
|
||||
@@ -156,8 +156,7 @@ public class Train extends BaseClass implements Comparable<Train> {
|
||||
case ACTION_UPDATE:
|
||||
return train.update(params);
|
||||
}
|
||||
String message = t("Unknown action: {}",action);
|
||||
return train.properties(message);
|
||||
return train.properties(t("Unknown action: {}",action));
|
||||
}
|
||||
|
||||
public Train add(Car car) {
|
||||
|
||||
Reference in New Issue
Block a user