You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.6 KiB
52 lines
1.6 KiB
package de.srsoftware.web4rail.conditions; |
|
|
|
import java.util.HashMap; |
|
|
|
import de.srsoftware.web4rail.Window; |
|
import de.srsoftware.web4rail.actions.Action.Context; |
|
import de.srsoftware.web4rail.moving.Train; |
|
import de.srsoftware.web4rail.tags.Button; |
|
import de.srsoftware.web4rail.tags.Form; |
|
import de.srsoftware.web4rail.tags.Input; |
|
import de.srsoftware.web4rail.tags.Label; |
|
|
|
public class TrainSelect extends Condition { |
|
|
|
private static final Object TRAIN = Train.class.getSimpleName(); |
|
private Train train; |
|
|
|
@Override |
|
public boolean fulfilledBy(Context context) { |
|
// TODO Auto-generated method stub |
|
return false; |
|
} |
|
|
|
@Override |
|
protected Window properties() { |
|
Window win = new Window("condition-props", t("Properties of {}",getClass().getSimpleName())); |
|
String formId = "conditional-props-"+id; |
|
Form form = new Form(formId); |
|
new Input(REALM,REALM_CONDITION).hideIn(form); |
|
new Input(ACTION,ACTION_UPDATE).hideIn(form); |
|
new Input(ID,id).hideIn(form); |
|
Train.selector(train, null).addTo(new Label(t("Select train:")+NBSP)).addTo(form); |
|
new Button(t("Save")).addTo(form).addTo(win); |
|
return win; |
|
} |
|
|
|
@Override |
|
public String toString() { |
|
if (train == null) return super.toString(); |
|
return t("Train = {}",train); |
|
} |
|
|
|
@Override |
|
protected Object update(HashMap<String, String> params) { |
|
if (!params.containsKey(TRAIN)) return t("No train id passed to TrainSelect.update()!"); |
|
int tid = Integer.parseInt(params.get(TRAIN)); |
|
Train train = Train.get(tid); |
|
if (train == null) return t("No train with id {} found!",tid); |
|
this.train = train; |
|
return t("Updated condition"); |
|
} |
|
}
|
|
|