Orderbook updates are synchronized now.
No "Out of Index Exeptions" aynmore
This commit is contained in:
parent
6719f9a7f5
commit
0603bbc0d3
@ -28,6 +28,7 @@ package gui.orderbook;
|
|||||||
import gui.Globals;
|
import gui.Globals;
|
||||||
import gui.Globals.CfgListener;
|
import gui.Globals.CfgListener;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
import javax.swing.table.DefaultTableModel;
|
import javax.swing.table.DefaultTableModel;
|
||||||
import javax.swing.table.TableColumn;
|
import javax.swing.table.TableColumn;
|
||||||
import javax.swing.table.TableColumnModel;
|
import javax.swing.table.TableColumnModel;
|
||||||
@ -56,8 +57,7 @@ public class OrderBook extends javax.swing.JPanel implements Exchange.BookReceiv
|
|||||||
tcm.addColumn(trader_column);
|
tcm.addColumn(trader_column);
|
||||||
tcm.moveColumn(2, 0);
|
tcm.moveColumn(2, 0);
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
if (list.getColumnCount() == 2) {
|
if (list.getColumnCount() == 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -87,8 +87,9 @@ public class OrderBook extends javax.swing.JPanel implements Exchange.BookReceiv
|
|||||||
*/
|
*/
|
||||||
public OrderBook() {
|
public OrderBook() {
|
||||||
initComponents();
|
initComponents();
|
||||||
if (Globals.se==null)
|
if (Globals.se == null) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
model = (DefaultTableModel) this.list.getModel();
|
model = (DefaultTableModel) this.list.getModel();
|
||||||
trader_column = list.getColumnModel().getColumn(0);
|
trader_column = list.getColumnModel().getColumn(0);
|
||||||
cfgChanged();
|
cfgChanged();
|
||||||
@ -96,8 +97,17 @@ public class OrderBook extends javax.swing.JPanel implements Exchange.BookReceiv
|
|||||||
Globals.addCfgListener(this);
|
Globals.addCfgListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean oupdate = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void UpdateOrderBook() {
|
public synchronized void UpdateOrderBook() {
|
||||||
|
|
||||||
|
if (oupdate) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
oupdate = true;
|
||||||
|
|
||||||
|
SwingUtilities.invokeLater(() -> {
|
||||||
ArrayList<Order> ob = Globals.se.getOrderBook(type, depth);
|
ArrayList<Order> ob = Globals.se.getOrderBook(type, depth);
|
||||||
model.setRowCount(ob.size());
|
model.setRowCount(ob.size());
|
||||||
int row = 0;
|
int row = 0;
|
||||||
@ -108,6 +118,19 @@ public class OrderBook extends javax.swing.JPanel implements Exchange.BookReceiv
|
|||||||
row++;
|
row++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
oupdate = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
/* ArrayList<Order> ob = Globals.se.getOrderBook(type, depth);
|
||||||
|
model.setRowCount(ob.size());
|
||||||
|
int row = 0;
|
||||||
|
for (Order ob1 : ob) {
|
||||||
|
model.setValueAt(ob1.getAccount().getOwner().getName(), row, 0);
|
||||||
|
model.setValueAt(ob1.getLimit(), row, 1);
|
||||||
|
model.setValueAt(ob1.getVolume(), row, 2);
|
||||||
|
row++;
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -168,5 +191,4 @@ public class OrderBook extends javax.swing.JPanel implements Exchange.BookReceiv
|
|||||||
private javax.swing.JTable list;
|
private javax.swing.JTable list;
|
||||||
// End of variables declaration//GEN-END:variables
|
// End of variables declaration//GEN-END:variables
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user