Work on trader editor
This commit is contained in:
parent
e4f85ba418
commit
a11cf985a7
5
pom.xml
5
pom.xml
@ -23,11 +23,6 @@
|
||||
<artifactId>json</artifactId>
|
||||
<version>20160810</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jdesktop</groupId>
|
||||
<artifactId>beansbinding</artifactId>
|
||||
<version>1.2.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
@ -1,138 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
|
||||
<NonVisualComponents>
|
||||
<Menu class="javax.swing.JMenuBar" name="menuBar">
|
||||
<SubComponents>
|
||||
<Menu class="javax.swing.JMenu" name="fileMenu">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="102"/>
|
||||
<Property name="text" type="java.lang.String" value="File"/>
|
||||
</Properties>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="openMenuItem">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="111"/>
|
||||
<Property name="text" type="java.lang.String" value="Open"/>
|
||||
</Properties>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="saveMenuItem">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="115"/>
|
||||
<Property name="text" type="java.lang.String" value="Save"/>
|
||||
</Properties>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="saveAsMenuItem">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="97"/>
|
||||
<Property name="text" type="java.lang.String" value="Save As ..."/>
|
||||
<Property name="displayedMnemonicIndex" type="int" value="5"/>
|
||||
</Properties>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="exitMenuItem">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="120"/>
|
||||
<Property name="text" type="java.lang.String" value="Exit"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="exitMenuItemActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
<Menu class="javax.swing.JMenu" name="editMenu">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="101"/>
|
||||
<Property name="text" type="java.lang.String" value="Edit"/>
|
||||
</Properties>
|
||||
<SubComponents>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="cutMenuItem">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="116"/>
|
||||
<Property name="text" type="java.lang.String" value="Cut"/>
|
||||
</Properties>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="copyMenuItem">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="121"/>
|
||||
<Property name="text" type="java.lang.String" value="Copy"/>
|
||||
</Properties>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="pasteMenuItem">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="112"/>
|
||||
<Property name="text" type="java.lang.String" value="Paste"/>
|
||||
</Properties>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="deleteMenuItem">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="100"/>
|
||||
<Property name="text" type="java.lang.String" value="Delete"/>
|
||||
</Properties>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
<Menu class="javax.swing.JMenu" name="helpMenu">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="104"/>
|
||||
<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"/>
|
||||
<Property name="text" type="java.lang.String" value="About"/>
|
||||
</Properties>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
</NonVisualComponents>
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="3"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="menuBar" type="java.lang.String" value="menuBar"/>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<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">
|
||||
<Component id="desktopPane" pref="400" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="desktopPane" pref="279" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JDesktopPane" name="desktopPane">
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
|
||||
<Property name="useNullLayout" type="boolean" value="true"/>
|
||||
</Layout>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
@ -1,202 +0,0 @@
|
||||
/*
|
||||
* 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 chart;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class NewMDIApplication extends javax.swing.JFrame {
|
||||
|
||||
/**
|
||||
* Creates new form NewMDIApplication
|
||||
*/
|
||||
public NewMDIApplication() {
|
||||
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() {
|
||||
|
||||
desktopPane = new javax.swing.JDesktopPane();
|
||||
menuBar = new javax.swing.JMenuBar();
|
||||
fileMenu = new javax.swing.JMenu();
|
||||
openMenuItem = new javax.swing.JMenuItem();
|
||||
saveMenuItem = new javax.swing.JMenuItem();
|
||||
saveAsMenuItem = new javax.swing.JMenuItem();
|
||||
exitMenuItem = new javax.swing.JMenuItem();
|
||||
editMenu = new javax.swing.JMenu();
|
||||
cutMenuItem = new javax.swing.JMenuItem();
|
||||
copyMenuItem = new javax.swing.JMenuItem();
|
||||
pasteMenuItem = new javax.swing.JMenuItem();
|
||||
deleteMenuItem = new javax.swing.JMenuItem();
|
||||
helpMenu = new javax.swing.JMenu();
|
||||
contentMenuItem = new javax.swing.JMenuItem();
|
||||
aboutMenuItem = new javax.swing.JMenuItem();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
||||
|
||||
fileMenu.setMnemonic('f');
|
||||
fileMenu.setText("File");
|
||||
|
||||
openMenuItem.setMnemonic('o');
|
||||
openMenuItem.setText("Open");
|
||||
fileMenu.add(openMenuItem);
|
||||
|
||||
saveMenuItem.setMnemonic('s');
|
||||
saveMenuItem.setText("Save");
|
||||
fileMenu.add(saveMenuItem);
|
||||
|
||||
saveAsMenuItem.setMnemonic('a');
|
||||
saveAsMenuItem.setText("Save As ...");
|
||||
saveAsMenuItem.setDisplayedMnemonicIndex(5);
|
||||
fileMenu.add(saveAsMenuItem);
|
||||
|
||||
exitMenuItem.setMnemonic('x');
|
||||
exitMenuItem.setText("Exit");
|
||||
exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
exitMenuItemActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
fileMenu.add(exitMenuItem);
|
||||
|
||||
menuBar.add(fileMenu);
|
||||
|
||||
editMenu.setMnemonic('e');
|
||||
editMenu.setText("Edit");
|
||||
|
||||
cutMenuItem.setMnemonic('t');
|
||||
cutMenuItem.setText("Cut");
|
||||
editMenu.add(cutMenuItem);
|
||||
|
||||
copyMenuItem.setMnemonic('y');
|
||||
copyMenuItem.setText("Copy");
|
||||
editMenu.add(copyMenuItem);
|
||||
|
||||
pasteMenuItem.setMnemonic('p');
|
||||
pasteMenuItem.setText("Paste");
|
||||
editMenu.add(pasteMenuItem);
|
||||
|
||||
deleteMenuItem.setMnemonic('d');
|
||||
deleteMenuItem.setText("Delete");
|
||||
editMenu.add(deleteMenuItem);
|
||||
|
||||
menuBar.add(editMenu);
|
||||
|
||||
helpMenu.setMnemonic('h');
|
||||
helpMenu.setText("Help");
|
||||
|
||||
contentMenuItem.setMnemonic('c');
|
||||
contentMenuItem.setText("Contents");
|
||||
helpMenu.add(contentMenuItem);
|
||||
|
||||
aboutMenuItem.setMnemonic('a');
|
||||
aboutMenuItem.setText("About");
|
||||
helpMenu.add(aboutMenuItem);
|
||||
|
||||
menuBar.add(helpMenu);
|
||||
|
||||
setJMenuBar(menuBar);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 279, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed
|
||||
System.exit(0);
|
||||
}//GEN-LAST:event_exitMenuItemActionPerformed
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String args[]) {
|
||||
/* Set the Nimbus look and feel */
|
||||
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
|
||||
/* 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(NewMDIApplication.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (InstantiationException ex) {
|
||||
java.util.logging.Logger.getLogger(NewMDIApplication.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (IllegalAccessException ex) {
|
||||
java.util.logging.Logger.getLogger(NewMDIApplication.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||
java.util.logging.Logger.getLogger(NewMDIApplication.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/* Create and display the form */
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
new NewMDIApplication().setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JMenuItem aboutMenuItem;
|
||||
private javax.swing.JMenuItem contentMenuItem;
|
||||
private javax.swing.JMenuItem copyMenuItem;
|
||||
private javax.swing.JMenuItem cutMenuItem;
|
||||
private javax.swing.JMenuItem deleteMenuItem;
|
||||
private javax.swing.JDesktopPane desktopPane;
|
||||
private javax.swing.JMenu editMenu;
|
||||
private javax.swing.JMenuItem exitMenuItem;
|
||||
private javax.swing.JMenu fileMenu;
|
||||
private javax.swing.JMenu helpMenu;
|
||||
private javax.swing.JMenuBar menuBar;
|
||||
private javax.swing.JMenuItem openMenuItem;
|
||||
private javax.swing.JMenuItem pasteMenuItem;
|
||||
private javax.swing.JMenuItem saveAsMenuItem;
|
||||
private javax.swing.JMenuItem saveMenuItem;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
}
|
@ -18,7 +18,7 @@
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jScrollPane1" pref="388" max="32767" attributes="0"/>
|
||||
<Component id="jScrollPane1" pref="446" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
|
@ -66,6 +66,8 @@ public class EditAutoTraderList extends javax.swing.JPanel {
|
||||
JSONObject jo = new JSONObject();
|
||||
for (int x = 0; x < model.getColumnCount(); x++) {
|
||||
Object cw = model.getValueAt(i, x);
|
||||
|
||||
System.out.printf("CWSaver: %s\n",cw.getClass().toString());
|
||||
|
||||
if (cw != null) {
|
||||
jo.put((String) th.getColumnModel().getColumn(x).getHeaderValue(), cw.toString());
|
||||
@ -82,13 +84,12 @@ public class EditAutoTraderList extends javax.swing.JPanel {
|
||||
}
|
||||
|
||||
final void load() {
|
||||
String traders_json = Globals.prefs.get("Traders", "[]");
|
||||
JSONArray traders = new JSONArray(traders_json);
|
||||
|
||||
int size = traders.toList().size();
|
||||
System.out.printf("Size = %d\n", size);
|
||||
|
||||
for (int row = 0; row < size; row++) {
|
||||
JSONArray traders = Globals.getTraders();
|
||||
DefaultTableModel model = (DefaultTableModel) list.getModel();
|
||||
model.setRowCount(traders.length());
|
||||
|
||||
for (int row = 0; row < traders.length(); row++) {
|
||||
JSONObject rowobj = traders.getJSONObject(row);
|
||||
for (int col = 0; col < list.getColumnCount(); col++) {
|
||||
String h = this.getColumnHeader(col);
|
||||
@ -112,6 +113,9 @@ public class EditAutoTraderList extends javax.swing.JPanel {
|
||||
if (cl == Boolean.class) {
|
||||
cv = rowobj.getBoolean(h);
|
||||
}
|
||||
if (cl == Object.class){
|
||||
cv=rowobj.getString(h);
|
||||
}
|
||||
list.getModel().setValueAt(cv, row, col);
|
||||
|
||||
}
|
||||
@ -125,34 +129,30 @@ public class EditAutoTraderList extends javax.swing.JPanel {
|
||||
*/
|
||||
public EditAutoTraderList() {
|
||||
initComponents();
|
||||
|
||||
if (Globals.se==null)
|
||||
return;
|
||||
|
||||
this.load();
|
||||
|
||||
JComboBox comboBox = new JComboBox();
|
||||
|
||||
Globals.getStrategiesIntoComboBox(comboBox);
|
||||
|
||||
ArrayList<Class<AutoTraderConfig>> trconfigs = null;
|
||||
trconfigs = Globals.tloader.getTraders();
|
||||
|
||||
for (int i = 0; i < trconfigs.size(); i++) {
|
||||
try {
|
||||
AutoTraderConfig ac = trconfigs.get(i).newInstance();
|
||||
|
||||
comboBox.addItem(ac.getName());
|
||||
} catch (InstantiationException ex) {
|
||||
Logger.getLogger(EditAutoTraderList.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} catch (IllegalAccessException ex) {
|
||||
Logger.getLogger(EditAutoTraderList.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
// comboBox.addItem("AAA");
|
||||
// comboBox.addItem("BBB");
|
||||
DefaultTableModel model = (DefaultTableModel) list.getModel();
|
||||
list.getColumnModel().getColumn(2).setCellEditor(new DefaultCellEditor(comboBox));
|
||||
// list.getColumnModel().getColumn(2).setCellRenderer(new javax.swing.table.DefaultTableCellRenderer());
|
||||
// model.setRowCount(3);
|
||||
|
||||
list.setRowHeight(30);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void add(){
|
||||
DefaultTableModel model = (DefaultTableModel) list.getModel();
|
||||
model.setRowCount(model.getRowCount()+1);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -193,7 +193,7 @@ public class EditAutoTraderList extends javax.swing.JPanel {
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 388, Short.MAX_VALUE)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 446, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
|
@ -25,12 +25,14 @@
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="jButton2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jOkButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="editAutoTraderList1" alignment="1" max="32767" attributes="0"/>
|
||||
<Component id="editAutoTraderList1" alignment="1" pref="541" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
@ -41,6 +43,7 @@
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jButton1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jOkButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jButton2" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
@ -69,5 +72,13 @@
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jOkButtonActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="jButton2">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Add"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton2ActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
|
@ -54,6 +54,7 @@ public class EditAutoTraderListDialog extends javax.swing.JDialog {
|
||||
editAutoTraderList1 = new gui.EditAutoTraderList();
|
||||
jButton1 = new javax.swing.JButton();
|
||||
jOkButton = new javax.swing.JButton();
|
||||
jButton2 = new javax.swing.JButton();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
@ -74,17 +75,26 @@ public class EditAutoTraderListDialog extends javax.swing.JDialog {
|
||||
}
|
||||
});
|
||||
|
||||
jButton2.setText("Add");
|
||||
jButton2.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jButton2ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jButton2)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jOkButton)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jButton1)
|
||||
.addContainerGap())
|
||||
.addComponent(editAutoTraderList1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(editAutoTraderList1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 541, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
@ -93,7 +103,8 @@ public class EditAutoTraderListDialog extends javax.swing.JDialog {
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jButton1)
|
||||
.addComponent(jOkButton))
|
||||
.addComponent(jOkButton)
|
||||
.addComponent(jButton2))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
@ -110,6 +121,10 @@ public class EditAutoTraderListDialog extends javax.swing.JDialog {
|
||||
this.dispose();
|
||||
}//GEN-LAST:event_jButton1ActionPerformed
|
||||
|
||||
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
|
||||
this.editAutoTraderList1.add();
|
||||
}//GEN-LAST:event_jButton2ActionPerformed
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
@ -155,6 +170,7 @@ public class EditAutoTraderListDialog extends javax.swing.JDialog {
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private gui.EditAutoTraderList editAutoTraderList1;
|
||||
private javax.swing.JButton jButton1;
|
||||
private javax.swing.JButton jButton2;
|
||||
private javax.swing.JButton jOkButton;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
|
@ -26,9 +26,9 @@
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="lafLabel" min="-2" pref="106" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="80" max="-2" attributes="0"/>
|
||||
<Component id="lafComboBox" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
@ -39,8 +39,11 @@
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="cancelButton" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jCheckBox1" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jCheckBox2" alignment="0" min="-2" pref="99" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
@ -54,11 +57,13 @@
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="lafComboBox" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lafLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Component id="jCheckBox1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="200" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jCheckBox2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="191" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="applyButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
@ -88,11 +93,6 @@
|
||||
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="lafLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Look & Feel:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="cancelButton">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="99"/>
|
||||
@ -120,13 +120,21 @@
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okButtonActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="jCheckBox1">
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Development Traders"/>
|
||||
<Property name="text" type="java.lang.String" value="jLabel1"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="jCheckBox2">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="jCheckBox2"/>
|
||||
<Property name="horizontalTextPosition" type="int" value="10"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel2">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="jLabel2"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jCheckBox1ActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
|
@ -74,11 +74,12 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
|
||||
private void initComponents() {
|
||||
|
||||
lafComboBox = new javax.swing.JComboBox<>();
|
||||
lafLabel = new javax.swing.JLabel();
|
||||
cancelButton = new javax.swing.JButton();
|
||||
applyButton = new javax.swing.JButton();
|
||||
okButton = new javax.swing.JButton();
|
||||
jCheckBox1 = new javax.swing.JCheckBox();
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
jCheckBox2 = new javax.swing.JCheckBox();
|
||||
jLabel2 = new javax.swing.JLabel();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
@ -89,8 +90,6 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
|
||||
}
|
||||
});
|
||||
|
||||
lafLabel.setText("Look & Feel:");
|
||||
|
||||
cancelButton.setMnemonic('c');
|
||||
cancelButton.setText("Cancel");
|
||||
cancelButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
@ -115,12 +114,12 @@ 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);
|
||||
}
|
||||
});
|
||||
jLabel1.setText("jLabel1");
|
||||
|
||||
jCheckBox2.setText("jCheckBox2");
|
||||
jCheckBox2.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
|
||||
|
||||
jLabel2.setText("jLabel2");
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
@ -130,8 +129,8 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(lafLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jLabel1)
|
||||
.addGap(80, 80, 80)
|
||||
.addComponent(lafComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addGap(0, 201, Short.MAX_VALUE)
|
||||
@ -141,7 +140,9 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(cancelButton))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jCheckBox1)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jLabel2)
|
||||
.addComponent(jCheckBox2, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
.addContainerGap())
|
||||
);
|
||||
@ -151,10 +152,12 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
|
||||
.addContainerGap()
|
||||
.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))
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(jCheckBox1)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 200, Short.MAX_VALUE)
|
||||
.addComponent(jLabel1))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jLabel2)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jCheckBox2)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 191, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(cancelButton)
|
||||
.addComponent(applyButton)
|
||||
@ -207,10 +210,6 @@ 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
|
||||
*/
|
||||
@ -256,9 +255,10 @@ 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.JCheckBox jCheckBox2;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JLabel jLabel2;
|
||||
private javax.swing.JComboBox<String> lafComboBox;
|
||||
private javax.swing.JLabel lafLabel;
|
||||
private javax.swing.JButton okButton;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
|
@ -32,9 +32,13 @@
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace pref="275" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jScrollPane1" alignment="0" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
<Component id="jNewButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jRemoveButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jSaveButton" min="-2" max="-2" attributes="0"/>
|
||||
@ -44,40 +48,36 @@
|
||||
<Component id="jButton2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="9" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="jComboBoxStrategySelector" alignment="1" min="-2" pref="361" max="-2" attributes="0"/>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="jBaseLabel" pref="263" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jComboBoxStrategySelector" min="-2" pref="361" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
|
||||
<Component id="jScrollPane1" max="32767" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jComboBoxStrategySelector" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="459" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jComboBoxStrategySelector" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jBaseLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jScrollPane1" pref="425" max="32767" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jSaveButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jButton2" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jButton1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jRemoveButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jNewButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace min="-2" pref="41" max="-2" attributes="0"/>
|
||||
<Component id="jScrollPane1" max="32767" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="41" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
@ -118,15 +118,32 @@
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="612" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel2" pref="612" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="435" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel2" pref="407" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jLabel2">
|
||||
<Properties>
|
||||
<Property name="horizontalAlignment" type="int" value="0"/>
|
||||
<Property name="text" type="java.lang.String" value="No config available"/>
|
||||
<Property name="horizontalTextPosition" type="int" value="0"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
@ -165,5 +182,20 @@
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jRemoveButtonActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="jNewButton">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="110"/>
|
||||
<Property name="text" type="java.lang.String" value="New"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value=""/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jNewButtonActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jBaseLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="base"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
|
@ -45,6 +45,7 @@ import sesim.AutoTraderGui;
|
||||
*/
|
||||
public final class EditStrategies extends javax.swing.JDialog {
|
||||
|
||||
|
||||
TreeMap<String, JSONObject> strategies = new TreeMap();
|
||||
|
||||
void initComboBox() {
|
||||
@ -52,13 +53,15 @@ public final class EditStrategies extends javax.swing.JDialog {
|
||||
this.reloadStrategyConfigs();
|
||||
|
||||
this.jComboBoxStrategySelector.removeAllItems();
|
||||
ArrayList<String> sn = Globals.tloader.getDefaultStrategyNames();
|
||||
|
||||
/*
|
||||
ArrayList<String> sn = Globals.tloader.getDefaultStrategyNames();
|
||||
*/
|
||||
Iterator<String> i = strategies.keySet().iterator();
|
||||
while (i.hasNext()) {
|
||||
|
||||
this.jComboBoxStrategySelector.addItem(i.next());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -83,30 +86,14 @@ public final class EditStrategies extends javax.swing.JDialog {
|
||||
|
||||
void reloadStrategyConfigs() {
|
||||
|
||||
ArrayList<String> sn = Globals.tloader.getDefaultStrategyNames();
|
||||
strategies = new TreeMap();
|
||||
|
||||
for (String s : sn) {
|
||||
JSONObject e = new JSONObject();
|
||||
// System.out.printf("String put %s\n", s);
|
||||
|
||||
this.strategies.put(s, null);
|
||||
|
||||
}
|
||||
|
||||
String cfglist = Globals.prefs.get(STRATEGYPREFS, "{}");
|
||||
JSONObject cfgs = new JSONObject(cfglist);
|
||||
|
||||
|
||||
|
||||
JSONObject cfgs = Globals.getStrategies();
|
||||
|
||||
Iterator<String> i = cfgs.keys();
|
||||
while (i.hasNext()) {
|
||||
|
||||
String k = i.next();
|
||||
JSONObject o = cfgs.getJSONObject(k);
|
||||
strategies.put(k, o);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -125,10 +112,13 @@ public final class EditStrategies extends javax.swing.JDialog {
|
||||
jScrollPane1 = new javax.swing.JScrollPane();
|
||||
guiPanel = new javax.swing.JPanel();
|
||||
defaultGuiPanel = new javax.swing.JPanel();
|
||||
jLabel2 = new javax.swing.JLabel();
|
||||
jSaveButton = new javax.swing.JButton();
|
||||
jButton2 = new javax.swing.JButton();
|
||||
jButton1 = new javax.swing.JButton();
|
||||
jRemoveButton = new javax.swing.JButton();
|
||||
jNewButton = new javax.swing.JButton();
|
||||
jBaseLabel = new javax.swing.JLabel();
|
||||
|
||||
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
|
||||
jLabel1.setText("No config available");
|
||||
@ -144,15 +134,25 @@ public final class EditStrategies extends javax.swing.JDialog {
|
||||
|
||||
guiPanel.setLayout(new java.awt.BorderLayout());
|
||||
|
||||
jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
|
||||
jLabel2.setText("No config available");
|
||||
jLabel2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
||||
|
||||
javax.swing.GroupLayout defaultGuiPanelLayout = new javax.swing.GroupLayout(defaultGuiPanel);
|
||||
defaultGuiPanel.setLayout(defaultGuiPanelLayout);
|
||||
defaultGuiPanelLayout.setHorizontalGroup(
|
||||
defaultGuiPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 612, Short.MAX_VALUE)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, defaultGuiPanelLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 612, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
);
|
||||
defaultGuiPanelLayout.setVerticalGroup(
|
||||
defaultGuiPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 435, Short.MAX_VALUE)
|
||||
.addGroup(defaultGuiPanelLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 407, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
guiPanel.add(defaultGuiPanel, java.awt.BorderLayout.CENTER);
|
||||
@ -186,14 +186,29 @@ public final class EditStrategies extends javax.swing.JDialog {
|
||||
}
|
||||
});
|
||||
|
||||
jNewButton.setMnemonic('n');
|
||||
jNewButton.setText("New");
|
||||
jNewButton.setToolTipText("");
|
||||
jNewButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jNewButtonActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jBaseLabel.setText("base");
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap(275, Short.MAX_VALUE)
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jScrollPane1)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
.addComponent(jNewButton)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jRemoveButton)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jSaveButton)
|
||||
@ -202,31 +217,29 @@ public final class EditStrategies extends javax.swing.JDialog {
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jButton2)
|
||||
.addGap(9, 9, 9))
|
||||
.addComponent(jComboBoxStrategySelector, 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(jBaseLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 263, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jComboBoxStrategySelector, javax.swing.GroupLayout.PREFERRED_SIZE, 361, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addContainerGap())
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(12, 12, 12)
|
||||
.addComponent(jScrollPane1)
|
||||
.addGap(12, 12, 12)))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jComboBoxStrategySelector, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 459, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jComboBoxStrategySelector, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jBaseLabel))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 425, Short.MAX_VALUE)
|
||||
.addGap(12, 12, 12)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jSaveButton)
|
||||
.addComponent(jButton2)
|
||||
.addComponent(jButton1)
|
||||
.addComponent(jRemoveButton))
|
||||
.addComponent(jRemoveButton)
|
||||
.addComponent(jNewButton))
|
||||
.addContainerGap())
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(41, 41, 41)
|
||||
.addComponent(jScrollPane1)
|
||||
.addGap(41, 41, 41)))
|
||||
);
|
||||
|
||||
pack();
|
||||
@ -262,15 +275,17 @@ public final class EditStrategies extends javax.swing.JDialog {
|
||||
|
||||
System.out.printf("Base %s\n", base);
|
||||
|
||||
ac = Globals.tloader.getStrategy(base);
|
||||
ac = Globals.tloader.getStrategyBase(base);
|
||||
if (ac == null) {
|
||||
System.out.print("BASE IST NULL\n");
|
||||
System.exit(0);
|
||||
Globals.LOGGER.info(String.format("Can't load: %s\n", base));
|
||||
//System.exit(0);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ac.putConfig(o);
|
||||
this.jBaseLabel.setText(base);
|
||||
|
||||
acgui = ac.getGui();
|
||||
guiPanel.removeAll();
|
||||
@ -303,7 +318,16 @@ public final class EditStrategies extends javax.swing.JDialog {
|
||||
JSONObject o = ac.getConfig();
|
||||
|
||||
String item = (String) this.jComboBoxStrategySelector.getSelectedItem();
|
||||
o.put("base", ac.getName());
|
||||
|
||||
// o.put("base", ac.getDisplayName());
|
||||
o.put("base", ac.getClass().getCanonicalName());
|
||||
|
||||
System.out.printf("The big name: %s\n", ac.getClass().getCanonicalName());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
JSONObject o0 = strategies.get(item);
|
||||
|
||||
if (o0 == null) {
|
||||
@ -358,6 +382,19 @@ public final class EditStrategies extends javax.swing.JDialog {
|
||||
|
||||
}//GEN-LAST:event_jRemoveButtonActionPerformed
|
||||
|
||||
private void jNewButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jNewButtonActionPerformed
|
||||
NewStrategyDialog sd = new NewStrategyDialog((Frame) this.getParent(),true);
|
||||
sd.setVisible(true);
|
||||
|
||||
if (sd.result==null)
|
||||
return;
|
||||
|
||||
AutoTraderConfig ac = Globals.tloader.getStrategyBase(sd.result.base);
|
||||
JSONObject cfg = ac.getConfig();
|
||||
Globals.saveStrategy(sd.result.name, cfg);
|
||||
this.initComboBox();
|
||||
}//GEN-LAST:event_jNewButtonActionPerformed
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
@ -404,10 +441,13 @@ public final class EditStrategies 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.JLabel jBaseLabel;
|
||||
private javax.swing.JButton jButton1;
|
||||
private javax.swing.JButton jButton2;
|
||||
private javax.swing.JComboBox<String> jComboBoxStrategySelector;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JLabel jLabel2;
|
||||
private javax.swing.JButton jNewButton;
|
||||
private javax.swing.JButton jRemoveButton;
|
||||
private javax.swing.JButton jSaveButton;
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
|
38
src/main/java/gui/EscDialog.form
Normal file
38
src/main/java/gui/EscDialog.form
Normal file
@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<Events>
|
||||
<EventHandler event="keyReleased" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="formKeyReleased"/>
|
||||
</Events>
|
||||
<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">
|
||||
<EmptySpace min="0" pref="400" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="300" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
</Form>
|
120
src/main/java/gui/EscDialog.java
Normal file
120
src/main/java/gui/EscDialog.java
Normal file
@ -0,0 +1,120 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class EscDialog extends javax.swing.JDialog {
|
||||
|
||||
/**
|
||||
* Creates new form EscDialog
|
||||
*/
|
||||
public EscDialog(java.awt.Frame parent, boolean modal) {
|
||||
super(parent, modal);
|
||||
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() {
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
addKeyListener(new java.awt.event.KeyAdapter() {
|
||||
public void keyReleased(java.awt.event.KeyEvent evt) {
|
||||
formKeyReleased(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 400, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 300, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void formKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_formKeyReleased
|
||||
dispose();
|
||||
}//GEN-LAST:event_formKeyReleased
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String args[]) {
|
||||
/* Set the Nimbus look and feel */
|
||||
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
|
||||
/* 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(EscDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (InstantiationException ex) {
|
||||
java.util.logging.Logger.getLogger(EscDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (IllegalAccessException ex) {
|
||||
java.util.logging.Logger.getLogger(EscDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||
java.util.logging.Logger.getLogger(EscDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/* Create and display the dialog */
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
EscDialog dialog = new EscDialog(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
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
@ -25,10 +25,15 @@
|
||||
*/
|
||||
package gui;
|
||||
|
||||
import chart.NewMDIApplication;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.TreeMap;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.prefs.Preferences;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.UIManager;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import sesim.AutoTraderLoader;
|
||||
|
||||
/**
|
||||
@ -37,6 +42,9 @@ import sesim.AutoTraderLoader;
|
||||
*/
|
||||
public class Globals {
|
||||
|
||||
static final String STRATEGYPREFS = "Strategies";
|
||||
static final String TRADERPREFS = "Traders";
|
||||
|
||||
static public sesim.Exchange se;
|
||||
|
||||
static public Preferences prefs;
|
||||
@ -64,10 +72,55 @@ public class Globals {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static AutoTraderLoader tloader=new AutoTraderLoader();
|
||||
|
||||
|
||||
static AutoTraderLoader tloader = new AutoTraderLoader();
|
||||
|
||||
static final Logger LOGGER = Logger.getLogger("com.cauwersin.sesim");
|
||||
|
||||
static public final JSONArray getTraders() {
|
||||
String traders_json = Globals.prefs.get(TRADERPREFS, "[]");
|
||||
JSONArray traders = new JSONArray(traders_json);
|
||||
return traders;
|
||||
}
|
||||
|
||||
static public final JSONObject getStrategies() {
|
||||
String cfglist = Globals.prefs.get(STRATEGYPREFS, "{}");
|
||||
JSONObject cfgs = new JSONObject(cfglist);
|
||||
return cfgs;
|
||||
}
|
||||
|
||||
static public JSONObject getStrategy(String name){
|
||||
return getStrategies().getJSONObject(name);
|
||||
}
|
||||
|
||||
static public void getStrategiesIntoComboBox(JComboBox comboBox) {
|
||||
TreeMap stm = getStrategiesAsTreeMap();
|
||||
comboBox.removeAllItems();
|
||||
|
||||
Iterator<String> i = stm.keySet().iterator();
|
||||
while (i.hasNext()) {
|
||||
comboBox.addItem(i.next());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static public TreeMap getStrategiesAsTreeMap() {
|
||||
TreeMap strategies = new TreeMap();
|
||||
JSONObject cfgs = Globals.getStrategies();
|
||||
|
||||
Iterator<String> i = cfgs.keys();
|
||||
while (i.hasNext()) {
|
||||
String k = i.next();
|
||||
JSONObject o = cfgs.getJSONObject(k);
|
||||
strategies.put(k, o);
|
||||
}
|
||||
return strategies;
|
||||
}
|
||||
|
||||
static public final void saveStrategy(String name, JSONObject cfg) {
|
||||
JSONObject cfgs = getStrategies();
|
||||
cfgs.put(name, cfg);
|
||||
prefs.put(STRATEGYPREFS, cfgs.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -289,19 +289,19 @@ public class MainWin extends javax.swing.JFrame {
|
||||
*/
|
||||
/* try {
|
||||
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
|
||||
if ("Motif".equals(info.getName())) {
|
||||
if ("Motif".equals(info.getDisplayName())) {
|
||||
javax.swing.UIManager.setLookAndFeel(info.getClassName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException ex) {
|
||||
java.util.logging.Logger.getLogger(MainWin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
java.util.logging.Logger.getLogger(MainWin.class.getDisplayName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (InstantiationException ex) {
|
||||
java.util.logging.Logger.getLogger(MainWin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
java.util.logging.Logger.getLogger(MainWin.class.getDisplayName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (IllegalAccessException ex) {
|
||||
java.util.logging.Logger.getLogger(MainWin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
java.util.logging.Logger.getLogger(MainWin.class.getDisplayName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||
java.util.logging.Logger.getLogger(MainWin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
java.util.logging.Logger.getLogger(MainWin.class.getDisplayName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
*/
|
||||
//</editor-fold>
|
||||
|
@ -34,6 +34,8 @@ import java.util.logging.Logger;
|
||||
import java.util.prefs.Preferences;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.UIManager;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import sesim.AutoTrader;
|
||||
import sesim.AutoTraderConfig;
|
||||
import sesim.Exchange;
|
||||
@ -56,6 +58,42 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
||||
|
||||
public void startTraders() {
|
||||
|
||||
JSONArray tlist = Globals.getTraders();
|
||||
for (int i=0; i<tlist.length();i++){
|
||||
JSONObject t=tlist.getJSONObject(i);
|
||||
String strategy_name = t.getString("Strategy");
|
||||
JSONObject strategy = Globals.getStrategy(strategy_name);
|
||||
String base = strategy.getString("base");
|
||||
AutoTraderConfig ac = Globals.tloader.getStrategyBase(base);
|
||||
|
||||
System.out.printf("Load Strat: %s\n",strategy_name);
|
||||
System.out.printf("Base %s\n", base);
|
||||
Integer count = t.getInt("Count");
|
||||
Double shares = t.getDouble("Shares");
|
||||
Double money = t.getDouble("Money");
|
||||
|
||||
System.out.printf("Count: %d Shares: %f Money %f\n", count,shares,money);
|
||||
|
||||
|
||||
|
||||
for (int i1=0;i1<count;i1++){
|
||||
AutoTrader trader = ac.createTrader(Globals.se, strategy, money, shares);
|
||||
Globals.se.traders.add(trader);
|
||||
trader.setName(t.getString("Name"));
|
||||
trader.start();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//AutoTraderConfig ac = Globals.tloader.getStrategyBase(t.getString("base"));
|
||||
//ac.putConfig(t);
|
||||
|
||||
}
|
||||
|
||||
// System.exit(0);
|
||||
|
||||
|
||||
/*
|
||||
AutoTraderConfig cfg1 = new RandomTraderConfig();
|
||||
AutoTrader rt1 = cfg1.createTrader(Globals.se, null, 100000, 100000);
|
||||
Globals.se.traders.add(rt1);
|
||||
@ -72,6 +110,7 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
||||
randt.setName("Bob");
|
||||
randt.start();
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
@ -404,7 +443,7 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
||||
|
||||
for (Class<AutoTraderConfig> at_class : traders) {
|
||||
AutoTraderConfig cfg = at_class.newInstance();
|
||||
System.out.printf("Have a Trader with name: %s\n", cfg.getName());
|
||||
System.out.printf("Have a Trader with name: %s\n", cfg.getDisplayName());
|
||||
}
|
||||
|
||||
//System.exit(0);
|
||||
|
125
src/main/java/gui/NewStrategyDialog.form
Normal file
125
src/main/java/gui/NewStrategyDialog.form
Normal file
@ -0,0 +1,125 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||
<Property name="title" type="java.lang.String" value="Create Strategy"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<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">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace min="0" pref="268" max="32767" attributes="0"/>
|
||||
<Component id="jOkButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jButton2" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jStrategyComboBox" max="32767" attributes="0"/>
|
||||
<Component id="jTextField1" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</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="3" attributes="0">
|
||||
<Component id="jStrategyComboBox" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jTextField1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace pref="23" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jOkButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jButton2" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JComboBox" name="jStrategyComboBox">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
|
||||
<StringArray count="4">
|
||||
<StringItem index="0" value="Item 1"/>
|
||||
<StringItem index="1" value="Item 2"/>
|
||||
<StringItem index="2" value="Item 3"/>
|
||||
<StringItem index="3" value="Item 4"/>
|
||||
</StringArray>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="jOkButton">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Ok"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jOkButtonActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="jButton2">
|
||||
<Properties>
|
||||
<Property name="mnemonic" type="int" value="99"/>
|
||||
<Property name="text" type="java.lang.String" value="Cancel"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value=""/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton2ActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Base:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="jTextField1">
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jTextField1ActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel2">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Name:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
223
src/main/java/gui/NewStrategyDialog.java
Normal file
223
src/main/java/gui/NewStrategyDialog.java
Normal file
@ -0,0 +1,223 @@
|
||||
/*
|
||||
* 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.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
//public class NewStrategyDialog extends javax.swing.JDialog {
|
||||
public class NewStrategyDialog extends EscDialog {
|
||||
|
||||
/**
|
||||
* Creates new form NewStrategyDialog
|
||||
*/
|
||||
public NewStrategyDialog(java.awt.Frame parent, boolean modal) {
|
||||
super(parent, modal);
|
||||
initComponents();
|
||||
this.setLocationRelativeTo(this.getParent());
|
||||
ArrayList <String> names = Globals.tloader.getDefaultStrategyNames();
|
||||
this.jStrategyComboBox.removeAllItems();
|
||||
names.stream().forEach((s) -> {
|
||||
this.jStrategyComboBox.addItem(s);
|
||||
});
|
||||
}
|
||||
|
||||
class Result{
|
||||
String base;
|
||||
String name;
|
||||
}
|
||||
|
||||
Result result=null;
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
jStrategyComboBox = new javax.swing.JComboBox<>();
|
||||
jOkButton = new javax.swing.JButton();
|
||||
jButton2 = new javax.swing.JButton();
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
jTextField1 = new javax.swing.JTextField();
|
||||
jLabel2 = new javax.swing.JLabel();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
setTitle("Create Strategy");
|
||||
|
||||
jStrategyComboBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
|
||||
|
||||
jOkButton.setText("Ok");
|
||||
jOkButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jOkButtonActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jButton2.setMnemonic('c');
|
||||
jButton2.setText("Cancel");
|
||||
jButton2.setToolTipText("");
|
||||
jButton2.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jButton2ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jLabel1.setText("Base:");
|
||||
|
||||
jTextField1.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jTextField1ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jLabel2.setText("Name:");
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addGap(0, 268, Short.MAX_VALUE)
|
||||
.addComponent(jOkButton)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jButton2))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jLabel1)
|
||||
.addComponent(jLabel2))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jStrategyComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jTextField1))))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jStrategyComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel1))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel2))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 23, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jOkButton)
|
||||
.addComponent(jButton2))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
|
||||
// TODO add your handling code here:
|
||||
}//GEN-LAST:event_jTextField1ActionPerformed
|
||||
|
||||
private void saveResult(){
|
||||
String name = this.jTextField1.getText();
|
||||
if (name.equals("")){
|
||||
return;
|
||||
}
|
||||
|
||||
this.result = new Result();
|
||||
this.result.base = (String) this.jStrategyComboBox.getSelectedItem();
|
||||
this.result.name = name;
|
||||
this.dispose();
|
||||
|
||||
}
|
||||
|
||||
private void jOkButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jOkButtonActionPerformed
|
||||
this.saveResult();
|
||||
}//GEN-LAST:event_jOkButtonActionPerformed
|
||||
|
||||
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
|
||||
// TODO add your handling code here:
|
||||
}//GEN-LAST:event_jButton2ActionPerformed
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String args[]) {
|
||||
/* Set the Nimbus look and feel */
|
||||
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
|
||||
/* 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(NewStrategyDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (InstantiationException ex) {
|
||||
java.util.logging.Logger.getLogger(NewStrategyDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (IllegalAccessException ex) {
|
||||
java.util.logging.Logger.getLogger(NewStrategyDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||
java.util.logging.Logger.getLogger(NewStrategyDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/* Create and display the dialog */
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
NewStrategyDialog dialog = new NewStrategyDialog(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.JButton jButton2;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JLabel jLabel2;
|
||||
private javax.swing.JButton jOkButton;
|
||||
private javax.swing.JComboBox<String> jStrategyComboBox;
|
||||
private javax.swing.JTextField jTextField1;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
@ -34,7 +34,7 @@ import org.json.JSONObject;
|
||||
*/
|
||||
public abstract interface AutoTraderConfig {
|
||||
public abstract AutoTrader createTrader(Exchange se, JSONObject cfg,double money, double shares);
|
||||
public abstract String getName();
|
||||
public abstract String getDisplayName();
|
||||
public abstract AutoTraderGui getGui();
|
||||
public abstract JSONObject getConfig();
|
||||
public abstract void putConfig(JSONObject cfg);
|
||||
|
@ -113,7 +113,7 @@ public class AutoTraderLoader {
|
||||
while ((entry = is.getNextJarEntry()) != null) {
|
||||
if (entry.getName().endsWith(".class")) {
|
||||
|
||||
// System.out.printf("Entry: %s\n", entry.getName());
|
||||
// System.out.printf("Entry: %s\n", entry.getDisplayName());
|
||||
|
||||
}
|
||||
}
|
||||
@ -155,7 +155,7 @@ public class AutoTraderLoader {
|
||||
for (int i = 0; i < trclasses.size(); i++) {
|
||||
try {
|
||||
AutoTraderConfig ac = trclasses.get(i).newInstance();
|
||||
ret.add(ac.getName());
|
||||
ret.add(ac.getClass().getCanonicalName());
|
||||
} catch (Exception ex) {
|
||||
|
||||
}
|
||||
@ -165,14 +165,19 @@ public class AutoTraderLoader {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public AutoTraderConfig getStrategy(String name) {
|
||||
public AutoTraderConfig getStrategyBase(String name) {
|
||||
ArrayList<Class<AutoTraderConfig>> traders = this.getTraders();
|
||||
for (int i = 0; i < traders.size(); i++) {
|
||||
try {
|
||||
AutoTraderConfig ac = traders.get(i).newInstance();
|
||||
|
||||
if (ac.getName().equals(name)) {
|
||||
System.out.printf("Looking for in %s == %s\n", ac.getClass().getCanonicalName(),name);
|
||||
|
||||
if (ac.getClass().getCanonicalName().equals(name)){
|
||||
return ac;
|
||||
|
||||
// if (ac.getDisplayName().equals(name)) {
|
||||
// return ac;}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public class RandomTrader extends AutoTrader {
|
||||
public long timerTask() {
|
||||
sesim.Exchange.Account a = se.getAccount(account_id);
|
||||
long rc = this.doTrade();
|
||||
return rc / 100;
|
||||
return rc /1;
|
||||
|
||||
// return this.event();
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public class RandomTraderConfig implements AutoTraderConfig {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
public String getDisplayName() {
|
||||
return "Random A";
|
||||
}
|
||||
|
||||
@ -89,6 +89,7 @@ public class RandomTraderConfig implements AutoTraderConfig {
|
||||
jo.put(BUY_WAIT, buy_wait);
|
||||
jo.put(WAIT_AFTER_SELL, wait_after_sell);
|
||||
jo.put(WAIT_AFTER_BUY, wait_after_buy);
|
||||
jo.put("base",this.getClass().getCanonicalName());
|
||||
|
||||
return jo;
|
||||
}
|
||||
@ -135,12 +136,12 @@ public class RandomTraderConfig implements AutoTraderConfig {
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.printf("Putconfig %s\n", cfg.toString(4));
|
||||
// System.out.printf("Putconfig %s\n", cfg.toString(4));
|
||||
|
||||
String cname = cfg.get(SELL_VOLUME).getClass().getName();
|
||||
|
||||
// JSONArray a = cfg.getJSONArray(SELL_VOLUME);
|
||||
System.out.printf("Array = %s \n", cname);
|
||||
// System.out.printf("Array = %s \n", cname);
|
||||
|
||||
sell_volume = to_float(cfg.getJSONArray(SELL_VOLUME));
|
||||
buy_volume = to_float(cfg.getJSONArray(BUY_VOLUME));
|
||||
|
@ -44,7 +44,7 @@ public class SuperTraderConfig implements AutoTraderConfig{
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
public String getDisplayName() {
|
||||
return "SuperTrader";
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ public class SwitchingTraderConfig extends RandomTraderConfig implements AutoTra
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName(){
|
||||
public String getDisplayName(){
|
||||
return "SwitchingTrader";
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user