1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
public class OrderLinesTableModel extends AbstractTableModel implements ListSelectionListener{
private Customer c;
private List<Order> ols;
private String[] columnNames={"Article","Qty","State","PriceInclTax","TotalInclTax", "Customer"};
private Facade facade;
private ResourceBundle resourceBundle;
public OrderLinesTableModel(Facade facade) {
this.facade=facade;
}
@Override
public void valueChanged(ListSelectionEvent e) {
c=(Customer)((JList)e.getSource()).getSelectedValue();
getOrderLine(c);
}
public void getOrderLine(Customer c){
ols = facade.getOrders(c);
fireTableDataChanged();
}
@Override
public int getRowCount() {
if(ols==null){
return 0;
}else{
return ols.size();
}
}
@Override
public String getColumnName(int column) {
resourceBundle=ResourceBundle.getBundle("MainView", Facade.getLocale());
return txt(columnNames[column]);
}
@Override
public int getColumnCount() {
return columnNames.length;
}
private String txt(String key){
return resourceBundle.getString(key);
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
Order order = (Order) ols.get(rowIndex);
switch (columnIndex) {
case 0:
return order.getRefOrder();
case 1:
return order.getIdOrder();
case 2:
return "test";
case 3:
return "";
case 4:
return "";
case 5:
return "";
}
return null;
}
} |