Creates assets in world from JSON
This commit is contained in:
@ -92,7 +92,7 @@ public class AssetListPanel extends javax.swing.JPanel implements GuiSelectionLi
|
||||
String type_name;
|
||||
|
||||
try {
|
||||
type_name=a.getConstructor().newInstance().getTypeName();
|
||||
type_name=a.getConstructor(World.class,JSONObject.class).newInstance(null,null).getTypeName();
|
||||
|
||||
} catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
|
||||
Logger.getLogger(AssetListPanel.class.getName()).log(Level.SEVERE, null, ex);
|
||||
|
@ -445,13 +445,7 @@ public class Globals {
|
||||
|
||||
}
|
||||
|
||||
public static JSONObject getWorld(){
|
||||
JSONObject world = new JSONObject();
|
||||
world.put(PrefKeys.ASSETS, getAssets());
|
||||
world.put(PrefKeys.EXCHANGES, getExchanges());
|
||||
return world;
|
||||
}
|
||||
|
||||
|
||||
public static void clearAll() {
|
||||
putStrategies(new JSONObject());
|
||||
putTraders(new JSONArray());
|
||||
@ -466,5 +460,13 @@ public class Globals {
|
||||
loadString(s);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static JSONObject getWorld(){
|
||||
JSONObject cfg = new JSONObject();
|
||||
cfg.put(World.JKEYS.ASSETS, getAssets());
|
||||
cfg.put(World.JKEYS.EXCHANGES, getExchanges());
|
||||
return cfg;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -69,6 +69,7 @@ import opensesim.old_sesim.Exchange;
|
||||
import opensesim.old_sesim.Scheduler;
|
||||
|
||||
import opensesim.util.XClassLoader;
|
||||
import opensesim.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -598,7 +599,7 @@ public class SeSimApplication extends javax.swing.JFrame {
|
||||
|
||||
void startSim() {
|
||||
|
||||
// World = new World();
|
||||
World world = new World(Globals.getWorld());
|
||||
|
||||
|
||||
|
||||
|
@ -129,16 +129,30 @@ public class Json {
|
||||
}
|
||||
|
||||
Class cls = f.getType();
|
||||
String name = null == imp.value() ? f.getName() : imp.value();
|
||||
|
||||
// JTextField
|
||||
if (JTextField.class.isAssignableFrom(cls)) {
|
||||
try {
|
||||
JTextField tf = (JTextField) f.get(o);
|
||||
String name = null == imp.value() ? f.getName() : imp.value();
|
||||
|
||||
tf.setText(jo.optString(name));
|
||||
} catch (IllegalArgumentException | IllegalAccessException ex1) {
|
||||
Logger.getLogger(Json.class.getName()).log(Level.SEVERE, null, ex1);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// String
|
||||
if (String.class.isAssignableFrom(cls)) {
|
||||
try {
|
||||
f.set(o, jo.optString(name));
|
||||
} catch (IllegalArgumentException | IllegalAccessException ex1) {
|
||||
Logger.getLogger(Json.class.getName()).log(Level.SEVERE, null, ex1);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Method[] methods = o.getClass().getMethods();
|
||||
|
Reference in New Issue
Block a user