implemented renamable blocks
This commit is contained in:
@@ -1,5 +1,55 @@
|
||||
package de.srsoftware.web4rail.tiles;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import de.srsoftware.tools.Tag;
|
||||
|
||||
public class BlockV extends StraightV{
|
||||
private static final String NAME = "name";
|
||||
Contact west,center,east;
|
||||
private String name = "Block";
|
||||
|
||||
@Override
|
||||
public JSONObject config() {
|
||||
JSONObject config = super.config();
|
||||
config.put(NAME, name);
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(JSONObject config) {
|
||||
super.configure(config);
|
||||
if (config.has(NAME)) name = config.getString(NAME);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Tag propForm() {
|
||||
Tag form = super.propForm();
|
||||
|
||||
Tag label = new Tag("label").content(t("name:"));
|
||||
new Tag("input").attr("type", "text").attr(NAME,"name").attr("value", name).addTo(label);
|
||||
label.addTo(form);
|
||||
|
||||
return form;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tag tag(Map<String, Object> replacements) throws IOException {
|
||||
if (replacements == null) replacements = new HashMap<String, Object>();
|
||||
replacements.put("%text%",name);
|
||||
return super.tag(replacements);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tile update(HashMap<String, String> params) {
|
||||
super.update(params);
|
||||
if (params.containsKey(NAME)) name=params.get(NAME);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user