json integration ...
This commit is contained in:
parent
22ac291e84
commit
78433352bc
10
pom.xml
10
pom.xml
@ -18,6 +18,16 @@
|
|||||||
<version>1.3</version>
|
<version>1.3</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.json</groupId>
|
||||||
|
<artifactId>json</artifactId>
|
||||||
|
<version>20160810</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.seaglasslookandfeel</groupId>
|
||||||
|
<artifactId>seaglasslookandfeel</artifactId>
|
||||||
|
<version>0.2.1</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
@ -25,9 +25,13 @@
|
|||||||
*/
|
*/
|
||||||
package gui;
|
package gui;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import javax.swing.table.AbstractTableModel;
|
import javax.swing.table.AbstractTableModel;
|
||||||
import javax.swing.table.DefaultTableModel;
|
import javax.swing.table.DefaultTableModel;
|
||||||
import javax.swing.table.JTableHeader;
|
import javax.swing.table.JTableHeader;
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -40,27 +44,32 @@ public class EditAutoTraderList extends javax.swing.JPanel {
|
|||||||
JTableHeader th = list.getTableHeader();
|
JTableHeader th = list.getTableHeader();
|
||||||
|
|
||||||
for (int i = 0; i < model.getColumnCount(); i++) {
|
for (int i = 0; i < model.getColumnCount(); i++) {
|
||||||
String hw = (String) th.getColumnModel().getColumn(0).getHeaderValue();
|
String hw = (String) th.getColumnModel().getColumn(i).getHeaderValue();
|
||||||
System.out.printf("%s\t", hw);
|
System.out.printf("%s\t", hw);
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println();
|
System.out.println();
|
||||||
|
|
||||||
|
// JSONObject ja = new JSONObject();
|
||||||
|
JSONArray ja = new JSONArray();
|
||||||
|
|
||||||
for (int i = 0; i < model.getRowCount(); i++) {
|
for (int i = 0; i < model.getRowCount(); i++) {
|
||||||
|
JSONObject jo = new JSONObject();
|
||||||
for (int x = 0; x < model.getColumnCount(); x++) {
|
for (int x = 0; x < model.getColumnCount(); x++) {
|
||||||
Object cw = model.getValueAt(i, x);
|
Object cw = model.getValueAt(i, x);
|
||||||
if (cw != null) {
|
|
||||||
System.out.printf("%s\t", cw.toString());
|
|
||||||
//model.getValueAt(i, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println();
|
if (cw != null) {
|
||||||
|
jo.put((String) th.getColumnModel().getColumn(x).getHeaderValue(), cw.toString());
|
||||||
|
}
|
||||||
|
//ja.put(Integer.toString(i),jo);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
ja.put(jo);
|
||||||
System.out.println();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Globals.prefs.put("Traders", ja.toString());
|
||||||
|
|
||||||
|
// System.out.printf("Arlist: %s\n", ja.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -51,6 +51,8 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
|
|||||||
for (UIManager.LookAndFeelInfo lafInfo1 : lafInfo) {
|
for (UIManager.LookAndFeelInfo lafInfo1 : lafInfo) {
|
||||||
lafComboBox.addItem(lafInfo1.getName());
|
lafComboBox.addItem(lafInfo1.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lafComboBox.setSelectedItem(Globals.prefs.get("laf", "Nimbus"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -153,7 +155,11 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
|
|||||||
String selected = (String) this.lafComboBox.getSelectedItem();
|
String selected = (String) this.lafComboBox.getSelectedItem();
|
||||||
|
|
||||||
System.out.printf("Selected %s\n", selected);
|
System.out.printf("Selected %s\n", selected);
|
||||||
|
|
||||||
|
Globals.setLookAndFeel(selected);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
for (UIManager.LookAndFeelInfo lafInfo1 : this.lafInfo) {
|
for (UIManager.LookAndFeelInfo lafInfo1 : this.lafInfo) {
|
||||||
if (lafInfo1.getName().equals(selected)) {
|
if (lafInfo1.getName().equals(selected)) {
|
||||||
String lafClassName = lafInfo1.getClassName();
|
String lafClassName = lafInfo1.getClassName();
|
||||||
@ -165,6 +171,8 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
for (Window w : Window.getWindows()) {
|
for (Window w : Window.getWindows()) {
|
||||||
System.out.print("Setting frame\n");
|
System.out.print("Setting frame\n");
|
||||||
SwingUtilities.updateComponentTreeUI(w);
|
SwingUtilities.updateComponentTreeUI(w);
|
||||||
@ -175,6 +183,8 @@ public class EditPreferencesDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
|
private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
|
||||||
this.applyButtonActionPerformed(evt);
|
this.applyButtonActionPerformed(evt);
|
||||||
|
String selected = (String) this.lafComboBox.getSelectedItem();
|
||||||
|
Globals.prefs.put("laf", selected);
|
||||||
this.dispose();
|
this.dispose();
|
||||||
}//GEN-LAST:event_okButtonActionPerformed
|
}//GEN-LAST:event_okButtonActionPerformed
|
||||||
|
|
||||||
|
@ -25,6 +25,10 @@
|
|||||||
*/
|
*/
|
||||||
package gui;
|
package gui;
|
||||||
|
|
||||||
|
import chart.NewMDIApplication;
|
||||||
|
import java.util.prefs.Preferences;
|
||||||
|
import javax.swing.UIManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author 7u83 <7u83@mail.ru>
|
* @author 7u83 <7u83@mail.ru>
|
||||||
@ -33,4 +37,35 @@ public class Globals {
|
|||||||
|
|
||||||
static public sesim.Exchange se;
|
static public sesim.Exchange se;
|
||||||
|
|
||||||
|
static public Preferences prefs;
|
||||||
|
|
||||||
|
static void setLookAndFeel(String selected){
|
||||||
|
|
||||||
|
try {
|
||||||
|
String look = "com.seaglasslookandfeel.SeaGlassLookAndFeel";
|
||||||
|
Class.forName(look);
|
||||||
|
UIManager.installLookAndFeel("Sea Glass", look);
|
||||||
|
}catch (ClassNotFoundException e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
UIManager.LookAndFeelInfo[] lafInfo = UIManager.getInstalledLookAndFeels();
|
||||||
|
for (UIManager.LookAndFeelInfo lafInfo1 : lafInfo) {
|
||||||
|
if (lafInfo1.getName().equals(selected)) {
|
||||||
|
String lafClassName = lafInfo1.getClassName();
|
||||||
|
try {
|
||||||
|
UIManager.setLookAndFeel(lafClassName);
|
||||||
|
// UIManager.setLookAndFeel("com.seaglasslookandfeel.SeaGlassLookAndFeel");
|
||||||
|
break;
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,9 @@ package gui;
|
|||||||
import java.awt.Dialog;
|
import java.awt.Dialog;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.prefs.Preferences;
|
||||||
import javax.swing.JFileChooser;
|
import javax.swing.JFileChooser;
|
||||||
|
import javax.swing.UIManager;
|
||||||
import sesim.AutoTrader;
|
import sesim.AutoTrader;
|
||||||
import sesim.AutoTraderConfig;
|
import sesim.AutoTraderConfig;
|
||||||
import sesim.Exchange;
|
import sesim.Exchange;
|
||||||
@ -54,6 +56,7 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
AutoTraderConfig cfg1 = new RandomTraderConfig();
|
AutoTraderConfig cfg1 = new RandomTraderConfig();
|
||||||
AutoTrader rt1 = cfg1.createTrader(Globals.se, 100000, 100000);
|
AutoTrader rt1 = cfg1.createTrader(Globals.se, 100000, 100000);
|
||||||
Globals.se.traders.add(rt1);
|
Globals.se.traders.add(rt1);
|
||||||
|
|
||||||
rt1.setName("Alice");
|
rt1.setName("Alice");
|
||||||
rt1.start();
|
rt1.start();
|
||||||
|
|
||||||
@ -324,6 +327,25 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
*/
|
*/
|
||||||
public static void main(String args[]) throws IllegalAccessException, InstantiationException {
|
public static void main(String args[]) throws IllegalAccessException, InstantiationException {
|
||||||
Globals.se = new Exchange();
|
Globals.se = new Exchange();
|
||||||
|
|
||||||
|
class Tube {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Class<?> c = sesim.Exchange.class;
|
||||||
|
Globals.prefs=Preferences.userNodeForPackage(c);
|
||||||
|
|
||||||
|
Globals.setLookAndFeel(Globals.prefs.get("laf", "Nimbus"));
|
||||||
|
|
||||||
|
/* try {
|
||||||
|
// Set cross-platform Java L&F (also called "Metal")
|
||||||
|
UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
|
||||||
|
} catch (UnsupportedLookAndFeelException | ClassNotFoundException |
|
||||||
|
InstantiationException | IllegalAccessException e) {
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
ArrayList<Class<AutoTraderConfig>> traders;
|
ArrayList<Class<AutoTraderConfig>> traders;
|
||||||
traders = null;
|
traders = null;
|
||||||
|
|
||||||
@ -343,6 +365,7 @@ public class NewMDIApplication extends javax.swing.JFrame {
|
|||||||
/* Create and display the form */
|
/* Create and display the form */
|
||||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
// Globals.prefs = Preferences.userNodeForPackage(this)
|
||||||
new NewMDIApplication().setVisible(true);
|
new NewMDIApplication().setVisible(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user