diff --git a/src/opensesim/gui/Globals.java b/src/opensesim/gui/Globals.java index 58faeea..728e3f6 100644 --- a/src/opensesim/gui/Globals.java +++ b/src/opensesim/gui/Globals.java @@ -110,6 +110,7 @@ public class Globals { public static final String STRATEGIES = "strategies"; public static final String TRADERS = "traders"; public static final String ASSETS = "assets"; + public static final String EXCHANGES = "exchanges"; } @@ -345,6 +346,13 @@ public class Globals { prefs.put(PrefKeys.ASSETS, assets.toString()); } + static public final JSONObject getExchanges(){ + String json = prefs.get(PrefKeys.EXCHANGES, "{}"); + return new JSONObject(json); + } + static public final void putExchanges(JSONObject e){ + prefs.put(PrefKeys.EXCHANGES, e.toString()); + } static public final JSONArray getTraders() { diff --git a/src/opensesim/gui/exchangeeditor/ExchangeEditorDialog.java b/src/opensesim/gui/exchangeeditor/ExchangeEditorDialog.java index d287e4e..90bd205 100644 --- a/src/opensesim/gui/exchangeeditor/ExchangeEditorDialog.java +++ b/src/opensesim/gui/exchangeeditor/ExchangeEditorDialog.java @@ -30,8 +30,11 @@ import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JDialog; import javax.swing.JFrame; +import opensesim.gui.Globals; import opensesim.gui.util.EscDialog; +import opensesim.gui.util.Json; import opensesim.util.SeSimException; +import org.json.JSONObject; /** * @@ -47,11 +50,17 @@ public class ExchangeEditorDialog extends EscDialog { initComponents(); } - public static void runDialog(Dialog parent) { + public static void runDialog(Dialog parent, JSONObject e) { ExchangeEditorDialog dialog = new ExchangeEditorDialog(parent, true); dialog.setLocationRelativeTo(parent); dialog.setVisible(true); + JSONObject r = Json.get(dialog.exchangeEditorPanel1); + JSONObject ex = Globals.getExchanges(); + ex.put(r.getString("symbol"), r); + Globals.putExchanges(ex); + + /* try { dialog.exchangeEditorPanel1.saveData(); } catch (SeSimException ex) { @@ -60,7 +69,8 @@ public class ExchangeEditorDialog extends EscDialog { javax.swing.JOptionPane.ERROR_MESSAGE); } dialog.dispose(); - +*/ + } /** diff --git a/src/opensesim/gui/exchangeeditor/ExchangeEditorPanel.form b/src/opensesim/gui/exchangeeditor/ExchangeEditorPanel.form index d3b7368..989eb5d 100644 --- a/src/opensesim/gui/exchangeeditor/ExchangeEditorPanel.form +++ b/src/opensesim/gui/exchangeeditor/ExchangeEditorPanel.form @@ -1,6 +1,6 @@ -
diff --git a/src/opensesim/gui/exchangeeditor/ExchangeEditorPanel.java b/src/opensesim/gui/exchangeeditor/ExchangeEditorPanel.java index a007f47..99762af 100644 --- a/src/opensesim/gui/exchangeeditor/ExchangeEditorPanel.java +++ b/src/opensesim/gui/exchangeeditor/ExchangeEditorPanel.java @@ -28,6 +28,8 @@ package opensesim.gui.exchangeeditor; import opensesim.Exchange; import opensesim.World; import opensesim.gui.Globals; +import opensesim.gui.util.Json.Export; +import opensesim.gui.util.Json.Import; import opensesim.util.SeSimException; /** @@ -80,8 +82,9 @@ public class ExchangeEditorPanel extends javax.swing.JPanel { .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(nameField, javax.swing.GroupLayout.DEFAULT_SIZE, 214, Short.MAX_VALUE) - .addComponent(symField, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) + .addComponent(symField, javax.swing.GroupLayout.DEFAULT_SIZE, 202, Short.MAX_VALUE) + .addComponent(nameField)) + .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -102,7 +105,11 @@ public class ExchangeEditorPanel extends javax.swing.JPanel { // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; - private javax.swing.JTextField nameField; - private opensesim.gui.util.JTextFieldLimit symField; + @Import("name") + @Export("name") + public javax.swing.JTextField nameField; + @Export("symbol") + @Import("name") + public opensesim.gui.util.JTextFieldLimit symField; // End of variables declaration//GEN-END:variables } diff --git a/src/opensesim/gui/exchangeeditor/ExchangeListDialog.form b/src/opensesim/gui/exchangeeditor/ExchangeListDialog.form index e1c70c0..f6f0368 100644 --- a/src/opensesim/gui/exchangeeditor/ExchangeListDialog.form +++ b/src/opensesim/gui/exchangeeditor/ExchangeListDialog.form @@ -3,6 +3,7 @@ diff --git a/src/opensesim/gui/exchangeeditor/ExchangeListDialog.java b/src/opensesim/gui/exchangeeditor/ExchangeListDialog.java index 4f9848b..4cf7378 100644 --- a/src/opensesim/gui/exchangeeditor/ExchangeListDialog.java +++ b/src/opensesim/gui/exchangeeditor/ExchangeListDialog.java @@ -27,15 +27,13 @@ package opensesim.gui.exchangeeditor; import java.awt.Dialog; import java.awt.Window; -import javax.swing.JFrame; import opensesim.gui.util.EscDialog; -import opensesim.util.SeSimException; /** * * @author 7u83 <7u83@mail.ru> */ -public class ExchangeListDialog extends EscDialog { +public class ExchangeListDialog extends EscDialog { /** * Creates new form ExchangeListDialog @@ -45,21 +43,22 @@ public class ExchangeListDialog extends EscDialog { initComponents(); } - public static void runDialog(Window parent) { + public static void runDialog(Window parent) { ExchangeListDialog dialog = new ExchangeListDialog(parent, true); dialog.setLocationRelativeTo(parent); dialog.setVisible(true); -/* try { + /* try { dialog.exchangeListPanel1. } catch (SeSimException ex) { javax.swing.JOptionPane.showMessageDialog(parent, ex.getMessage(), "Error Hello", javax.swing.JOptionPane.ERROR_MESSAGE); } -*/ dialog.dispose(); + */ dialog.dispose(); } + /** * 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 @@ -69,11 +68,12 @@ public class ExchangeListDialog extends EscDialog { //