implemented conditions on routes

This commit is contained in:
Stephan Richter
2020-10-30 12:35:04 +01:00
parent d8ce80f2da
commit ce00d21184
11 changed files with 102 additions and 22 deletions

View File

@@ -34,6 +34,10 @@ public abstract class Action implements Constants {
if (route == null) return;
train = route.train;
}
public Context(Train train) {
this.train = train;
}
}
public Action() {

View File

@@ -50,8 +50,7 @@ public class ActionList extends Vector<Action> implements Constants{
}
private Object actionTypeForm(Window win, String context) {
String formId ="add-action-to-"+id;
Tag typeForm = new Form(formId);
Form typeForm = new Form("add-action-to-"+id);
new Input(REALM, REALM_ACTIONS).hideIn(typeForm);
new Input(ID,id).hideIn(typeForm);
new Input(ACTION,ACTION_ADD).hideIn(typeForm);
@@ -68,7 +67,7 @@ public class ActionList extends Vector<Action> implements Constants{
);
for (Class<? extends Action> clazz : classes) select.addOption(clazz.getSimpleName());
select.addTo(new Label("Action type:")).addTo(typeForm);
return new Button(t("Create action"),"return submitForm('"+formId+"');").addTo(typeForm).addTo(win);
return new Button(t("Create action"),typeForm).addTo(typeForm).addTo(win);
}
private Object addActionForm(HashMap<String, String> params, Plan plan) {

View File

@@ -43,8 +43,8 @@ public class ConditionalAction extends Action {
for (Condition condition : conditions) condition.link("li",params.get(CONTEXT)).addTo(list);
list.addTo(fieldset);
}
String formId = "action-prop-form-"+id;
Form form = new Form(formId);
Form form = new Form("action-prop-form-"+id);
new Input(REALM,REALM_ACTIONS).hideIn(form);
new Input(ID,params.get(ID)).hideIn(form);
new Input(ACTION,ACTION_UPDATE).hideIn(form);
@@ -54,7 +54,7 @@ public class ConditionalAction extends Action {
List<Class<? extends Condition>> classes = List.of(TrainSelect.class);
for (Class<? extends Condition> clazz : classes) select.addOption(clazz.getSimpleName());
select.addTo(form);
return new Button(t("Add condition"),"return submitForm('"+formId+"');").addTo(form).addTo(fieldset);
return new Button(t("Add condition"),form).addTo(form).addTo(fieldset);
}
@Override

View File

@@ -45,8 +45,7 @@ public class SetSpeed extends Action{
@Override
public Window properties(HashMap<String, String> params) {
Window win = super.properties(params);
String formId = "action-prop-form-"+id;
Form form = new Form(formId);
Form form = new Form("action-prop-form-"+id);
new Input(REALM,REALM_ACTIONS).hideIn(form);
new Input(ID,params.get(ID)).hideIn(form);
new Input(ACTION,ACTION_UPDATE).hideIn(form);
@@ -54,7 +53,7 @@ public class SetSpeed extends Action{
Label label = new Label(t("Set speed to")+NBSP);
new Input(MAX_SPEED, maxSpeed).addTo(label).content(NBSP+t("km/h"));
label.addTo(form);
new Button(t("Apply"),"return submitForm('"+formId+"');").addTo(form).addTo(win);
new Button(t("Apply"),form).addTo(form).addTo(win);
return win;
}