Search in sources :

Example 1 with MarketTableModel

use of com.moneychanger.ui.model.MarketTableModel in project otapij by FellowTraveler.

the class MainPage method jComboBox5ActionPerformed.

//GEN-LAST:event_jComboBox4ActionPerformed
private void jComboBox5ActionPerformed(java.awt.event.ActionEvent evt) {
    //GEN-FIRST:event_jComboBox5ActionPerformed
    // Load the markets for this server
    String serverID = "ALL";
    String nymID = "ALL";
    if (serverMap != null && serverMap.size() > 0 && jComboBox5.getSelectedIndex() > -1) {
        serverID = ((String[]) serverMap.get((Integer) jComboBox5.getSelectedIndex()))[1];
    }
    System.out.println("Mrkets tab - nym selected index - " + jComboBox6.getSelectedIndex());
    nymRegisteredMap = new NYM().loadRegisteredNYM(serverID);
    Helpers.populateComboWithoutAll(nymRegisteredMap, jComboBox6);
    if (nymRegisteredMap != null && nymRegisteredMap.size() > 0 && jComboBox6.getSelectedIndex() > -1) {
        nymID = ((String[]) nymRegisteredMap.get((Integer) jComboBox6.getSelectedIndex()))[1];
    }
    System.out.println("Mrkets tab, serverID:" + serverID + " nymID:" + nymID);
    if (jComboBox6.getSelectedIndex() > -1 && jComboBox5.getSelectedIndex() > -1) {
        Map marketList = null;
        try {
            marketList = Market.loadMarketList(serverID, nymID);
        } catch (InterruptedException ex) {
            Logger.getLogger(MainPage.class.getName()).log(Level.SEVERE, null, ex);
        }
        if (marketList != null) {
            ((MarketTableModel) jTable13.getModel()).setValue(marketList, jTable13);
        }
        if (marketList != null && marketList.size() > 0) {
            String marketID = (String) jTable13.getModel().getValueAt(jTable13.getSelectedRow(), 1);
            System.out.println("-----marketID----:" + marketID);
            boolean marketExists = false;
            for (int i = 0; i < jTable13.getRowCount(); i++) {
                if (marketID != null && jTable13.getModel().getValueAt(jTable13.getSelectedRow(), 1) != null && marketID.equals(jTable13.getModel().getValueAt(jTable13.getSelectedRow(), 1))) {
                    jTable13.setRowSelectionInterval(i, i);
                    marketListClick();
                    marketExists = true;
                    break;
                }
            }
            if (jTable13.getRowCount() > 0 && !marketExists) {
                jTable13.setRowSelectionInterval(0, 0);
                marketListClick();
            }
        }
    }
}
Also used : MarketTableModel(com.moneychanger.ui.model.MarketTableModel) NYM(com.moneychanger.core.NYM) Map(java.util.Map) Point(java.awt.Point)

Example 2 with MarketTableModel

use of com.moneychanger.ui.model.MarketTableModel in project otapij by FellowTraveler.

the class MainPage method jComboBox6ActionPerformed.

//GEN-LAST:event_jComboBox5ActionPerformed
private void jComboBox6ActionPerformed(java.awt.event.ActionEvent evt) {
    //GEN-FIRST:event_jComboBox6ActionPerformed
    String serverID = "ALL";
    String nymID = "ALL";
    if (serverMap != null && serverMap.size() > 0 && jComboBox5.getSelectedIndex() > -1) {
        serverID = ((String[]) serverMap.get((Integer) jComboBox5.getSelectedIndex()))[1];
    }
    if (nymRegisteredMap != null && nymRegisteredMap.size() > 0 && jComboBox6.getSelectedIndex() > -1) {
        nymID = ((String[]) nymRegisteredMap.get((Integer) jComboBox6.getSelectedIndex()))[1];
    }
    System.out.println("Mrkets tab, nym combo serverID:" + serverID + " nymID:" + nymID);
    if (jComboBox6.getSelectedIndex() > -1 && jComboBox5.getSelectedIndex() > -1) {
        Map marketList = null;
        try {
            marketList = Market.loadMarketList(serverID, nymID);
        } catch (InterruptedException ex) {
            Logger.getLogger(MainPage.class.getName()).log(Level.SEVERE, null, ex);
        }
        if (marketList != null) {
            ((MarketTableModel) jTable13.getModel()).setValue(marketList, jTable13);
        }
        if (marketList != null && marketList.size() > 0) {
            String marketID = (String) jTable13.getModel().getValueAt(jTable13.getSelectedRow(), 1);
            System.out.println("-----marketID:" + marketID);
            boolean marketExists = false;
            for (int i = 0; i < jTable13.getRowCount(); i++) {
                if (marketID != null && jTable13.getModel().getValueAt(jTable13.getSelectedRow(), 1) != null && marketID.equals(jTable13.getModel().getValueAt(jTable13.getSelectedRow(), 1))) {
                    jTable13.setRowSelectionInterval(i, i);
                    marketListClick();
                    marketExists = true;
                    break;
                }
            }
            if (jTable13.getRowCount() > 0 && !marketExists) {
                jTable13.setRowSelectionInterval(0, 0);
                marketListClick();
            }
        }
    }
}
Also used : MarketTableModel(com.moneychanger.ui.model.MarketTableModel) Map(java.util.Map) Point(java.awt.Point)

Example 3 with MarketTableModel

use of com.moneychanger.ui.model.MarketTableModel in project otapij by FellowTraveler.

the class MainPage method refreshMarketOfferList.

public static void refreshMarketOfferList(String serverID, String nymID) {
    Map marketList = null;
    Map offerList = null;
    try {
        // DEBUGGING: this is where the next step happens
        marketList = Market.loadMarketList(serverID, nymID);
        offerList = Market.getNymOfferList(serverID, nymID);
        if (marketList != null) {
            ((MarketTableModel) jTable13.getModel()).setValue(marketList, jTable13);
        } else {
            System.out.println("refreshMarketOfferList:  Market.loadMarketList() returned null!");
        }
        // ------------------------------------
        if (offerList != null) {
            ((MarketOffersTableModel) jTable14.getModel()).setValue(offerList, jTable14);
        } else {
            System.out.println("refreshMarketOfferList:  Market.getNymOfferList() returned null!");
        }
        // ------------------------------------
        if (marketList != null && marketList.size() > 0) {
            jTable13.setRowSelectionInterval(0, 0);
        } else {
            System.out.println("refreshMarketOfferList:  marketList.size() was <= 0");
        }
        // ------------------------------------
        if (offerList != null && offerList.size() > 0) {
            jTable14.setRowSelectionInterval(0, 0);
        } else {
            System.out.println("refreshMarketOfferList:  offerList.size() was <= 0");
        }
    // ------------------------------------
    } catch (Exception ex) {
        Logger.getLogger(MainPage.class.getName()).log(Level.SEVERE, null, ex);
    }
}
Also used : MarketTableModel(com.moneychanger.ui.model.MarketTableModel) MarketOffersTableModel(com.moneychanger.ui.model.MarketOffersTableModel) Map(java.util.Map) AWTException(java.awt.AWTException)

Aggregations

MarketTableModel (com.moneychanger.ui.model.MarketTableModel)3 Map (java.util.Map)3 Point (java.awt.Point)2 NYM (com.moneychanger.core.NYM)1 MarketOffersTableModel (com.moneychanger.ui.model.MarketOffersTableModel)1 AWTException (java.awt.AWTException)1