Merge branch 'master' of https://github.com/7u83/SeSim
This commit is contained in:
@ -61,7 +61,7 @@
|
||||
<Font component="jTextPane1" property="font" relativeSize="true" size="0"/>
|
||||
</FontInfo>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="SeSim - Sock Exchange Simulator - Version 0.1


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.
"/>
|
||||
<Property name="text" type="java.lang.String" value="SeSim - Stock Exchange Simulator - Version 0.1


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.
"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
|
@ -37,7 +37,7 @@ public class AboutDialog extends javax.swing.JDialog {
|
||||
public AboutDialog(java.awt.Frame parent, boolean modal) {
|
||||
super(parent, modal);
|
||||
initComponents();
|
||||
// this.setLocationRelativeTo(MainWin.instance);
|
||||
this.setLocationRelativeTo(null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -58,7 +58,7 @@ public class AboutDialog extends javax.swing.JDialog {
|
||||
|
||||
jTextPane1.setEditable(false);
|
||||
jTextPane1.setFont(jTextPane1.getFont());
|
||||
jTextPane1.setText("SeSim - Sock Exchange Simulator - Version 0.1\n\n\nCopyright (c) 2017, 7u83 <7u83@mail.ru>\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n\n* 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.\n\nTHIS 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.\n");
|
||||
jTextPane1.setText("SeSim - Stock Exchange Simulator - Version 0.1\n\n\nCopyright (c) 2017, 7u83 <7u83@mail.ru>\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n\n* 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.\n\nTHIS 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.\n");
|
||||
jScrollPane1.setViewportView(jTextPane1);
|
||||
|
||||
jButton1.setMnemonic('c');
|
||||
|
@ -1,107 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jLabel1" min="-2" pref="63" max="-2" attributes="0"/>
|
||||
<Component id="jLabel2" min="-2" pref="50" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jTextField2" max="32767" attributes="0"/>
|
||||
<Component id="jTextField1" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace pref="37" max="32767" attributes="0"/>
|
||||
<Component id="jButton1" min="-2" pref="65" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jButton2" min="-2" pref="70" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||
<Component id="jTextField1" max="32767" attributes="0"/>
|
||||
<Component id="jLabel1" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jLabel2" min="-2" pref="25" max="-2" attributes="0"/>
|
||||
<Component id="jTextField2" alignment="0" min="-2" pref="27" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jButton1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jButton2" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace pref="358" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="jButton1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Byu"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="jButton2">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Sell"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="jTextField1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="325"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jTextField1ActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Shares:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel2">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Limit:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="jTextField2">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="127.00"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jTextField2ActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
@ -1,145 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class ControlPanel extends javax.swing.JPanel {
|
||||
|
||||
/**
|
||||
* Creates new form ControlPanel
|
||||
*/
|
||||
public ControlPanel() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
jButton1 = new javax.swing.JButton();
|
||||
jButton2 = new javax.swing.JButton();
|
||||
jTextField1 = new javax.swing.JTextField();
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
jLabel2 = new javax.swing.JLabel();
|
||||
jTextField2 = new javax.swing.JTextField();
|
||||
|
||||
jButton1.setText("Byu");
|
||||
jButton1.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jButton1ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jButton2.setText("Sell");
|
||||
|
||||
jTextField1.setText("325");
|
||||
jTextField1.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jTextField1ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jLabel1.setText("Shares:");
|
||||
|
||||
jLabel2.setText("Limit:");
|
||||
|
||||
jTextField2.setText("127.00");
|
||||
jTextField2.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jTextField2ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jTextField2)
|
||||
.addComponent(jTextField1)))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap(37, Short.MAX_VALUE)
|
||||
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addComponent(jTextField1)
|
||||
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jButton1)
|
||||
.addComponent(jButton2))
|
||||
.addContainerGap(358, Short.MAX_VALUE))
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
|
||||
// TODO add your handling code here:
|
||||
}//GEN-LAST:event_jButton1ActionPerformed
|
||||
|
||||
private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField2ActionPerformed
|
||||
// TODO add your handling code here:
|
||||
}//GEN-LAST:event_jTextField2ActionPerformed
|
||||
|
||||
private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
|
||||
// TODO add your handling code here:
|
||||
}//GEN-LAST:event_jTextField1ActionPerformed
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton jButton1;
|
||||
private javax.swing.JButton jButton2;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JLabel jLabel2;
|
||||
private javax.swing.JTextField jTextField1;
|
||||
private javax.swing.JTextField jTextField2;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
@ -41,7 +41,7 @@ import javax.swing.table.DefaultTableModel;
|
||||
import javax.swing.table.JTableHeader;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import sesim.AutoTraderConfig;
|
||||
//import sesim.AutoTraderConfig;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -79,7 +79,7 @@ public class EditAutoTraderList extends javax.swing.JPanel {
|
||||
ja.put(jo);
|
||||
}
|
||||
|
||||
Globals.prefs.put("Traders", ja.toString());
|
||||
Globals.prefs.put(Globals.PrefKeys.TRADERS, ja.toString());
|
||||
|
||||
}
|
||||
|
||||
@ -139,7 +139,7 @@ public class EditAutoTraderList extends javax.swing.JPanel {
|
||||
|
||||
for (int r = 0; r < model.getRowCount(); r++) {
|
||||
Boolean e = (Boolean) list.getValueAt(r, list.getColumn("Enabled").getModelIndex());
|
||||
if (e==null){
|
||||
if (e == null) {
|
||||
continue;
|
||||
}
|
||||
if (!e) {
|
||||
@ -147,7 +147,7 @@ public class EditAutoTraderList extends javax.swing.JPanel {
|
||||
}
|
||||
money += (Double) list.getValueAt(r, list.getColumn("Money").getModelIndex());
|
||||
shares += (Double) list.getValueAt(r, list.getColumn("Shares").getModelIndex());
|
||||
System.out.printf("Row: %d %f %f\n", r, money, shares);
|
||||
// System.out.printf("Row: %d %f %f\n", r, money, shares);
|
||||
}
|
||||
return money / shares;
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
|
||||
|
||||
void resetUI() {
|
||||
for (Window w : Window.getWindows()) {
|
||||
System.out.print("Setting frame\n");
|
||||
|
||||
SwingUtilities.updateComponentTreeUI(w);
|
||||
w.pack();
|
||||
}
|
||||
|
@ -36,8 +36,6 @@ import java.util.logging.Logger;
|
||||
import javax.swing.JPanel;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import sesim.AutoTraderConfig;
|
||||
import sesim.AutoTraderGui;
|
||||
import sesim.AutoTraderInterface;
|
||||
|
||||
@ -75,7 +73,7 @@ public final class EditStrategies extends javax.swing.JDialog {
|
||||
initComponents();
|
||||
|
||||
|
||||
String dp = new java.io.File(NewMDIApplication.class.getProtectionDomain()
|
||||
String dp = new java.io.File(SeSimApplication.class.getProtectionDomain()
|
||||
.getCodeSource()
|
||||
.getLocation()
|
||||
.getPath()).toString();
|
||||
@ -93,7 +91,7 @@ public final class EditStrategies extends javax.swing.JDialog {
|
||||
|
||||
|
||||
|
||||
final String STRATEGYPREFS = "Strategies";
|
||||
//final String STRATEGYPREFS = "Strategies";
|
||||
|
||||
void reloadStrategyConfigs() {
|
||||
|
||||
@ -261,7 +259,7 @@ public final class EditStrategies extends javax.swing.JDialog {
|
||||
|
||||
private void jComboBoxStrategySelectorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxStrategySelectorActionPerformed
|
||||
|
||||
String cfglist = Globals.prefs.get(STRATEGYPREFS, "{}");
|
||||
String cfglist = Globals.prefs.get(Globals.PrefKeys.STRATEGIES, "{}");
|
||||
JSONObject cfgs = new JSONObject(cfglist);
|
||||
String item = (String) this.jComboBoxStrategySelector.getSelectedItem();
|
||||
|
||||
@ -354,12 +352,12 @@ System.out.printf("The big name: %s\n", ac.getClass().getCanonicalName());
|
||||
item = item + " - " + d.getName();
|
||||
}
|
||||
|
||||
String cfglist = Globals.prefs.get(STRATEGYPREFS, "{}");
|
||||
String cfglist = Globals.prefs.get(Globals.PrefKeys.STRATEGIES, "{}");
|
||||
JSONObject cfgs = new JSONObject(cfglist);
|
||||
|
||||
cfgs.put(item, o);
|
||||
|
||||
Globals.prefs.put(STRATEGYPREFS, cfgs.toString());
|
||||
Globals.prefs.put(Globals.PrefKeys.STRATEGIES, cfgs.toString());
|
||||
|
||||
//this.reloadStrategyConfigs();
|
||||
this.initComboBox();
|
||||
@ -381,14 +379,14 @@ System.out.printf("The big name: %s\n", ac.getClass().getCanonicalName());
|
||||
String selected = (String) this.jComboBoxStrategySelector.getSelectedItem();
|
||||
System.out.printf("Selected: %s\n", selected);
|
||||
|
||||
String cfglist = Globals.prefs.get(STRATEGYPREFS, "{}");
|
||||
String cfglist = Globals.prefs.get(Globals.PrefKeys.STRATEGIES, "{}");
|
||||
JSONObject cfgs = new JSONObject(cfglist);
|
||||
|
||||
//System.out.printf("CFG vorher: %s\n", cfgs.toString(3));
|
||||
cfgs.remove(selected);
|
||||
|
||||
// System.out.printf("Neue nachher: %s\n", cfgs.toString(3));
|
||||
Globals.prefs.put(STRATEGYPREFS, cfgs.toString());
|
||||
Globals.prefs.put(Globals.PrefKeys.STRATEGIES, cfgs.toString());
|
||||
|
||||
this.initComboBox();
|
||||
|
||||
|
@ -27,7 +27,9 @@ package gui;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
@ -47,6 +49,12 @@ import sesim.AutoTraderLoader;
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class Globals {
|
||||
|
||||
public static final String SESIM_FILEEXTENSION = "sesim";
|
||||
public static final Double SESIM_FILEVERSION = 0.1;
|
||||
|
||||
public static final String SESIM_APPTITLE = "SeSim - Stock Exchange Simulator";
|
||||
|
||||
|
||||
public interface CfgListener {
|
||||
|
||||
@ -67,14 +75,30 @@ public class Globals {
|
||||
|
||||
public static JFrame frame;
|
||||
|
||||
static final String STRATEGYPREFS = "Strategies";
|
||||
static final String TRADERPREFS = "Traders";
|
||||
// static final String STRATEGYPREFS = "Strategies";
|
||||
// static final String TRADERPREFS = "Traders";
|
||||
|
||||
static final String DEVELSTATUS = "devel_status";
|
||||
public static final String GODMODE = "godmode";
|
||||
|
||||
static public sesim.Exchange se;
|
||||
|
||||
/**
|
||||
* Defines keys for preferences
|
||||
*/
|
||||
public static final class PrefKeys{
|
||||
|
||||
public static String WORKDIR = "workdir";
|
||||
public static final String CURRENTFILE = "currentfile";
|
||||
|
||||
public static final String SESIMVERSION = "version";
|
||||
public static final String STRATEGIES = "strategies";
|
||||
public static final String TRADERS = "traders";
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
static public Preferences prefs;
|
||||
|
||||
public static class CfgStrings {
|
||||
@ -116,18 +140,18 @@ public class Globals {
|
||||
static AutoTraderLoader tloader;
|
||||
|
||||
static void initGlobals() {
|
||||
String[] a = System.getProperty("java.class.path").split(System.getProperty("path.separator"));
|
||||
String[] a = System.getProperty("java.class.path").split(System.getProperty("path.separator"));
|
||||
ArrayList pathlist = new ArrayList<>(Arrays.asList(a));
|
||||
System.out.printf("Init tloader\n");
|
||||
|
||||
pathlist = new ArrayList<>();
|
||||
String dp = new java.io.File(NewMDIApplication.class.getProtectionDomain()
|
||||
String dp = new java.io.File(SeSimApplication.class.getProtectionDomain()
|
||||
.getCodeSource()
|
||||
.getLocation()
|
||||
.getPath()).toString();
|
||||
|
||||
pathlist.add(dp);
|
||||
LOGGER.info(String.format("Path %s",dp));
|
||||
LOGGER.info(String.format("Path %s", dp));
|
||||
tloader = new AutoTraderLoader(pathlist);
|
||||
|
||||
}
|
||||
@ -135,17 +159,26 @@ public class Globals {
|
||||
static public final Logger LOGGER = Logger.getLogger("com.cauwersin.sesim");
|
||||
|
||||
static public final JSONArray getTraders() {
|
||||
String traders_json = Globals.prefs.get(TRADERPREFS, "[]");
|
||||
String traders_json = Globals.prefs.get(PrefKeys.TRADERS, "[]");
|
||||
JSONArray traders = new JSONArray(traders_json);
|
||||
return traders;
|
||||
}
|
||||
|
||||
static public final JSONObject getStrategies() {
|
||||
String cfglist = Globals.prefs.get(STRATEGYPREFS, "{}");
|
||||
String cfglist = Globals.prefs.get(PrefKeys.STRATEGIES, "{}");
|
||||
JSONObject cfgs = new JSONObject(cfglist);
|
||||
return cfgs;
|
||||
}
|
||||
|
||||
static public final void putStrategies(JSONObject strategies){
|
||||
Globals.prefs.put(Globals.PrefKeys.STRATEGIES, strategies.toString());
|
||||
}
|
||||
|
||||
static public final void putTraders (JSONArray traders){
|
||||
Globals.prefs.put(Globals.PrefKeys.TRADERS, traders.toString());
|
||||
}
|
||||
|
||||
|
||||
static public JSONObject getStrategy(String name) {
|
||||
return getStrategies().getJSONObject(name);
|
||||
}
|
||||
@ -177,24 +210,60 @@ public class Globals {
|
||||
static public final void saveStrategy(String name, JSONObject cfg) {
|
||||
JSONObject cfgs = getStrategies();
|
||||
cfgs.put(name, cfg);
|
||||
prefs.put(STRATEGYPREFS, cfgs.toString());
|
||||
prefs.put(PrefKeys.STRATEGIES, cfgs.toString());
|
||||
}
|
||||
|
||||
static void saveFile(File f) {
|
||||
|
||||
|
||||
|
||||
public static void saveFile(File f) throws FileNotFoundException {
|
||||
|
||||
JSONObject sobj = new JSONObject();
|
||||
|
||||
JSONArray traders = getTraders();
|
||||
JSONObject strategies = getStrategies();
|
||||
sobj.put("strategies", strategies);
|
||||
sobj.put("traders", traders);
|
||||
try {
|
||||
PrintWriter out = new PrintWriter(f.getAbsolutePath());
|
||||
out.print(sobj.toString(4));
|
||||
out.close();
|
||||
} catch (FileNotFoundException ex) {
|
||||
Logger.getLogger(Globals.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
sobj.put(PrefKeys.SESIMVERSION, SESIM_FILEVERSION);
|
||||
sobj.put(PrefKeys.STRATEGIES, strategies);
|
||||
sobj.put(PrefKeys.TRADERS, traders);
|
||||
|
||||
PrintWriter out;
|
||||
out = new PrintWriter(f.getAbsolutePath());
|
||||
out.print(sobj.toString(4));
|
||||
out.close();
|
||||
|
||||
}
|
||||
|
||||
public static void loadString(String s) throws IOException{
|
||||
JSONObject sobj = new JSONObject(s);
|
||||
|
||||
Double version = sobj.getDouble(PrefKeys.SESIMVERSION);
|
||||
if (version > SESIM_FILEVERSION){
|
||||
throw new IOException("File has wrong version.");
|
||||
}
|
||||
|
||||
JSONArray traders = sobj.getJSONArray(PrefKeys.TRADERS);
|
||||
JSONObject strategies = sobj.getJSONObject(PrefKeys.STRATEGIES);
|
||||
|
||||
putStrategies(strategies);
|
||||
putTraders(traders);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void clearAll(){
|
||||
putStrategies(new JSONObject());
|
||||
putTraders(new JSONArray());
|
||||
}
|
||||
|
||||
public static void loadFile(File f) throws IOException {
|
||||
|
||||
f.getAbsoluteFile();
|
||||
String s;
|
||||
s = new String(Files.readAllBytes(f.toPath()));
|
||||
|
||||
loadString(s);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ public class MainChart extends chart.Chart {
|
||||
1 * 24 * 3600 * 1000, 2 * 24 * 3600 * 1000
|
||||
};
|
||||
|
||||
private final Integer default_cmopression = 60 * 1000;
|
||||
private final Integer default_cmopression = 60 * 60 * 1000;
|
||||
|
||||
private void initCtxMenu() {
|
||||
ButtonGroup group = new ButtonGroup();
|
||||
|
@ -55,12 +55,12 @@
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jScrollPane1" alignment="1" pref="400" max="32767" attributes="0"/>
|
||||
<Component id="jScrollPane1" alignment="1" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jScrollPane1" alignment="0" pref="221" max="32767" attributes="0"/>
|
||||
<Component id="jScrollPane1" alignment="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
|
@ -49,13 +49,11 @@ public class OpenOrdersList extends javax.swing.JPanel {
|
||||
DefaultTableModel model;
|
||||
|
||||
public final void updateModel() {
|
||||
System.out.printf("Update Model\n");
|
||||
if (null == account) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.printf("Now updateing\n");
|
||||
|
||||
|
||||
int row = 0;
|
||||
|
||||
@ -90,6 +88,7 @@ public class OpenOrdersList extends javax.swing.JPanel {
|
||||
model.setRowCount(0);
|
||||
table.setFillsViewportHeight(true);
|
||||
updateModel();
|
||||
|
||||
}
|
||||
|
||||
public void initOrderList(Account account) {
|
||||
@ -179,11 +178,11 @@ public class OpenOrdersList extends javax.swing.JPanel {
|
||||
this.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)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 221, Short.MAX_VALUE)
|
||||
.addComponent(jScrollPane1)
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
@ -191,11 +190,11 @@ public class OpenOrdersList extends javax.swing.JPanel {
|
||||
|
||||
Point point = evt.getPoint();
|
||||
int currentRow = table.rowAtPoint(point);
|
||||
if (currentRow == -1) {
|
||||
|
||||
} else {
|
||||
|
||||
if (currentRow != -1) {
|
||||
|
||||
table.setRowSelectionInterval(currentRow, currentRow);
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
int nbuttons = MouseInfo.getNumberOfButtons();
|
||||
@ -204,9 +203,7 @@ public class OpenOrdersList extends javax.swing.JPanel {
|
||||
return;
|
||||
}
|
||||
|
||||
this.ctxMenu.show(this, evt.getX(), evt.getY());
|
||||
|
||||
System.out.printf("Button %d %d \n", nbuttons, button);
|
||||
ctxMenu.show(table, point.x,point.y);
|
||||
|
||||
}//GEN-LAST:event_tableMousePressed
|
||||
|
||||
|
@ -53,15 +53,6 @@
|
||||
<Property name="text" type="java.lang.String" value="File"/>
|
||||
</Properties>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem1">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="110"/>
|
||||
<Property name="text" type="java.lang.String" value="New"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem1ActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="openMenuItem">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="111"/>
|
||||
@ -76,6 +67,9 @@
|
||||
<Property name="mnemonic" type="int" value="115"/>
|
||||
<Property name="text" type="java.lang.String" value="Save"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="saveMenuItemActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="saveAsMenuItem">
|
||||
<Properties>
|
||||
@ -87,6 +81,38 @@
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="saveAsMenuItemActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="closeMenuItem">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="99"/>
|
||||
<Property name="text" type="java.lang.String" value="Close"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="closeMenuItemActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JPopupMenu$Separator" name="jSeparator5">
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="resetToDefaultsMenuItem">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="114"/>
|
||||
<Property name="text" type="java.lang.String" value="Reset to defaults"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value=""/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="resetToDefaultsMenuItemActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="clearMenuItem">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="99"/>
|
||||
<Property name="text" type="java.lang.String" value="Clear All"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="clearMenuItemActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JPopupMenu$Separator" name="jSeparator4">
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="exitMenuItem">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="120"/>
|
||||
@ -179,21 +205,6 @@
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="simMenuStopActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JPopupMenu$Separator" name="jSeparator3">
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem4">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Point Zero"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem4ActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem5">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="jMenuItem5"/>
|
||||
</Properties>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
<Menu class="javax.swing.JMenu" name="viewMenu">
|
||||
@ -211,22 +222,6 @@
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="viewTraderListCheckBoxActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="viewClock">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Clock"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="viewClockActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem3">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="LogWindow"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem3ActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JCheckBoxMenuItem" name="jCheckBoxMenuItem1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Orderbook"/>
|
||||
@ -243,12 +238,6 @@
|
||||
<Property name="text" type="java.lang.String" value="Help"/>
|
||||
</Properties>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="contentMenuItem">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="99"/>
|
||||
<Property name="text" type="java.lang.String" value="Contents"/>
|
||||
</Properties>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="aboutMenuItem">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="97"/>
|
||||
@ -265,6 +254,7 @@
|
||||
</NonVisualComponents>
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="3"/>
|
||||
<Property name="title" type="java.lang.String" value="SeSim - Stock Exchange Simmulator"/>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[640, 480]"/>
|
||||
</Property>
|
@ -29,17 +29,42 @@ import java.awt.Dialog;
|
||||
import java.awt.Frame;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Window;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.io.File;
|
||||
<<<<<<< HEAD:src/gui/NewMDIApplication.java
|
||||
=======
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Scanner;
|
||||
import java.util.TimerTask;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
>>>>>>> a106593383445fdec94759a19d1b57426816c20d:src/gui/SeSimApplication.java
|
||||
import java.util.prefs.Preferences;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JOptionPane;
|
||||
import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER;
|
||||
<<<<<<< HEAD:src/gui/NewMDIApplication.java
|
||||
=======
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
>>>>>>> a106593383445fdec94759a19d1b57426816c20d:src/gui/SeSimApplication.java
|
||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
<<<<<<< HEAD:src/gui/NewMDIApplication.java
|
||||
=======
|
||||
|
||||
>>>>>>> a106593383445fdec94759a19d1b57426816c20d:src/gui/SeSimApplication.java
|
||||
import sesim.AutoTraderInterface;
|
||||
import sesim.Exchange;
|
||||
import sesim.Scheduler;
|
||||
@ -48,19 +73,42 @@ import sesim.Scheduler;
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class NewMDIApplication extends javax.swing.JFrame {
|
||||
public class SeSimApplication extends javax.swing.JFrame {
|
||||
|
||||
/**
|
||||
* Creates new form NewMDIApplication
|
||||
*/
|
||||
public NewMDIApplication() {
|
||||
public SeSimApplication() {
|
||||
|
||||
initComponents();
|
||||
|
||||
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
GraphicsDevice[] screens = ge.getScreenDevices();
|
||||
|
||||
//Window w = screens[1].getFullScreenWindow();
|
||||
|
||||
// JFrame dummy = new JFrame(screens[1].getDefaultConfiguration());
|
||||
|
||||
// setLocationRelativeTo(dummy);
|
||||
// dummy.dispose();
|
||||
|
||||
for (GraphicsDevice gd:screens){
|
||||
//Window w = gd.getFullScreenWindow();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
setTitle("");
|
||||
boolean init = Globals.prefs.getBoolean("initilized", false);
|
||||
if (!init){
|
||||
resetToDefaults();
|
||||
Globals.prefs.putBoolean("initilized", true);
|
||||
}
|
||||
this.chartSrollPane.setVerticalScrollBarPolicy(VERTICAL_SCROLLBAR_NEVER);
|
||||
// Globals.frame = this;
|
||||
//this.setLocationRelativeTo(null);
|
||||
System.out.printf("Set title\n");
|
||||
setTitle("SeSim - Stock Exchange Simmulator");
|
||||
}
|
||||
|
||||
AutoTraderInterface createTraderNew(Exchange se, long id, String name, double money, double shares, JSONObject cfg) {
|
||||
@ -163,10 +211,14 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
||||
statistics1 = new gui.Statistics();
|
||||
menuBar = new javax.swing.JMenuBar();
|
||||
fileMenu = new javax.swing.JMenu();
|
||||
jMenuItem1 = new javax.swing.JMenuItem();
|
||||
openMenuItem = new javax.swing.JMenuItem();
|
||||
saveMenuItem = new javax.swing.JMenuItem();
|
||||
saveAsMenuItem = new javax.swing.JMenuItem();
|
||||
closeMenuItem = new javax.swing.JMenuItem();
|
||||
jSeparator5 = new javax.swing.JPopupMenu.Separator();
|
||||
resetToDefaultsMenuItem = new javax.swing.JMenuItem();
|
||||
clearMenuItem = new javax.swing.JMenuItem();
|
||||
jSeparator4 = new javax.swing.JPopupMenu.Separator();
|
||||
exitMenuItem = new javax.swing.JMenuItem();
|
||||
editMenu = new javax.swing.JMenu();
|
||||
editExchangeMenuItem = new javax.swing.JMenuItem();
|
||||
@ -179,16 +231,10 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
||||
simMenuStart = new javax.swing.JMenuItem();
|
||||
simMenuPause = new javax.swing.JMenuItem();
|
||||
simMenuStop = new javax.swing.JMenuItem();
|
||||
jSeparator3 = new javax.swing.JPopupMenu.Separator();
|
||||
jMenuItem4 = new javax.swing.JMenuItem();
|
||||
jMenuItem5 = new javax.swing.JMenuItem();
|
||||
viewMenu = new javax.swing.JMenu();
|
||||
viewTraderListCheckBox = new javax.swing.JCheckBoxMenuItem();
|
||||
viewClock = new javax.swing.JMenuItem();
|
||||
jMenuItem3 = new javax.swing.JMenuItem();
|
||||
jCheckBoxMenuItem1 = new javax.swing.JCheckBoxMenuItem();
|
||||
helpMenu = new javax.swing.JMenu();
|
||||
contentMenuItem = new javax.swing.JMenuItem();
|
||||
aboutMenuItem = new javax.swing.JMenuItem();
|
||||
|
||||
jTextArea1.setColumns(20);
|
||||
@ -203,6 +249,7 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
||||
jSplitPane1.setTopComponent(jSplitPane2);
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
||||
setTitle("SeSim - Stock Exchange Simmulator");
|
||||
setMinimumSize(new java.awt.Dimension(640, 480));
|
||||
|
||||
stopButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/icons/stop.gif"))); // NOI18N
|
||||
@ -322,15 +369,6 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
||||
fileMenu.setMnemonic('f');
|
||||
fileMenu.setText("File");
|
||||
|
||||
jMenuItem1.setMnemonic('n');
|
||||
jMenuItem1.setText("New");
|
||||
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jMenuItem1ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
fileMenu.add(jMenuItem1);
|
||||
|
||||
openMenuItem.setMnemonic('o');
|
||||
openMenuItem.setText("Open");
|
||||
openMenuItem.addActionListener(new java.awt.event.ActionListener() {
|
||||
@ -342,6 +380,11 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
||||
|
||||
saveMenuItem.setMnemonic('s');
|
||||
saveMenuItem.setText("Save");
|
||||
saveMenuItem.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
saveMenuItemActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
fileMenu.add(saveMenuItem);
|
||||
|
||||
saveAsMenuItem.setMnemonic('a');
|
||||
@ -354,6 +397,36 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
||||
});
|
||||
fileMenu.add(saveAsMenuItem);
|
||||
|
||||
closeMenuItem.setMnemonic('c');
|
||||
closeMenuItem.setText("Close");
|
||||
closeMenuItem.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
closeMenuItemActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
fileMenu.add(closeMenuItem);
|
||||
fileMenu.add(jSeparator5);
|
||||
|
||||
resetToDefaultsMenuItem.setMnemonic('r');
|
||||
resetToDefaultsMenuItem.setText("Reset to defaults");
|
||||
resetToDefaultsMenuItem.setToolTipText("");
|
||||
resetToDefaultsMenuItem.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
resetToDefaultsMenuItemActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
fileMenu.add(resetToDefaultsMenuItem);
|
||||
|
||||
clearMenuItem.setMnemonic('c');
|
||||
clearMenuItem.setText("Clear All");
|
||||
clearMenuItem.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
clearMenuItemActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
fileMenu.add(clearMenuItem);
|
||||
fileMenu.add(jSeparator4);
|
||||
|
||||
exitMenuItem.setMnemonic('x');
|
||||
exitMenuItem.setText("Exit");
|
||||
exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
|
||||
@ -437,18 +510,6 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
||||
}
|
||||
});
|
||||
simMenu.add(simMenuStop);
|
||||
simMenu.add(jSeparator3);
|
||||
|
||||
jMenuItem4.setText("Point Zero");
|
||||
jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jMenuItem4ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
simMenu.add(jMenuItem4);
|
||||
|
||||
jMenuItem5.setText("jMenuItem5");
|
||||
simMenu.add(jMenuItem5);
|
||||
|
||||
menuBar.add(simMenu);
|
||||
|
||||
@ -464,22 +525,6 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
||||
});
|
||||
viewMenu.add(viewTraderListCheckBox);
|
||||
|
||||
viewClock.setText("Clock");
|
||||
viewClock.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
viewClockActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
viewMenu.add(viewClock);
|
||||
|
||||
jMenuItem3.setText("LogWindow");
|
||||
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jMenuItem3ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
viewMenu.add(jMenuItem3);
|
||||
|
||||
jCheckBoxMenuItem1.setText("Orderbook");
|
||||
jCheckBoxMenuItem1.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
@ -493,10 +538,6 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
||||
helpMenu.setMnemonic('h');
|
||||
helpMenu.setText("Help");
|
||||
|
||||
contentMenuItem.setMnemonic('c');
|
||||
contentMenuItem.setText("Contents");
|
||||
helpMenu.add(contentMenuItem);
|
||||
|
||||
aboutMenuItem.setMnemonic('a');
|
||||
aboutMenuItem.setText("About");
|
||||
aboutMenuItem.addActionListener(new java.awt.event.ActionListener() {
|
||||
@ -605,43 +646,121 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
||||
|
||||
private final LoggerDialog log_d = new LoggerDialog(this, false);
|
||||
|
||||
private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
|
||||
log_d.setVisible(!log_d.isShowing());
|
||||
|
||||
|
||||
}//GEN-LAST:event_jMenuItem3ActionPerformed
|
||||
|
||||
private void openMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openMenuItemActionPerformed
|
||||
JFileChooser fc = getFileChooser();
|
||||
|
||||
while (true) {
|
||||
if (fc.showOpenDialog(this) != JFileChooser.APPROVE_OPTION) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
File f = fc.getSelectedFile();
|
||||
Globals.loadFile(f);
|
||||
String workdir = fc.getCurrentDirectory().getAbsolutePath();
|
||||
Globals.prefs.put(Globals.PrefKeys.WORKDIR, workdir);
|
||||
Globals.prefs.put(Globals.PrefKeys.CURRENTFILE, f.getAbsolutePath());
|
||||
setTitle(f.getName());
|
||||
return;
|
||||
|
||||
} catch (Exception ex) {
|
||||
JOptionPane.showMessageDialog(this, "Can't load file: " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
}
|
||||
}//GEN-LAST:event_openMenuItemActionPerformed
|
||||
|
||||
private void saveAsMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveAsMenuItemActionPerformed
|
||||
// initialize a JFileChose with worging directory and extension
|
||||
private JFileChooser getFileChooser() {
|
||||
JFileChooser fc = new JFileChooser();
|
||||
|
||||
FileNameExtensionFilter filter = new FileNameExtensionFilter("SeSim Files", "sesim");
|
||||
fc.setFileFilter(filter);
|
||||
String workdir = Globals.prefs.get(Globals.PrefKeys.WORKDIR, "");
|
||||
fc.setCurrentDirectory(new File(workdir));
|
||||
|
||||
FileNameExtensionFilter sesim_filter = new FileNameExtensionFilter("SeSim Files", Globals.SESIM_FILEEXTENSION);
|
||||
fc.setFileFilter(sesim_filter);
|
||||
return fc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setTitle(String filename) {
|
||||
String name;
|
||||
name = Globals.SESIM_APPTITLE;
|
||||
if (!"".equals(filename)) {
|
||||
name += " (" + filename + ")";
|
||||
}
|
||||
super.setTitle(name);
|
||||
}
|
||||
|
||||
private void saveFile(boolean saveAs) {
|
||||
JFileChooser fc = getFileChooser();
|
||||
FileFilter sesim_filter = fc.getFileFilter();
|
||||
|
||||
while (true) {
|
||||
String current_file = Globals.prefs.get(Globals.PrefKeys.CURRENTFILE, "");
|
||||
File fobj;
|
||||
|
||||
if (saveAs || "".equals(current_file)) {
|
||||
|
||||
if (!"".equals(current_file)) {
|
||||
fobj = new File(current_file);
|
||||
fc.setSelectedFile(fobj);
|
||||
fc.setCurrentDirectory(fobj);
|
||||
}
|
||||
|
||||
saveAs = true;
|
||||
if (fc.showSaveDialog(this) != JFileChooser.APPROVE_OPTION) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
fobj = new File(current_file);
|
||||
fc.setSelectedFile(fobj);
|
||||
fc.setCurrentDirectory(fobj);
|
||||
}
|
||||
|
||||
File f = fc.getSelectedFile();
|
||||
String workdir = fc.getCurrentDirectory().getAbsolutePath();
|
||||
Globals.prefs.put(Globals.PrefKeys.WORKDIR, workdir);
|
||||
String fn = f.getAbsolutePath();
|
||||
|
||||
if (f.exists() && saveAs) {
|
||||
String s = String.format("File %s already exists. Do you want to overwrite?", fn);
|
||||
int dialogResult = JOptionPane.showConfirmDialog(this, s, "Warning", JOptionPane.YES_NO_OPTION);
|
||||
if (dialogResult != JOptionPane.YES_OPTION) {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
FileFilter selected_filter = fc.getFileFilter();
|
||||
if (selected_filter == sesim_filter) {
|
||||
System.out.printf("Filter", selected_filter.toString());
|
||||
if (!fn.toLowerCase().endsWith("." + Globals.SESIM_FILEEXTENSION)) {
|
||||
f = new File(fn + "." + Globals.SESIM_FILEEXTENSION);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
Globals.saveFile(f);
|
||||
Globals.prefs.put(Globals.PrefKeys.CURRENTFILE, fn);
|
||||
setTitle(f.getName());
|
||||
return;
|
||||
|
||||
} catch (Exception ex) {
|
||||
|
||||
JOptionPane.showMessageDialog(this, "Can't save file: " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
|
||||
|
||||
}
|
||||
|
||||
if (fc.showSaveDialog(this) != JFileChooser.APPROVE_OPTION) {
|
||||
return;
|
||||
}
|
||||
|
||||
File f = fc.getSelectedFile();
|
||||
|
||||
String[] e = ((FileNameExtensionFilter) fc.getFileFilter()).getExtensions();
|
||||
|
||||
System.out.printf("Abs: %s\n", f.getAbsoluteFile());
|
||||
|
||||
String fn = f.getAbsolutePath();
|
||||
|
||||
if (!f.getAbsolutePath().endsWith(e[0])) {
|
||||
f = new File(f.getAbsolutePath() + "." + e[0]);
|
||||
}
|
||||
|
||||
Globals.saveFile(f);
|
||||
|
||||
System.out.printf("Sel File: %s \n", f.getAbsolutePath());
|
||||
}
|
||||
|
||||
|
||||
private void saveAsMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveAsMenuItemActionPerformed
|
||||
|
||||
this.saveFile(true);
|
||||
}//GEN-LAST:event_saveAsMenuItemActionPerformed
|
||||
|
||||
private void editExchangeMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editExchangeMenuItemActionPerformed
|
||||
@ -651,15 +770,29 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
||||
|
||||
}//GEN-LAST:event_editExchangeMenuItemActionPerformed
|
||||
|
||||
private void viewClockActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewClockActionPerformed
|
||||
ClockDialog cd = new ClockDialog(this, true);
|
||||
cd.setVisible(rootPaneCheckingEnabled);
|
||||
private void resetToDefaults(){
|
||||
InputStream is = getClass().getResourceAsStream("/resources/files/defaultcfg.json");
|
||||
String df = new Scanner(is, "UTF-8").useDelimiter("\\A").next();
|
||||
|
||||
}//GEN-LAST:event_viewClockActionPerformed
|
||||
try {
|
||||
Globals.loadString(df);
|
||||
} catch (IOException ex) {
|
||||
JOptionPane.showMessageDialog(this, "Can't load file: " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
|
||||
|
||||
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
|
||||
// TODO add your handling code here:
|
||||
}//GEN-LAST:event_jMenuItem1ActionPerformed
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void resetToDefaultsMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resetToDefaultsMenuItemActionPerformed
|
||||
|
||||
int dialogResult = JOptionPane.showConfirmDialog(this, "Are you sure?", "Warning", JOptionPane.YES_NO_OPTION);
|
||||
if (dialogResult != JOptionPane.YES_OPTION) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.resetToDefaults();
|
||||
|
||||
}//GEN-LAST:event_resetToDefaultsMenuItemActionPerformed
|
||||
|
||||
private void simMenuStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_simMenuStartActionPerformed
|
||||
startSim();
|
||||
@ -695,37 +828,58 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
||||
jd.setVisible(rootPaneCheckingEnabled);
|
||||
}//GEN-LAST:event_jCheckBoxMenuItem1ActionPerformed
|
||||
|
||||
private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
|
||||
Globals.se.pointZero();
|
||||
}//GEN-LAST:event_jMenuItem4ActionPerformed
|
||||
|
||||
TraderListDialog tld = null;
|
||||
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 (tld == null) {
|
||||
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");
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.SwingUtilities.invokeLater(() -> {
|
||||
|
||||
System.out.printf("Trwindow: %s\n", Boolean.toString(this.viewTraderListCheckBox.getState()));
|
||||
if (this.viewTraderListCheckBox.getState()) {
|
||||
if (tld == null) {
|
||||
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);
|
||||
} else if (tld != null) {
|
||||
System.out.printf("Set visible = false\n");
|
||||
tld.setVisible(false);
|
||||
}
|
||||
tld.setVisible(true);
|
||||
} else if (tld != null) {
|
||||
System.out.printf("Set visible = false\n");
|
||||
tld.setVisible(false);
|
||||
}
|
||||
});
|
||||
|
||||
}//GEN-LAST:event_viewTraderListCheckBoxActionPerformed
|
||||
|
||||
private void accelSpinnerPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_accelSpinnerPropertyChange
|
||||
System.out.printf("Accel Spinner PRop Change\n");
|
||||
// System.out.printf("Accel Spinner PRop Change\n");
|
||||
}//GEN-LAST:event_accelSpinnerPropertyChange
|
||||
|
||||
private void saveMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveMenuItemActionPerformed
|
||||
saveFile(false);
|
||||
|
||||
}//GEN-LAST:event_saveMenuItemActionPerformed
|
||||
|
||||
private void closeMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeMenuItemActionPerformed
|
||||
Globals.prefs.put(Globals.PrefKeys.CURRENTFILE, "");
|
||||
setTitle("");
|
||||
}//GEN-LAST:event_closeMenuItemActionPerformed
|
||||
|
||||
private void clearMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clearMenuItemActionPerformed
|
||||
|
||||
int dialogResult = JOptionPane.showConfirmDialog(this, "Are you sure?", "Warning", JOptionPane.YES_NO_OPTION);
|
||||
if (dialogResult != JOptionPane.YES_OPTION) {
|
||||
return;
|
||||
}
|
||||
Globals.clearAll();
|
||||
}//GEN-LAST:event_clearMenuItemActionPerformed
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
* @throws java.lang.IllegalAccessException
|
||||
@ -735,37 +889,40 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
||||
|
||||
System.out.printf("Main called\n");
|
||||
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
|
||||
GraphicsDevice[]gs = ge.getScreenDevices();
|
||||
for (GraphicsDevice d:gs){
|
||||
System.out.printf("ID %s\n",d.getIDstring());
|
||||
|
||||
|
||||
GraphicsDevice[] gs = ge.getScreenDevices();
|
||||
for (GraphicsDevice d : gs) {
|
||||
System.out.printf("ID %s\n", d.getIDstring());
|
||||
|
||||
}
|
||||
|
||||
//System.exit(0);
|
||||
|
||||
|
||||
|
||||
//System.exit(0);
|
||||
Globals.initGlobals();
|
||||
//System.exit(0);
|
||||
Globals.se = new Exchange();
|
||||
|
||||
Class<?> c = sesim.Exchange.class;
|
||||
Globals.prefs = Preferences.userNodeForPackage(c);
|
||||
Globals.prefs.put(Globals.PrefKeys.CURRENTFILE, "");
|
||||
|
||||
Globals.setLookAndFeel(Globals.prefs.get("laf", "Nimbus"));
|
||||
|
||||
JDialog.setDefaultLookAndFeelDecorated(true);
|
||||
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.printf("In run method now\n");
|
||||
|
||||
String x = new java.io.File(NewMDIApplication.class.getProtectionDomain()
|
||||
.getCodeSource()
|
||||
.getLocation()
|
||||
.getPath()).toString(); //.getName();
|
||||
|
||||
String x = new java.io.File(SeSimApplication.class.getProtectionDomain()
|
||||
.getCodeSource()
|
||||
.getLocation()
|
||||
.getPath()).toString(); //.getName();
|
||||
|
||||
System.out.printf("Creating Application\n");
|
||||
new NewMDIApplication().setVisible(true);
|
||||
|
||||
new SeSimApplication().setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -775,8 +932,9 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
||||
private javax.swing.JSpinner accelSpinner;
|
||||
private gui.MainChart chart;
|
||||
private javax.swing.JScrollPane chartSrollPane;
|
||||
private javax.swing.JMenuItem clearMenuItem;
|
||||
private gui.Clock clock;
|
||||
private javax.swing.JMenuItem contentMenuItem;
|
||||
private javax.swing.JMenuItem closeMenuItem;
|
||||
private javax.swing.JMenuItem deleteMenuItem;
|
||||
private javax.swing.JMenuItem editExchangeMenuItem;
|
||||
private javax.swing.JMenu editMenu;
|
||||
@ -787,15 +945,12 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
||||
private javax.swing.JButton jButton2;
|
||||
private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem1;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JMenuItem jMenuItem1;
|
||||
private javax.swing.JMenuItem jMenuItem3;
|
||||
private javax.swing.JMenuItem jMenuItem4;
|
||||
private javax.swing.JMenuItem jMenuItem5;
|
||||
private javax.swing.JPanel jPanel2;
|
||||
private javax.swing.JScrollPane jScrollPane2;
|
||||
private javax.swing.JPopupMenu.Separator jSeparator1;
|
||||
private javax.swing.JPopupMenu.Separator jSeparator2;
|
||||
private javax.swing.JPopupMenu.Separator jSeparator3;
|
||||
private javax.swing.JPopupMenu.Separator jSeparator4;
|
||||
private javax.swing.JPopupMenu.Separator jSeparator5;
|
||||
private javax.swing.JSplitPane jSplitPane1;
|
||||
private javax.swing.JSplitPane jSplitPane2;
|
||||
private javax.swing.JSplitPane jSplitPane3;
|
||||
@ -808,6 +963,7 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
||||
private gui.orderbook.OrderBooksHorizontal orderBooksHorizontal1;
|
||||
private javax.swing.JMenuItem pasteMenuItem;
|
||||
private gui.orderbook.QuoteVertical quoteVertical1;
|
||||
private javax.swing.JMenuItem resetToDefaultsMenuItem;
|
||||
private javax.swing.JButton runButton;
|
||||
private javax.swing.JMenuItem saveAsMenuItem;
|
||||
private javax.swing.JMenuItem saveMenuItem;
|
||||
@ -817,7 +973,6 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
||||
private javax.swing.JMenuItem simMenuStop;
|
||||
private gui.Statistics statistics1;
|
||||
private javax.swing.JButton stopButton;
|
||||
private javax.swing.JMenuItem viewClock;
|
||||
private javax.swing.JMenu viewMenu;
|
||||
private javax.swing.JCheckBoxMenuItem viewTraderListCheckBox;
|
||||
// End of variables declaration//GEN-END:variables
|
@ -3,8 +3,8 @@
|
||||
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<Properties>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
|
||||
<TitledBorder/>
|
||||
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
|
||||
<LineBorder/>
|
||||
</Border>
|
||||
</Property>
|
||||
</Properties>
|
||||
@ -23,13 +23,82 @@
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="380" max="32767" attributes="0"/>
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="labelHigh" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="labelLow" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="tradesLabel" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace pref="302" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="280" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="labelHigh" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="labelLow" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="tradesLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace pref="235" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Trades:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel2">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Heigh:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel3">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Low:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="labelHigh">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="100.00"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="labelLow">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="50.00"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="tradesLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="0"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
|
@ -25,6 +25,10 @@
|
||||
*/
|
||||
package gui;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import sesim.Exchange;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
@ -36,6 +40,29 @@ public class Statistics extends javax.swing.JPanel {
|
||||
*/
|
||||
public Statistics() {
|
||||
initComponents();
|
||||
|
||||
new Timer().schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
Exchange.Statistics s = Globals.se.getStatistics();
|
||||
|
||||
tradesLabel.setText(String.format("%d", s.trades));
|
||||
|
||||
if (s.heigh == null) {
|
||||
labelHigh.setText("--");
|
||||
} else {
|
||||
labelHigh.setText(Globals.se.getMoneyFormatter().format(s.heigh));
|
||||
}
|
||||
|
||||
if (s.low == null) {
|
||||
labelLow.setText("--");
|
||||
} else {
|
||||
labelLow.setText(Globals.se.getMoneyFormatter().format(s.low));
|
||||
}
|
||||
|
||||
}
|
||||
}, 1000, 1000);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -47,21 +74,74 @@ public class Statistics extends javax.swing.JPanel {
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
setBorder(javax.swing.BorderFactory.createTitledBorder(""));
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
jLabel2 = new javax.swing.JLabel();
|
||||
jLabel3 = new javax.swing.JLabel();
|
||||
labelHigh = new javax.swing.JLabel();
|
||||
labelLow = new javax.swing.JLabel();
|
||||
tradesLabel = new javax.swing.JLabel();
|
||||
|
||||
setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
|
||||
|
||||
jLabel1.setText("Trades:");
|
||||
|
||||
jLabel2.setText("Heigh:");
|
||||
|
||||
jLabel3.setText("Low:");
|
||||
|
||||
labelHigh.setText("100.00");
|
||||
|
||||
labelLow.setText("50.00");
|
||||
|
||||
tradesLabel.setText("0");
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 380, Short.MAX_VALUE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jLabel2)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(labelHigh))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jLabel3)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(labelLow))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jLabel1)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(tradesLabel)))
|
||||
.addContainerGap(302, Short.MAX_VALUE))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 280, Short.MAX_VALUE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel2)
|
||||
.addComponent(labelHigh))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel3)
|
||||
.addComponent(labelLow))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel1)
|
||||
.addComponent(tradesLabel))
|
||||
.addContainerGap(235, Short.MAX_VALUE))
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JLabel jLabel2;
|
||||
private javax.swing.JLabel jLabel3;
|
||||
private javax.swing.JLabel labelHigh;
|
||||
private javax.swing.JLabel labelLow;
|
||||
private javax.swing.JLabel tradesLabel;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
|
@ -24,7 +24,7 @@
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="traderListPanel22" alignment="0" pref="922" max="32767" attributes="0"/>
|
||||
<Component id="traderListPanel22" alignment="0" pref="714" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
|
@ -1,5 +1,7 @@
|
||||
package gui;
|
||||
|
||||
import java.awt.Dialog;
|
||||
|
||||
/*
|
||||
* Copyright (c) 2017, 7u83 <7u83@mail.ru>
|
||||
* All rights reserved.
|
||||
@ -40,7 +42,7 @@ public class TraderListDialog extends javax.swing.JDialog {
|
||||
public TraderListDialog(java.awt.Frame parent, boolean modal) {
|
||||
super(parent, modal);
|
||||
initComponents();
|
||||
// this.setLocationRelativeTo(MainWin.instance);
|
||||
setLocationRelativeTo(parent);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -61,7 +63,7 @@ public class TraderListDialog extends javax.swing.JDialog {
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(traderListPanel22, javax.swing.GroupLayout.DEFAULT_SIZE, 922, Short.MAX_VALUE)
|
||||
.addComponent(traderListPanel22, javax.swing.GroupLayout.DEFAULT_SIZE, 714, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
|
@ -31,6 +31,9 @@ import gui.tools.NummericCellRenderer;
|
||||
import java.awt.Component;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
@ -121,15 +124,26 @@ public class OrderBook extends javax.swing.JPanel implements Exchange.BookReceiv
|
||||
model = (DefaultTableModel) this.list.getModel();
|
||||
trader_column = list.getColumnModel().getColumn(0);
|
||||
list.getColumnModel().getColumn(1).setCellRenderer(new NummericCellRenderer(3));
|
||||
list.getColumnModel().getColumn(2).setCellRenderer(new NummericCellRenderer(0));
|
||||
list.getColumnModel().getColumn(2).setCellRenderer(new NummericCellRenderer(0));
|
||||
cfgChanged();
|
||||
// Globals.se.addBookReceiver(Exchange.OrderType.BUYLIMIT, this);
|
||||
Globals.addCfgListener(this);
|
||||
|
||||
new Timer().schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
// System.out.printf("Update order book\n");
|
||||
// UpdateOrderBook();
|
||||
}
|
||||
}, 1000, 1000);
|
||||
|
||||
}
|
||||
|
||||
boolean oupdate = false;
|
||||
boolean new_oupdate = false;
|
||||
|
||||
long ouctr = 0;
|
||||
|
||||
void oupdater() {
|
||||
ArrayList<Order> ob = Globals.se.getOrderBook(type, depth);
|
||||
model.setRowCount(ob.size());
|
||||
@ -141,24 +155,33 @@ public class OrderBook extends javax.swing.JPanel implements Exchange.BookReceiv
|
||||
row++;
|
||||
}
|
||||
|
||||
oupdate = false;
|
||||
synchronized (this) {
|
||||
oupdate = new_oupdate;
|
||||
new_oupdate = false;
|
||||
}
|
||||
if (oupdate) {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
oupdater();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void UpdateOrderBook() {
|
||||
public void UpdateOrderBook() {
|
||||
|
||||
if (oupdate) {
|
||||
new_oupdate=true;
|
||||
return;
|
||||
synchronized (this) {
|
||||
if (oupdate) {
|
||||
new_oupdate = true;
|
||||
return;
|
||||
}
|
||||
oupdate = true;
|
||||
}
|
||||
|
||||
oupdate = true;
|
||||
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
oupdater();
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user