|
@@ -6,6 +6,8 @@ import javafx.scene.layout.GridPane;
|
|
|
import org.json.simple.JSONArray;
|
|
|
import org.json.simple.JSONObject;
|
|
|
|
|
|
+import java.util.Iterator;
|
|
|
+
|
|
|
public class PropertyManager extends ScrollPane implements IGUIEventClient{
|
|
|
private GUIEventHandler _eventHandler;
|
|
|
private JSONObject jsel = new JSONObject();
|
|
@@ -31,81 +33,40 @@ public class PropertyManager extends ScrollPane implements IGUIEventClient{
|
|
|
setFitToWidth(true);
|
|
|
}
|
|
|
|
|
|
- private void setContent(TitledPane pane, JSONObject json){
|
|
|
- TabPane tabPane = new TabPane();
|
|
|
- GridPane gpane = new GridPane();
|
|
|
+ private GridPane createLayout(JSONObject json){
|
|
|
+ GridPane glayout = new GridPane();
|
|
|
+ glayout.getChildren().clear();
|
|
|
+ glayout.setHgap(5);
|
|
|
+ glayout.setVgap(5);
|
|
|
+
|
|
|
+ Iterator<String> itr = json.keySet().iterator();
|
|
|
int counter = 0;
|
|
|
- if (json.containsKey("ID")){
|
|
|
- JSONObject jID = (JSONObject)json.get("ID");
|
|
|
- if (jID.containsKey("name")){
|
|
|
- gpane.add(new Label("Name:"), 0,counter);
|
|
|
- TextField tf = new TextField(jID.get("name").toString());
|
|
|
- gpane.add(tf, 1,counter);
|
|
|
- ++counter;
|
|
|
- }
|
|
|
- if (jID.containsKey("appendix")){
|
|
|
- gpane.add(new Label("Appendix:"), 0,counter);
|
|
|
- TextField tf = new TextField(jID.get("appendix").toString());
|
|
|
- gpane.add(tf, 1,counter);
|
|
|
- ++counter;
|
|
|
+ while (itr.hasNext()){
|
|
|
+ String key = itr.next();
|
|
|
+ JSONObject jconfig;
|
|
|
+ try {
|
|
|
+ jconfig = (JSONObject) json.get(key);
|
|
|
+ }catch (ClassCastException e){
|
|
|
+ jconfig = new JSONObject();
|
|
|
+ jconfig.put("value", json.get(key));
|
|
|
}
|
|
|
- }
|
|
|
- if (json.containsKey("optimizable")){
|
|
|
- gpane.add(new Label("Optimized:"), 0,counter);
|
|
|
- CheckBox cb = new CheckBox();
|
|
|
- String sstate = json.get("optimizable").toString();
|
|
|
- if (sstate.equals("true")){
|
|
|
- cb.setSelected(true);
|
|
|
- }
|
|
|
- gpane.add(cb, 1,counter);
|
|
|
- ++counter;
|
|
|
- }
|
|
|
- if (json.containsKey("value")){
|
|
|
- gpane.add(new Label("Value:"), 0,counter);
|
|
|
- TextField tf = new TextField(json.get("value").toString());
|
|
|
- gpane.add(tf, 1,counter);
|
|
|
+ Label clabel = new Label(key);
|
|
|
+ glayout.add(clabel,0,counter);
|
|
|
+ glayout.add(new Configuration(jsel, key, jconfig),1,counter);
|
|
|
++counter;
|
|
|
}
|
|
|
- Tab tab_main = new Tab("Main", gpane);
|
|
|
- tabPane.getTabs().add(tab_main);
|
|
|
|
|
|
+ return glayout;
|
|
|
+ }
|
|
|
|
|
|
- if (json.containsKey("limit")){
|
|
|
- counter = 0;
|
|
|
- GridPane gplimit = new GridPane();
|
|
|
- JSONObject jlimit = (JSONObject)json.get("limit");
|
|
|
- if (jlimit.containsKey("min")){
|
|
|
- gplimit.add(new Label("min:"), 0,counter);
|
|
|
- TextField tf = new TextField(jlimit.get("min").toString());
|
|
|
- gplimit.add(tf, 1,counter);
|
|
|
- ++counter;
|
|
|
- }
|
|
|
- if (jlimit.containsKey("max")){
|
|
|
- gplimit.add(new Label("max:"), 0,counter);
|
|
|
- TextField tf = new TextField(jlimit.get("max").toString());
|
|
|
- gplimit.add(tf, 1,counter);
|
|
|
- ++counter;
|
|
|
- }
|
|
|
- if (jlimit.containsKey("step")){
|
|
|
- gplimit.add(new Label("step:"), 0,counter);
|
|
|
- TextField tf = new TextField(jlimit.get("step").toString());
|
|
|
- gplimit.add(tf, 1,counter);
|
|
|
- ++counter;
|
|
|
- }
|
|
|
- if (jlimit.containsKey("rule")){
|
|
|
- gplimit.add(new Label("rule:"), 0,counter);
|
|
|
- TextField tf = new TextField(jlimit.get("rule").toString());
|
|
|
- gplimit.add(tf, 1,counter);
|
|
|
- ++counter;
|
|
|
- }
|
|
|
- if (jlimit.containsKey("elements")){
|
|
|
- gplimit.add(new Label("elements:"), 0,counter);
|
|
|
- TextField tf = new TextField(jlimit.get("elements").toString());
|
|
|
- gplimit.add(tf, 1,counter);
|
|
|
- ++counter;
|
|
|
- }
|
|
|
- Tab tab_limit = new Tab("Limit" , gplimit);
|
|
|
- tabPane.getTabs().add(tab_limit);
|
|
|
+ private void setContent(TitledPane pane, JSONObject json){
|
|
|
+ TabPane tabPane = new TabPane();
|
|
|
+ Iterator<String> itr = json.keySet().iterator();
|
|
|
+ while (itr.hasNext()){
|
|
|
+ String key = itr.next();
|
|
|
+ JSONObject jcontent = (JSONObject) json.get(key);
|
|
|
+ Tab tab = new Tab(key , new ScrollPane(createLayout(jcontent)));
|
|
|
+ tabPane.getTabs().add(tab);
|
|
|
}
|
|
|
tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE);
|
|
|
pane.setContent(tabPane);
|
|
@@ -121,7 +82,7 @@ public class PropertyManager extends ScrollPane implements IGUIEventClient{
|
|
|
public void processGUIEvent(String event, JSONObject args) {
|
|
|
if (event == "MOUSE_PRESSED"){
|
|
|
if (!args.equals(jsel)){
|
|
|
-
|
|
|
+ jsel = args;
|
|
|
JSONObject jmsg = new JSONObject();
|
|
|
jmsg.put("operation", "state");
|
|
|
jmsg.put("args", args);
|