implemented conditions on routes
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user