From c6c5ed2931d133d51f258a18fce9b97831753bec Mon Sep 17 00:00:00 2001
From: 7u83 <7u83@maiol.ru>
Date: Sat, 28 Jan 2017 15:34:24 +0100
Subject: [PATCH] More work on Strategy editor
---
pom.xml | 5 +
.../Clock.form} | 24 +--
.../Clock.java} | 24 +--
src/main/java/gui/EditPreferencesDialog.form | 16 +-
src/main/java/gui/EditPreferencesDialog.java | 82 +++++---
...ingStrategies.form => EditStrategies.form} | 41 ++--
...ingStrategies.java => EditStrategies.java} | 120 ++++++++----
src/main/java/gui/Globals.java | 2 +
src/main/java/gui/LoggerDialog.form | 53 ++++++
src/main/java/gui/LoggerDialog.java | 156 +++++++++++++++
src/main/java/gui/MainWin.java | 4 +-
src/main/java/gui/NewMDIApplication.form | 42 ++++-
src/main/java/gui/NewMDIApplication.java | 82 +++++---
src/main/java/sesim/AutoTraderConfig.java | 6 +-
src/main/java/sesim/AutoTraderGui.java | 39 ++++
src/main/java/sesim/AutoTraderLoader.java | 6 +-
src/main/java/traders/RandomTrader.java | 8 +-
src/main/java/traders/RandomTraderConfig.java | 57 ++++--
src/main/java/traders/RandomTraderGui.form | 126 +++++++++++++
src/main/java/traders/RandomTraderGui.java | 177 ++++++++++++++++++
src/main/java/traders/SuperTraderConfig.java | 11 +-
.../java/traders/SwitchingTraderConfig.java | 19 +-
22 files changed, 927 insertions(+), 173 deletions(-)
rename src/main/java/{traders/RandomTraderConfigForm.form => gui/Clock.form} (50%)
rename src/main/java/{traders/RandomTraderConfigForm.java => gui/Clock.java} (67%)
rename src/main/java/gui/{EditTradingStrategies.form => EditStrategies.form} (76%)
rename src/main/java/gui/{EditTradingStrategies.java => EditStrategies.java} (63%)
create mode 100644 src/main/java/gui/LoggerDialog.form
create mode 100644 src/main/java/gui/LoggerDialog.java
create mode 100644 src/main/java/sesim/AutoTraderGui.java
create mode 100644 src/main/java/traders/RandomTraderGui.form
create mode 100644 src/main/java/traders/RandomTraderGui.java
diff --git a/pom.xml b/pom.xml
index 9d7de6a..d675def 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,6 +23,11 @@
json
20160810
+
+ org.jdesktop
+ beansbinding
+ 1.2.1
+
UTF-8
diff --git a/src/main/java/traders/RandomTraderConfigForm.form b/src/main/java/gui/Clock.form
similarity index 50%
rename from src/main/java/traders/RandomTraderConfigForm.form
rename to src/main/java/gui/Clock.form
index 956ad9d..d15c158 100644
--- a/src/main/java/traders/RandomTraderConfigForm.form
+++ b/src/main/java/gui/Clock.form
@@ -1,6 +1,6 @@
-
diff --git a/src/main/java/traders/RandomTraderConfigForm.java b/src/main/java/gui/Clock.java
similarity index 67%
rename from src/main/java/traders/RandomTraderConfigForm.java
rename to src/main/java/gui/Clock.java
index 3065e0d..f986f64 100644
--- a/src/main/java/traders/RandomTraderConfigForm.java
+++ b/src/main/java/gui/Clock.java
@@ -23,18 +23,18 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
-package traders;
+package gui;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
-public class RandomTraderConfigForm extends javax.swing.JPanel {
+public class Clock extends javax.swing.JPanel {
/**
- * Creates new form RandomTraderConfigForm
+ * Creates new form Clock
*/
- public RandomTraderConfigForm() {
+ public Clock() {
initComponents();
}
@@ -47,31 +47,19 @@ public class RandomTraderConfigForm extends javax.swing.JPanel {
// //GEN-BEGIN:initComponents
private void initComponents() {
- jFormattedTextField1 = new javax.swing.JFormattedTextField();
-
- jFormattedTextField1.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0.00%"))));
- jFormattedTextField1.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
-
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(115, 115, 115)
- .addComponent(jFormattedTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap(197, Short.MAX_VALUE))
+ .addGap(0, 400, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(24, 24, 24)
- .addComponent(jFormattedTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap(249, Short.MAX_VALUE))
+ .addGap(0, 300, Short.MAX_VALUE)
);
}// //GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JFormattedTextField jFormattedTextField1;
// End of variables declaration//GEN-END:variables
}
diff --git a/src/main/java/gui/EditPreferencesDialog.form b/src/main/java/gui/EditPreferencesDialog.form
index ece4945..2dedc74 100644
--- a/src/main/java/gui/EditPreferencesDialog.form
+++ b/src/main/java/gui/EditPreferencesDialog.form
@@ -39,6 +39,10 @@
+
+
+
+
@@ -52,7 +56,9 @@
-
+
+
+
@@ -114,5 +120,13 @@
+
+
+
+
+
+
+
+
diff --git a/src/main/java/gui/EditPreferencesDialog.java b/src/main/java/gui/EditPreferencesDialog.java
index 2f7da64..40e7561 100644
--- a/src/main/java/gui/EditPreferencesDialog.java
+++ b/src/main/java/gui/EditPreferencesDialog.java
@@ -27,8 +27,12 @@ package gui;
import java.awt.Frame;
import java.awt.Window;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.LookAndFeel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
/**
*
@@ -38,20 +42,25 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
UIManager.LookAndFeelInfo[] lafInfo;
+ LookAndFeel old_laf;
+ LookAndFeel new_laf;
+
/**
* Creates new form EditPreferencesDialog
*/
public EditPreferencesDialog(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
- this.setLocationRelativeTo(MainWin.instance);
-
+ this.setLocationRelativeTo(this.getParent());
+
+ old_laf = UIManager.getLookAndFeel();
+
+
lafInfo = UIManager.getInstalledLookAndFeels();
lafComboBox.removeAllItems();
for (UIManager.LookAndFeelInfo lafInfo1 : lafInfo) {
lafComboBox.addItem(lafInfo1.getName());
}
-
lafComboBox.setSelectedItem(Globals.prefs.get("laf", "Nimbus"));
}
@@ -69,6 +78,7 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
cancelButton = new javax.swing.JButton();
applyButton = new javax.swing.JButton();
okButton = new javax.swing.JButton();
+ jCheckBox1 = new javax.swing.JCheckBox();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
@@ -105,6 +115,13 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
}
});
+ jCheckBox1.setText("Development Traders");
+ jCheckBox1.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jCheckBox1ActionPerformed(evt);
+ }
+ });
+
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
@@ -122,7 +139,10 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(applyButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(cancelButton)))
+ .addComponent(cancelButton))
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(jCheckBox1)
+ .addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);
layout.setVerticalGroup(
@@ -132,7 +152,9 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lafComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lafLabel))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 236, Short.MAX_VALUE)
+ .addGap(18, 18, 18)
+ .addComponent(jCheckBox1)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 200, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cancelButton)
.addComponent(applyButton)
@@ -148,37 +170,34 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
}//GEN-LAST:event_lafComboBoxActionPerformed
private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
+ if (old_laf!=new_laf){
+ try {
+ UIManager.setLookAndFeel(old_laf);
+ } catch (UnsupportedLookAndFeelException ex) {
+ Logger.getLogger(EditPreferencesDialog.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ resetUI();
+ }
this.dispose();
}//GEN-LAST:event_cancelButtonActionPerformed
- private void applyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_applyButtonActionPerformed
- String selected = (String) this.lafComboBox.getSelectedItem();
-
- System.out.printf("Selected %s\n", selected);
-
- Globals.setLookAndFeel(selected);
-
-
- /*
- for (UIManager.LookAndFeelInfo lafInfo1 : this.lafInfo) {
- if (lafInfo1.getName().equals(selected)) {
- String lafClassName = lafInfo1.getClassName();
- try {
- UIManager.setLookAndFeel(lafClassName);
- break;
- } catch (Exception e) {
-
- }
- }
- }
- */
-
- for (Window w : Window.getWindows()) {
+ void resetUI(){
+ for (Window w : Window.getWindows()) {
System.out.print("Setting frame\n");
SwingUtilities.updateComponentTreeUI(w);
w.pack();
+ }
+ }
+
+ private void applyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_applyButtonActionPerformed
+
+ String selected = (String) this.lafComboBox.getSelectedItem();
+
+
+ Globals.setLookAndFeel(selected);
+ new_laf=UIManager.getLookAndFeel();
+ resetUI();
- }
}//GEN-LAST:event_applyButtonActionPerformed
private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
@@ -188,6 +207,10 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
this.dispose();
}//GEN-LAST:event_okButtonActionPerformed
+ private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed
+ // TODO add your handling code here:
+ }//GEN-LAST:event_jCheckBox1ActionPerformed
+
/**
* @param args the command line arguments
*/
@@ -233,6 +256,7 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton applyButton;
private javax.swing.JButton cancelButton;
+ private javax.swing.JCheckBox jCheckBox1;
private javax.swing.JComboBox lafComboBox;
private javax.swing.JLabel lafLabel;
private javax.swing.JButton okButton;
diff --git a/src/main/java/gui/EditTradingStrategies.form b/src/main/java/gui/EditStrategies.form
similarity index 76%
rename from src/main/java/gui/EditTradingStrategies.form
rename to src/main/java/gui/EditStrategies.form
index 1b58a6d..696c399 100644
--- a/src/main/java/gui/EditTradingStrategies.form
+++ b/src/main/java/gui/EditStrategies.form
@@ -30,8 +30,12 @@
-
-
+
+
+
+
+
+
@@ -43,18 +47,21 @@
-
+
-
+
+
+
+
-
+
@@ -66,17 +73,12 @@
-
+
-
-
-
-
-
@@ -102,8 +104,8 @@
-
-
+
+
@@ -119,5 +121,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/java/gui/EditTradingStrategies.java b/src/main/java/gui/EditStrategies.java
similarity index 63%
rename from src/main/java/gui/EditTradingStrategies.java
rename to src/main/java/gui/EditStrategies.java
index dab46bc..d4fb7b5 100644
--- a/src/main/java/gui/EditTradingStrategies.java
+++ b/src/main/java/gui/EditStrategies.java
@@ -26,26 +26,32 @@
package gui;
import java.util.ArrayList;
+import java.util.logging.Logger;
import javax.swing.JPanel;
+import org.json.JSONArray;
+import org.json.JSONObject;
+import sesim.AutoTrader;
import sesim.AutoTraderConfig;
+import sesim.AutoTraderGui;
/**
*
* @author 7u83 <7u83@mail.ru>
*/
-public class EditTradingStrategies extends javax.swing.JDialog {
+public class EditStrategies extends javax.swing.JDialog {
/**
* Creates new form EditTradingStrategies
*/
- public EditTradingStrategies(java.awt.Frame parent, boolean modal) {
+ public EditStrategies(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
+ this.setLocationRelativeTo(this.getParent());
- this.jComboBox1.removeAllItems();
+ this.jComboBoxStrategySelector.removeAllItems();
ArrayList sn = Globals.tloader.getDefaultStrategyNames();
for (int i = 0; i < sn.size(); i++) {
- this.jComboBox1.addItem(sn.get(i));
+ this.jComboBoxStrategySelector.addItem(sn.get(i));
}
@@ -55,6 +61,23 @@ public class EditTradingStrategies extends javax.swing.JDialog {
ArrayList> s = Globals.tloader.getTraders();
}
+
+
+ JSONArray loadStrategyConfigs(){
+
+ ArrayList sn = Globals.tloader.getDefaultStrategyNames();
+
+
+ String cfglist = Globals.prefs.get("StrategyCFG", "[]");
+ JSONArray cfgs = new JSONArray(cfglist);
+
+ Logger.getGlobal().info(cfglist);
+
+
+
+
+ return cfgs;
+ }
/**
* This method is called from within the constructor to initialize the form.
@@ -65,23 +88,22 @@ public class EditTradingStrategies extends javax.swing.JDialog {
// //GEN-BEGIN:initComponents
private void initComponents() {
- jComboBox1 = new javax.swing.JComboBox<>();
- jToggleButton1 = new javax.swing.JToggleButton();
+ jComboBoxStrategySelector = new javax.swing.JComboBox<>();
guiPanel = new javax.swing.JPanel();
defaultGuiPanel = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
+ jButton1 = new javax.swing.JButton();
+ jButton2 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
- jComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
- jComboBox1.addActionListener(new java.awt.event.ActionListener() {
+ jComboBoxStrategySelector.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
+ jComboBoxStrategySelector.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
- jComboBox1ActionPerformed(evt);
+ jComboBoxStrategySelectorActionPerformed(evt);
}
});
- jToggleButton1.setText("jToggleButton1");
-
guiPanel.setLayout(new java.awt.BorderLayout());
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
@@ -100,12 +122,21 @@ public class EditTradingStrategies extends javax.swing.JDialog {
defaultGuiPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(defaultGuiPanelLayout.createSequentialGroup()
.addContainerGap()
- .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE)
- .addContainerGap())
+ .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 229, Short.MAX_VALUE)
+ .addGap(39, 39, 39))
);
guiPanel.add(defaultGuiPanel, java.awt.BorderLayout.CENTER);
+ jButton1.setText("Save");
+ jButton1.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jButton1ActionPerformed(evt);
+ }
+ });
+
+ jButton2.setText("Cancel");
+
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
@@ -117,48 +148,71 @@ public class EditTradingStrategies extends javax.swing.JDialog {
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jToggleButton1, javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(jComboBox1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 361, javax.swing.GroupLayout.PREFERRED_SIZE))))
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
+ .addComponent(jButton1)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jButton2))
+ .addComponent(jComboBoxStrategySelector, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 361, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
- .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(jComboBoxStrategySelector, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(guiPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jToggleButton1)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jButton1)
+ .addComponent(jButton2))
.addContainerGap())
);
pack();
}// //GEN-END:initComponents
- private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
- System.out.printf("Now Strategie Dialog to open\n");
- AutoTraderConfig ac = Globals.tloader.getStrategy((String) this.jComboBox1.getSelectedItem());
+
+ AutoTraderGui acgui;
+ AutoTraderConfig ac;
+
+ private void jComboBoxStrategySelectorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxStrategySelectorActionPerformed
+// System.out.printf("Now Strategie Dialog to open\n");
+ ac = Globals.tloader.getStrategy((String) this.jComboBoxStrategySelector.getSelectedItem());
if (ac == null) {
return;
}
- JPanel gui = ac.getGui();
+ acgui = ac.getGui();
guiPanel.removeAll();
- if (gui != null) {
+ if (acgui != null) {
// javax.swing.GroupLayout guil = (javax.swing.GroupLayout) this.guiPanel.getLayout();
- guiPanel.add(gui, java.awt.BorderLayout.CENTER);
+ guiPanel.add(acgui, java.awt.BorderLayout.CENTER);
// this.guiPanel;
- gui.setVisible(true);
+ acgui.setVisible(true);
} else {
guiPanel.add(this.defaultGuiPanel, java.awt.BorderLayout.CENTER);
}
this.revalidate();
System.out.printf("Setted the dings\n", "");
+ JSONObject jo = ac.getConfig();
+ if (jo != null) {
+ System.out.printf("%s\n", jo.toString(2));
+ }
+
+
+ AutoTrader at = ac.createTrader(Globals.se, jo, 100, 100);
+
this.repaint();
- }//GEN-LAST:event_jComboBox1ActionPerformed
+ }//GEN-LAST:event_jComboBoxStrategySelectorActionPerformed
+
+ private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
+ acgui.save();
+
+
+ }//GEN-LAST:event_jButton1ActionPerformed
/**
* @param args the command line arguments
@@ -177,20 +231,21 @@ public class EditTradingStrategies extends javax.swing.JDialog {
}
}
} catch (ClassNotFoundException ex) {
- java.util.logging.Logger.getLogger(EditTradingStrategies.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ java.util.logging.Logger.getLogger(EditStrategies.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
- java.util.logging.Logger.getLogger(EditTradingStrategies.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ java.util.logging.Logger.getLogger(EditStrategies.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
- java.util.logging.Logger.getLogger(EditTradingStrategies.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ java.util.logging.Logger.getLogger(EditStrategies.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
- java.util.logging.Logger.getLogger(EditTradingStrategies.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ java.util.logging.Logger.getLogger(EditStrategies.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//
+ //
/* Create and display the dialog */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
- EditTradingStrategies dialog = new EditTradingStrategies(new javax.swing.JFrame(), true);
+ EditStrategies dialog = new EditStrategies(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
@@ -205,8 +260,9 @@ public class EditTradingStrategies extends javax.swing.JDialog {
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel defaultGuiPanel;
private javax.swing.JPanel guiPanel;
- private javax.swing.JComboBox jComboBox1;
+ private javax.swing.JButton jButton1;
+ private javax.swing.JButton jButton2;
+ private javax.swing.JComboBox jComboBoxStrategySelector;
private javax.swing.JLabel jLabel1;
- private javax.swing.JToggleButton jToggleButton1;
// End of variables declaration//GEN-END:variables
}
diff --git a/src/main/java/gui/Globals.java b/src/main/java/gui/Globals.java
index 0f8f1dc..90586a9 100644
--- a/src/main/java/gui/Globals.java
+++ b/src/main/java/gui/Globals.java
@@ -26,6 +26,7 @@
package gui;
import chart.NewMDIApplication;
+import java.util.logging.Logger;
import java.util.prefs.Preferences;
import javax.swing.UIManager;
import sesim.AutoTraderLoader;
@@ -66,6 +67,7 @@ public class Globals {
static AutoTraderLoader tloader=new AutoTraderLoader();
+ static final Logger LOGGER = Logger.getLogger("com.cauwersin.sesim");
}
diff --git a/src/main/java/gui/LoggerDialog.form b/src/main/java/gui/LoggerDialog.form
new file mode 100644
index 0000000..f59d060
--- /dev/null
+++ b/src/main/java/gui/LoggerDialog.form
@@ -0,0 +1,53 @@
+
+
+
diff --git a/src/main/java/gui/LoggerDialog.java b/src/main/java/gui/LoggerDialog.java
new file mode 100644
index 0000000..941cf3d
--- /dev/null
+++ b/src/main/java/gui/LoggerDialog.java
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 2017, 7u83 <7u83@mail.ru>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+package gui;
+
+import java.util.logging.Handler;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author 7u83 <7u83@mail.ru>
+ */
+public class LoggerDialog extends javax.swing.JDialog {
+
+ /**
+ * Creates new form LoggerDialog
+ */
+ public LoggerDialog(java.awt.Frame parent, boolean modal) {
+ super(parent, modal);
+ initComponents();
+
+ this.setTitle("Logger Window");
+
+ class LogHandler extends Handler {
+
+ @Override
+ public void publish(LogRecord record) {
+ String str = record.getMessage();
+ logArea.append(str);
+ logArea.append("\n");
+
+ // System.out.printf("SRTR WAS: %s",str);
+ return;
+ }
+
+ @Override
+ public void flush() {
+ return;
+ }
+
+ @Override
+ public void close() throws SecurityException {
+ return;
+ }
+
+ }
+ LogHandler handler = new LogHandler();
+ Globals.LOGGER.addHandler(handler);
+
+
+
+ }
+
+ /**
+ * 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
+ * regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // //GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ jScrollPane1 = new javax.swing.JScrollPane();
+ logArea = new javax.swing.JTextArea();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+
+ logArea.setEditable(false);
+ logArea.setColumns(20);
+ logArea.setRows(5);
+ jScrollPane1.setViewportView(logArea);
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
+ );
+
+ pack();
+ }// //GEN-END:initComponents
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String args[]) {
+ /* Set the Nimbus look and feel */
+ //
+ /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
+ * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
+ */
+ try {
+ for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
+ if ("Nimbus".equals(info.getName())) {
+ javax.swing.UIManager.setLookAndFeel(info.getClassName());
+ break;
+ }
+ }
+ } catch (ClassNotFoundException ex) {
+ java.util.logging.Logger.getLogger(LoggerDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ } catch (InstantiationException ex) {
+ java.util.logging.Logger.getLogger(LoggerDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ } catch (IllegalAccessException ex) {
+ java.util.logging.Logger.getLogger(LoggerDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ } catch (javax.swing.UnsupportedLookAndFeelException ex) {
+ java.util.logging.Logger.getLogger(LoggerDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ }
+ //
+
+ /* Create and display the dialog */
+ java.awt.EventQueue.invokeLater(new Runnable() {
+ public void run() {
+ LoggerDialog dialog = new LoggerDialog(new javax.swing.JFrame(), true);
+ dialog.addWindowListener(new java.awt.event.WindowAdapter() {
+ @Override
+ public void windowClosing(java.awt.event.WindowEvent e) {
+ System.exit(0);
+ }
+ });
+ dialog.setVisible(true);
+ }
+ });
+ }
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JScrollPane jScrollPane1;
+ private javax.swing.JTextArea logArea;
+ // End of variables declaration//GEN-END:variables
+}
diff --git a/src/main/java/gui/MainWin.java b/src/main/java/gui/MainWin.java
index 8b57b24..3b06746 100644
--- a/src/main/java/gui/MainWin.java
+++ b/src/main/java/gui/MainWin.java
@@ -246,7 +246,7 @@ public class MainWin extends javax.swing.JFrame {
// rcfg1.sell_limit[0]=-1;
// rcfg1.sell_limit[1]=1;
- AutoTrader rt1 = rcfg1.createTrader(Globals.se, 1000000, 1000000);
+ AutoTrader rt1 = rcfg1.createTrader(Globals.se, null, 1000000, 1000000);
Globals.se.traders.add(rt1);
rt1.setName("Alice");
rt1.start();
@@ -260,7 +260,7 @@ public class MainWin extends javax.swing.JFrame {
RandomTraderConfig cfg= new RandomTraderConfig();
for (int i=0; i<30; i++){
- AutoTrader randt = cfg.createTrader(Globals.se, 100000, 100000);
+ AutoTrader randt = cfg.createTrader(Globals.se,null, 100000, 100000);
Globals.se.traders.add(randt);
randt.setName("Bob");
diff --git a/src/main/java/gui/NewMDIApplication.form b/src/main/java/gui/NewMDIApplication.form
index 8501571..15965be 100644
--- a/src/main/java/gui/NewMDIApplication.form
+++ b/src/main/java/gui/NewMDIApplication.form
@@ -2,6 +2,22 @@
+
+
+