Trader liste menu works now fine
This commit is contained in:
parent
cf8f6b584e
commit
a4d781d154
@ -202,12 +202,13 @@
|
|||||||
<Property name="text" type="java.lang.String" value="View"/>
|
<Property name="text" type="java.lang.String" value="View"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
<SubComponents>
|
<SubComponents>
|
||||||
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem2">
|
<MenuItem class="javax.swing.JCheckBoxMenuItem" name="viewTraderListCheckBox">
|
||||||
<Properties>
|
<Properties>
|
||||||
|
<Property name="mnemonic" type="int" value="116"/>
|
||||||
<Property name="text" type="java.lang.String" value="Traders"/>
|
<Property name="text" type="java.lang.String" value="Traders"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
<Events>
|
<Events>
|
||||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem2ActionPerformed"/>
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="viewTraderListCheckBoxActionPerformed"/>
|
||||||
</Events>
|
</Events>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem class="javax.swing.JMenuItem" name="viewClock">
|
<MenuItem class="javax.swing.JMenuItem" name="viewClock">
|
||||||
@ -228,21 +229,12 @@
|
|||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem class="javax.swing.JCheckBoxMenuItem" name="jCheckBoxMenuItem1">
|
<MenuItem class="javax.swing.JCheckBoxMenuItem" name="jCheckBoxMenuItem1">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="selected" type="boolean" value="true"/>
|
<Property name="text" type="java.lang.String" value="Orderbook"/>
|
||||||
<Property name="text" type="java.lang.String" value="jCheckBoxMenuItem1"/>
|
|
||||||
</Properties>
|
</Properties>
|
||||||
<Events>
|
<Events>
|
||||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jCheckBoxMenuItem1ActionPerformed"/>
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jCheckBoxMenuItem1ActionPerformed"/>
|
||||||
</Events>
|
</Events>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem class="javax.swing.JCheckBoxMenuItem" name="viewTraderListCheckBox">
|
|
||||||
<Properties>
|
|
||||||
<Property name="text" type="java.lang.String" value="Traders"/>
|
|
||||||
</Properties>
|
|
||||||
<Events>
|
|
||||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="viewTraderListCheckBoxActionPerformed"/>
|
|
||||||
</Events>
|
|
||||||
</MenuItem>
|
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
</Menu>
|
</Menu>
|
||||||
<Menu class="javax.swing.JMenu" name="helpMenu">
|
<Menu class="javax.swing.JMenu" name="helpMenu">
|
||||||
|
@ -27,6 +27,9 @@ package gui;
|
|||||||
|
|
||||||
import java.awt.Dialog;
|
import java.awt.Dialog;
|
||||||
import java.awt.Frame;
|
import java.awt.Frame;
|
||||||
|
import java.awt.event.WindowAdapter;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
|
import java.awt.event.WindowListener;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -68,25 +71,21 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
System.out.printf("!!!! creating new\n");
|
System.out.printf("!!!! creating new\n");
|
||||||
String base = cfg.getString("base");
|
String base = cfg.getString("base");
|
||||||
AutoTraderInterface ac = Globals.tloader.getStrategyBase(base);
|
AutoTraderInterface ac = Globals.tloader.getStrategyBase(base);
|
||||||
if (ac==null)
|
if (ac == null) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
ac.putConfig(cfg);
|
ac.putConfig(cfg);
|
||||||
ac.init(se, id, name, money, shares, cfg);
|
ac.init(se, id, name, money, shares, cfg);
|
||||||
|
|
||||||
return ac;
|
return ac;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void startTraders() {
|
public void startTraders() {
|
||||||
|
|
||||||
WaitBox wb = new WaitBox();
|
WaitBox wb = new WaitBox();
|
||||||
|
|
||||||
|
|
||||||
// Globals.se.setMoneyDecimals(8);
|
// Globals.se.setMoneyDecimals(8);
|
||||||
// Globals.se.setSharesDecimals(0);
|
// Globals.se.setSharesDecimals(0);
|
||||||
|
|
||||||
JSONArray tlist = Globals.getTraders();
|
JSONArray tlist = Globals.getTraders();
|
||||||
|
|
||||||
Double moneyTotal = 0.0;
|
Double moneyTotal = 0.0;
|
||||||
@ -118,10 +117,8 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
System.out.printf("shoudl create new\n");
|
System.out.printf("shoudl create new\n");
|
||||||
trader = this.createTraderNew(Globals.se, id, t.getString("Name") + i1, money, shares, strategy);
|
trader = this.createTraderNew(Globals.se, id, t.getString("Name") + i1, money, shares, strategy);
|
||||||
|
|
||||||
|
|
||||||
Globals.se.traders.add(trader);
|
Globals.se.traders.add(trader);
|
||||||
|
|
||||||
|
|
||||||
moneyTotal += money;
|
moneyTotal += money;
|
||||||
sharesTotal += shares;
|
sharesTotal += shares;
|
||||||
|
|
||||||
@ -188,11 +185,10 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
jMenuItem4 = new javax.swing.JMenuItem();
|
jMenuItem4 = new javax.swing.JMenuItem();
|
||||||
jMenuItem5 = new javax.swing.JMenuItem();
|
jMenuItem5 = new javax.swing.JMenuItem();
|
||||||
viewMenu = new javax.swing.JMenu();
|
viewMenu = new javax.swing.JMenu();
|
||||||
jMenuItem2 = new javax.swing.JMenuItem();
|
viewTraderListCheckBox = new javax.swing.JCheckBoxMenuItem();
|
||||||
viewClock = new javax.swing.JMenuItem();
|
viewClock = new javax.swing.JMenuItem();
|
||||||
jMenuItem3 = new javax.swing.JMenuItem();
|
jMenuItem3 = new javax.swing.JMenuItem();
|
||||||
jCheckBoxMenuItem1 = new javax.swing.JCheckBoxMenuItem();
|
jCheckBoxMenuItem1 = new javax.swing.JCheckBoxMenuItem();
|
||||||
viewTraderListCheckBox = new javax.swing.JCheckBoxMenuItem();
|
|
||||||
helpMenu = new javax.swing.JMenu();
|
helpMenu = new javax.swing.JMenu();
|
||||||
contentMenuItem = new javax.swing.JMenuItem();
|
contentMenuItem = new javax.swing.JMenuItem();
|
||||||
aboutMenuItem = new javax.swing.JMenuItem();
|
aboutMenuItem = new javax.swing.JMenuItem();
|
||||||
@ -456,13 +452,14 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
viewMenu.setMnemonic('v');
|
viewMenu.setMnemonic('v');
|
||||||
viewMenu.setText("View");
|
viewMenu.setText("View");
|
||||||
|
|
||||||
jMenuItem2.setText("Traders");
|
viewTraderListCheckBox.setMnemonic('t');
|
||||||
jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
|
viewTraderListCheckBox.setText("Traders");
|
||||||
|
viewTraderListCheckBox.addActionListener(new java.awt.event.ActionListener() {
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
jMenuItem2ActionPerformed(evt);
|
viewTraderListCheckBoxActionPerformed(evt);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
viewMenu.add(jMenuItem2);
|
viewMenu.add(viewTraderListCheckBox);
|
||||||
|
|
||||||
viewClock.setText("Clock");
|
viewClock.setText("Clock");
|
||||||
viewClock.addActionListener(new java.awt.event.ActionListener() {
|
viewClock.addActionListener(new java.awt.event.ActionListener() {
|
||||||
@ -480,8 +477,7 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
});
|
});
|
||||||
viewMenu.add(jMenuItem3);
|
viewMenu.add(jMenuItem3);
|
||||||
|
|
||||||
jCheckBoxMenuItem1.setSelected(true);
|
jCheckBoxMenuItem1.setText("Orderbook");
|
||||||
jCheckBoxMenuItem1.setText("jCheckBoxMenuItem1");
|
|
||||||
jCheckBoxMenuItem1.addActionListener(new java.awt.event.ActionListener() {
|
jCheckBoxMenuItem1.addActionListener(new java.awt.event.ActionListener() {
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
jCheckBoxMenuItem1ActionPerformed(evt);
|
jCheckBoxMenuItem1ActionPerformed(evt);
|
||||||
@ -489,14 +485,6 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
});
|
});
|
||||||
viewMenu.add(jCheckBoxMenuItem1);
|
viewMenu.add(jCheckBoxMenuItem1);
|
||||||
|
|
||||||
viewTraderListCheckBox.setText("Traders");
|
|
||||||
viewTraderListCheckBox.addActionListener(new java.awt.event.ActionListener() {
|
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
||||||
viewTraderListCheckBoxActionPerformed(evt);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
viewMenu.add(viewTraderListCheckBox);
|
|
||||||
|
|
||||||
menuBar.add(viewMenu);
|
menuBar.add(viewMenu);
|
||||||
|
|
||||||
helpMenu.setMnemonic('h');
|
helpMenu.setMnemonic('h');
|
||||||
@ -538,8 +526,6 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
|
|
||||||
void startSim() {
|
void startSim() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resetSim();
|
resetSim();
|
||||||
JSONObject jo = new JSONObject(Globals.prefs.get("Exchange", "{}"));
|
JSONObject jo = new JSONObject(Globals.prefs.get("Exchange", "{}"));
|
||||||
Globals.se.putConfig(jo);
|
Globals.se.putConfig(jo);
|
||||||
@ -557,7 +543,6 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
Globals.se.timer.start();
|
Globals.se.timer.start();
|
||||||
Globals.se.timer.setAcceleration((Double) this.accelSpinner.getValue());
|
Globals.se.timer.setAcceleration((Double) this.accelSpinner.getValue());
|
||||||
|
|
||||||
|
|
||||||
Scheduler.TimerTask tt = new Scheduler.TimerTask() {
|
Scheduler.TimerTask tt = new Scheduler.TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public long timerTask() {
|
public long timerTask() {
|
||||||
@ -574,7 +559,6 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
};
|
};
|
||||||
// Globals.se.timer.startTimerTask(tt, 0);
|
// Globals.se.timer.startTimerTask(tt, 0);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void stopSim() {
|
void stopSim() {
|
||||||
@ -602,12 +586,6 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
}//GEN-LAST:event_editPreferencesActionPerformed
|
}//GEN-LAST:event_editPreferencesActionPerformed
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
|
|
||||||
TraderListDialog d = new TraderListDialog(this, false);
|
|
||||||
d.setVisible(rootPaneCheckingEnabled);
|
|
||||||
}//GEN-LAST:event_jMenuItem2ActionPerformed
|
|
||||||
|
|
||||||
private void deleteMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteMenuItemActionPerformed
|
private void deleteMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteMenuItemActionPerformed
|
||||||
EditAutoTraderListDialog ed = new EditAutoTraderListDialog(this, true);
|
EditAutoTraderListDialog ed = new EditAutoTraderListDialog(this, true);
|
||||||
ed.setVisible(rootPaneCheckingEnabled);
|
ed.setVisible(rootPaneCheckingEnabled);
|
||||||
@ -718,21 +696,27 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
Globals.se.pointZero();
|
Globals.se.pointZero();
|
||||||
}//GEN-LAST:event_jMenuItem4ActionPerformed
|
}//GEN-LAST:event_jMenuItem4ActionPerformed
|
||||||
|
|
||||||
|
|
||||||
TraderListDialog tld = null;
|
TraderListDialog tld = null;
|
||||||
private void viewTraderListCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewTraderListCheckBoxActionPerformed
|
private void viewTraderListCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewTraderListCheckBoxActionPerformed
|
||||||
|
System.out.printf("Trwindow: %s\n", Boolean.toString(this.viewTraderListCheckBox.getState()));
|
||||||
if (this.viewTraderListCheckBox.getState()) {
|
if (this.viewTraderListCheckBox.getState()) {
|
||||||
if (tld == null) {
|
if (tld == null) {
|
||||||
tld = new TraderListDialog(this, false);
|
tld = new TraderListDialog(this, false);
|
||||||
|
tld.addWindowListener(new WindowAdapter() {
|
||||||
|
@Override
|
||||||
|
public void windowClosing(WindowEvent e) {
|
||||||
|
super.windowClosing(e);
|
||||||
|
viewTraderListCheckBox.setState(false);
|
||||||
|
System.out.printf("Set menu false\n");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
tld.setVisible(true);
|
tld.setVisible(true);
|
||||||
}
|
} else if (tld != null) {
|
||||||
else {
|
System.out.printf("Set visible = false\n");
|
||||||
if (tld!=null)
|
|
||||||
tld.setVisible(false);
|
tld.setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}//GEN-LAST:event_viewTraderListCheckBoxActionPerformed
|
}//GEN-LAST:event_viewTraderListCheckBoxActionPerformed
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -746,14 +730,8 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
tl.getTraders();
|
tl.getTraders();
|
||||||
|
|
||||||
//System.exit(0);
|
//System.exit(0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Globals.se = new Exchange();
|
Globals.se = new Exchange();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Class<?> c = sesim.Exchange.class;
|
Class<?> c = sesim.Exchange.class;
|
||||||
Globals.prefs = Preferences.userNodeForPackage(c);
|
Globals.prefs = Preferences.userNodeForPackage(c);
|
||||||
|
|
||||||
@ -785,7 +763,6 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem1;
|
private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem1;
|
||||||
private javax.swing.JComboBox<String> jComboBox1;
|
private javax.swing.JComboBox<String> jComboBox1;
|
||||||
private javax.swing.JMenuItem jMenuItem1;
|
private javax.swing.JMenuItem jMenuItem1;
|
||||||
private javax.swing.JMenuItem jMenuItem2;
|
|
||||||
private javax.swing.JMenuItem jMenuItem3;
|
private javax.swing.JMenuItem jMenuItem3;
|
||||||
private javax.swing.JMenuItem jMenuItem4;
|
private javax.swing.JMenuItem jMenuItem4;
|
||||||
private javax.swing.JMenuItem jMenuItem5;
|
private javax.swing.JMenuItem jMenuItem5;
|
||||||
|
Loading…
Reference in New Issue
Block a user