Removed the "masterkey thing"

We will use proxies from RealWorld to GodWorld
This commit is contained in:
2018-12-08 11:11:08 +01:00
parent 137c6af75d
commit 6d24eb67b9
27 changed files with 423 additions and 374 deletions

View File

@ -31,10 +31,8 @@ import java.awt.Window;
import opensesim.world.AbstractAsset;
import opensesim.gui.util.EscDialog;
import opensesim.gui.Globals;
import opensesim.gui.util.Json;
import opensesim.world.World;
import opensesim.world.WorldAdm;
import opensesim.world.GodWorld;
import org.json.JSONObject;
/**
@ -43,7 +41,7 @@ import org.json.JSONObject;
*/
public class AssetEditorDialog extends EscDialog {
WorldAdm worldadm;
GodWorld worldadm;
/**
@ -196,7 +194,7 @@ public class AssetEditorDialog extends EscDialog {
}//GEN-LAST:event_cancelButtonActionPerformed
static public boolean runDialog(Window parent, WorldAdm worldadm, JSONObject o, JSONObject old) {
static public boolean runDialog(Window parent, GodWorld worldadm, JSONObject o, JSONObject old) {
AssetEditorDialog d = new AssetEditorDialog(parent);
d.worldadm = worldadm;

View File

@ -40,8 +40,9 @@ import opensesim.gui.util.Json;
import opensesim.gui.util.Json.Export;
import opensesim.gui.util.Json.Import;
import opensesim.util.SeSimException;
import opensesim.world.World;
import opensesim.world.WorldAdm;
import opensesim.world.GodWorld;
import opensesim.world.RealWorld;
import org.json.JSONObject;
/**
@ -228,7 +229,7 @@ public class AssetEditorPanel extends javax.swing.JPanel {
decimalsField.setValue(Integer.parseInt(d));
}
@Export(World.JKEYS.ASSET_TYPE)
@Export(GodWorld.JKEYS.ASSET_TYPE)
public String getType() {
int selected = assetTypesComboBox.getSelectedIndex();
//return asset_types.get(selected).getName();
@ -237,7 +238,7 @@ public class AssetEditorPanel extends javax.swing.JPanel {
String type;
@Import(World.JKEYS.ASSET_TYPE)
@Import(GodWorld.JKEYS.ASSET_TYPE)
public void setType(String type) {
this.type=type;
@ -249,7 +250,7 @@ public class AssetEditorPanel extends javax.swing.JPanel {
AbstractAsset a;
try {
a = ac.getConstructor(World.class, JSONObject.class).newInstance(null, null);
a = ac.getConstructor(RealWorld.class, JSONObject.class).newInstance(null, null);
} catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
Logger.getLogger(AssetEditorPanel.class.getName()).log(Level.SEVERE, null, ex);
return;
@ -274,12 +275,12 @@ public class AssetEditorPanel extends javax.swing.JPanel {
}
public boolean save(WorldAdm worldadm ){
public boolean save(GodWorld worldadm ){
JSONObject jo = Json.get(this);
System.out.printf("ASSETGETTER: %s\n",jo.toString(5));
if (jo.getString(World.JKEYS.ASSET_SYMBOL).length()==0){
if (jo.getString(GodWorld.JKEYS.ASSET_SYMBOL).length()==0){
javax.swing.JOptionPane.showMessageDialog(this, "Symbol must not be empty.",
"Error",
javax.swing.JOptionPane.ERROR_MESSAGE);
@ -287,7 +288,7 @@ public class AssetEditorPanel extends javax.swing.JPanel {
}
try {
worldadm.world.createAsset(worldadm.masterKey, jo);
worldadm.createAsset(jo);
} catch (SeSimException ex) {
javax.swing.JOptionPane.showMessageDialog(this, ex.getMessage(),
"Error",

View File

@ -29,8 +29,7 @@ import java.awt.Window;
import java.awt.event.MouseEvent;
import opensesim.gui.Globals;
import opensesim.gui.util.EscDialog;
import opensesim.world.World;
import opensesim.world.WorldAdm;
import opensesim.world.GodWorld;
import org.json.JSONObject;
@ -40,7 +39,7 @@ import org.json.JSONObject;
*/
public class AssetListDialog extends EscDialog {
WorldAdm worldadm;
GodWorld worldadm;
/**
* Creates new form EditAssetsDialog
@ -62,7 +61,7 @@ public class AssetListDialog extends EscDialog {
this.assetListPanel.assetTable.addMouseListener(l);
}
public AssetListDialog(WorldAdm worldadm, Window parent, boolean modal) {
public AssetListDialog(GodWorld worldadm, Window parent, boolean modal) {
super(parent, modal);
this.worldadm = worldadm;
@ -173,7 +172,7 @@ public class AssetListDialog extends EscDialog {
return;
}
JSONObject o = new JSONObject();
o.put(World.JKEYS.ASSET_TYPE, type);
o.put(GodWorld.JKEYS.ASSET_TYPE, type);
AssetEditorDialog.runDialog(this, worldadm, o, null);
assetListPanel.reload();
@ -185,7 +184,7 @@ public class AssetListDialog extends EscDialog {
private void doneButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_doneButtonActionPerformed
dispose();
JSONObject o = worldadm.world.getJson();
JSONObject o = worldadm.getJson();
Globals.prefs.put("world", o.toString());
}//GEN-LAST:event_doneButtonActionPerformed
@ -205,7 +204,7 @@ public class AssetListDialog extends EscDialog {
private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteButtonActionPerformed
JSONObject o = assetListPanel.getSelectedObject();
JSONObject ass = Globals.getAssets();
ass.remove(o.getString(World.JKEYS.ASSET_SYMBOL));
ass.remove(o.getString(GodWorld.JKEYS.ASSET_SYMBOL));
Globals.putAssets(ass);
assetListPanel.reload();
}//GEN-LAST:event_deleteButtonActionPerformed

View File

@ -32,9 +32,9 @@ import java.util.logging.Logger;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import opensesim.world.AbstractAsset;
import opensesim.world.World;
import opensesim.world.RealWorld;
import opensesim.gui.Globals;
import opensesim.world.WorldAdm;
import opensesim.world.GodWorld;
import org.json.JSONObject;
/**
@ -43,7 +43,7 @@ import org.json.JSONObject;
*/
public class AssetListPanel extends javax.swing.JPanel implements GuiSelectionList {
WorldAdm worldadm;
GodWorld worldadm;
/**
* Creates new form AssetList
@ -63,7 +63,7 @@ public class AssetListPanel extends javax.swing.JPanel implements GuiSelectionLi
assetTable.getColumnModel().getColumn(2).setPreferredWidth(80);
}
public AssetListPanel(WorldAdm worldadm) {
public AssetListPanel(GodWorld worldadm) {
this();
this.worldadm = worldadm;
@ -74,13 +74,13 @@ public class AssetListPanel extends javax.swing.JPanel implements GuiSelectionLi
public JSONObject getSelectedObject() {
int row = assetTable.getSelectedRow();
String symbol = (String) assetTable.getValueAt(row, 0);
return worldadm.world.getAssetBySymbol(symbol).getJson();
return worldadm.getAssetBySymbol(symbol).getJson();
}
final void reload() {
Collection<AbstractAsset> assets;
assets = worldadm.world.getAssetCollection();
assets = worldadm.getAssetCollection();
DefaultTableModel m = (DefaultTableModel) assetTable.getModel();
m.setRowCount(0);
for (AbstractAsset asset : assets) {
@ -94,7 +94,7 @@ public class AssetListPanel extends javax.swing.JPanel implements GuiSelectionLi
String type_name;
try {
type_name = a.getConstructor(World.class, JSONObject.class).newInstance(null, null).getTypeName();
type_name = a.getConstructor(GodWorld.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);

View File

@ -36,7 +36,8 @@ import javax.swing.DefaultComboBoxModel;
import opensesim.world.AbstractAsset;
import opensesim.gui.Globals;
import opensesim.gui.util.EscDialog;
import opensesim.world.World;
import opensesim.world.GodWorld;
import opensesim.world.RealWorld;
import org.json.JSONObject;
/**
@ -45,7 +46,8 @@ import org.json.JSONObject;
*/
public class SelectAssetTypeDialog extends EscDialog {
ArrayList<Class<AbstractAsset>>asset_types;
ArrayList<Class<AbstractAsset>> asset_types;
/**
* Creates new form SelectAssetTypeDialog
*/
@ -64,22 +66,16 @@ public class SelectAssetTypeDialog extends EscDialog {
Class<AbstractAsset> asset_type = asset_types.get(i);
System.out.printf("ACL: %s\n", asset_type.getName());
try {
Constructor<AbstractAsset> c;
c = asset_type.getConstructor(World.class,JSONObject.class);
ait = c.newInstance(null,null);
//ait = asset_type.getConstructor<AbstractAsset>(World.class,JSONObject.class).
vector.add(i, ait.getTypeName());
} catch (InstantiationException | IllegalAccessException | ClassCastException ex) {
Logger.getLogger(AssetEditorPanel.class.getName()).log(Level.SEVERE, null, ex);
} catch (NoSuchMethodException | SecurityException | IllegalArgumentException | InvocationTargetException ex) {
Logger.getLogger(SelectAssetTypeDialog.class.getName()).log(Level.SEVERE, null, ex);
String tn = GodWorld.getTypeName(asset_type);
if (tn == null) {
continue;
}
vector.add(i, tn);
}
return new DefaultComboBoxModel(vector.toArray());
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
@ -151,7 +147,7 @@ public class SelectAssetTypeDialog extends EscDialog {
}// </editor-fold>//GEN-END:initComponents
String selected = null;
private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
int i = this.assetTypeComboBox.getSelectedIndex();
selected = asset_types.get(i).getName();
@ -162,15 +158,14 @@ public class SelectAssetTypeDialog extends EscDialog {
dispose();
}//GEN-LAST:event_cancelButtonActionPerformed
public static String runDialog(Window parent){
public static String runDialog(Window parent) {
SelectAssetTypeDialog dialog;
dialog = new SelectAssetTypeDialog(parent,true);
dialog = new SelectAssetTypeDialog(parent, true);
dialog.setLocationRelativeTo(parent);
dialog.setVisible(true);
return dialog.selected;
}
/**
* @param args the command line arguments
*/

View File

@ -2,7 +2,7 @@ package opensesim.gui.AssetPairEditor;
import java.util.Collection;
import opensesim.world.AbstractAsset;
import opensesim.world.World;
import opensesim.world.RealWorld;
import opensesim.gui.Globals;
/*
@ -37,7 +37,7 @@ import opensesim.gui.Globals;
*/
public class EditAssetPairPanel extends javax.swing.JPanel {
World world;
RealWorld world;
/**
* Creates new form EditAssetPairPanel
*/
@ -50,8 +50,8 @@ public class EditAssetPairPanel extends javax.swing.JPanel {
assetBox.removeAllItems();
currencyBox.removeAllItems();
Collection<AbstractAsset> ac = world.getAssetCollection();
for (AbstractAsset asset: ac ){
// Collection<AbstractAsset> ac = world.getAssetCollection();
/* for (AbstractAsset asset: ac ){
if (asset.isCurrency()){
this.currencyBox.addItem(asset.getSymbol());
}
@ -60,7 +60,7 @@ public class EditAssetPairPanel extends javax.swing.JPanel {
}
}
}
*/ }
/**
* This method is called from within the constructor to initialize the form.

View File

@ -25,7 +25,7 @@
*/
package opensesim.gui.AssetPairEditor;
import opensesim.world.World;
import opensesim.world.RealWorld;
import opensesim.gui.util.EscDialog;
import opensesim.gui.Globals;
@ -34,7 +34,7 @@ import opensesim.gui.Globals;
* @author tohe
*/
public class NewJDialog extends EscDialog /*javax.swing.JDialog*/ {
World world;
RealWorld world;
/**
* Creates new form NewJDialog

View File

@ -48,13 +48,14 @@ import javax.swing.JFrame;
import javax.swing.LookAndFeel;
import javax.swing.UIManager;
import opensesim.world.AbstractAsset;
import opensesim.world.World;
import opensesim.world.RealWorld;
import opensesim.gui.AssetEditor.AssetEditorPanel;
import org.json.JSONArray;
import org.json.JSONObject;
import opensesim.old_sesim.AutoTraderLoader;
import opensesim.old_sesim.IndicatorLoader;
import opensesim.util.XClassLoader.ClassCache;
import opensesim.world.GodWorld;
/**
*
@ -62,7 +63,7 @@ import opensesim.util.XClassLoader.ClassCache;
*/
public class Globals {
public static World world;
public static RealWorld world;
public static final String SESIM_FILEEXTENSION = "sesim";
public static final Double SESIM_FILEVERSION = 0.1;
@ -235,8 +236,8 @@ public class Globals {
try {
// a1 = o1.newInstance();
a1 = o1.getConstructor(World.class,JSONObject.class).newInstance(null,null);
a2 = o2.getConstructor(World.class,JSONObject.class).newInstance(null,null);
a1 = o1.getConstructor(RealWorld.class,JSONObject.class).newInstance(null,null);
a2 = o2.getConstructor(RealWorld.class,JSONObject.class).newInstance(null,null);
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException | SecurityException | IllegalArgumentException | InvocationTargetException ex) {
Logger.getLogger(AssetEditorPanel.class.getName()).log(Level.SEVERE, null, ex);
return 0;
@ -420,7 +421,7 @@ public class Globals {
public static void saveFile(File f) throws FileNotFoundException {
JSONObject sobj = new JSONObject();
/* JSONObject sobj = new JSONObject();
JSONArray traders = getTraders();
JSONObject strategies = getStrategies();
@ -428,7 +429,9 @@ public class Globals {
sobj.put(PrefKeys.SESIMVERSION, SESIM_FILEVERSION);
sobj.put(PrefKeys.STRATEGIES, strategies);
sobj.put(PrefKeys.TRADERS, traders);
*/
JSONObject sobj = Globals.getWorld();
PrintWriter out;
out = new PrintWriter(f.getAbsolutePath());
out.print(sobj.toString(4));
@ -469,8 +472,8 @@ public class Globals {
public static JSONObject getWorld() {
JSONObject cfg = new JSONObject();
cfg.put(World.JKEYS.ASSETS, getAssets());
cfg.put(World.JKEYS.EXCHANGES, getExchanges());
cfg.put(GodWorld.JKEYS.ASSETS, getAssets());
cfg.put(GodWorld.JKEYS.EXCHANGES, getExchanges());
return cfg;
}

View File

@ -26,8 +26,6 @@
package opensesim.gui;
import com.google.gson.Gson;
import opensesim.chart.Help;
import opensesim.chart.SuperDlg;
import java.awt.Dialog;
import java.awt.Frame;
import java.awt.GraphicsDevice;
@ -39,27 +37,14 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.prefs.Preferences;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.LookAndFeel;
import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER;
import javax.swing.UIManager;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileNameExtensionFilter;
import opensesim.gui.AssetPairEditor.NewJDialog;
import opensesim.gui.exchangeeditor.ExchangeEditorDialog;
import opensesim.gui.exchangeeditor.ExchangeListDialog;
import org.json.JSONArray;
import org.json.JSONObject;
@ -68,9 +53,7 @@ import opensesim.old_sesim.AutoTraderInterface;
import opensesim.old_sesim.Exchange;
import opensesim.old_sesim.Scheduler;
import opensesim.util.XClassLoader;
import opensesim.world.World;
import opensesim.world.WorldAdm;
import opensesim.world.GodWorld;
/**
*
@ -79,7 +62,7 @@ import opensesim.world.WorldAdm;
public class SeSimApplication extends javax.swing.JFrame {
WorldAdm worldadm;
GodWorld worldadm;
/**
* Creates new form NewMDIApplication
@ -93,7 +76,7 @@ public class SeSimApplication extends javax.swing.JFrame {
JSONObject cfg;
cfg = new JSONObject(Globals.prefs.get("world","{}"));
worldadm = new WorldAdm(cfg);
worldadm = new GodWorld(cfg);
@ -609,7 +592,7 @@ public class SeSimApplication extends javax.swing.JFrame {
void startSim() {
World world = new World(Globals.getWorld());
GodWorld world = new GodWorld(Globals.getWorld());
@ -985,7 +968,6 @@ public class SeSimApplication extends javax.swing.JFrame {
//opensesim.world.World.MasterApi mapi = new opensesim.world.World.MasterApi();

View File

@ -26,11 +26,12 @@
package opensesim.gui.exchangeeditor;
import opensesim.world.Exchange;
import opensesim.world.World;
import opensesim.world.RealWorld;
import opensesim.gui.Globals;
import opensesim.gui.util.Json.Export;
import opensesim.gui.util.Json.Import;
import opensesim.util.SeSimException;
import opensesim.world.GodWorld;
/**
*
@ -38,12 +39,12 @@ import opensesim.util.SeSimException;
*/
public class ExchangeEditorPanel extends javax.swing.JPanel {
World world;
GodWorld world=null;
/**
* Creates new form ExchangeEditorPanel
*/
public ExchangeEditorPanel() {
world = Globals.world;
//world = Globals.world;
initComponents();
}

View File

@ -27,7 +27,7 @@ package opensesim.gui.exchangeeditor;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import opensesim.world.World;
import opensesim.world.RealWorld;
import opensesim.gui.Globals;
import opensesim.world.Exchange;
import org.json.JSONObject;