Search in sources :

Example 1 with NymOfferDetails

use of com.moneychanger.core.dataobjects.NymOfferDetails in project otapij by FellowTraveler.

the class MainPage method nymOfferClick.

private void nymOfferClick() {
    try {
        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];
        }
        if (!"ALL".equalsIgnoreCase(nymID)) {
            NymOfferDetails nymOfferDetails = Market.getNymOfferDetails(serverID, nymID, (String) jTable14.getModel().getValueAt(jTable14.getSelectedRow(), 0));
            jLabel47.setVisible(true);
            jLabel48.setVisible(true);
            jLabel49.setVisible(true);
            jLabel50.setVisible(true);
            if (null != nymOfferDetails) {
                jLabel47.setText(nymOfferDetails.getPrice());
                jLabel48.setText(nymOfferDetails.getMinIncrement());
                jLabel49.setText(nymOfferDetails.getTotalAssetsOnOffer());
                jLabel50.setText(nymOfferDetails.getAssetsStillOnOffer());
            }
        }
    } catch (Exception ex) {
        Logger.getLogger(MainPage.class.getName()).log(Level.SEVERE, null, ex);
    }
}
Also used : NymOfferDetails(com.moneychanger.core.dataobjects.NymOfferDetails) AWTException(java.awt.AWTException)

Example 2 with NymOfferDetails

use of com.moneychanger.core.dataobjects.NymOfferDetails in project otapij by FellowTraveler.

the class Market method getNymOfferDetails.

public static NymOfferDetails getNymOfferDetails(String serverID, String nymID, String transactionID) {
    NymOfferDetails nymOfferDetails = new NymOfferDetails();
    OfferListNym offerListNym = Helpers.getNYMOffer(serverID, nymID);
    if (offerListNym == null) {
        System.out.println("getNymOfferDetails - offerListNym returns null");
        return null;
    }
    for (int j = 0; j < offerListNym.GetOfferDataNymCount(); j++) {
        OfferDataNym offerDataNym = offerListNym.GetOfferDataNym(j);
        if (offerDataNym == null || !Utility.VerifyStringVal(transactionID)) {
            continue;
        }
        if (transactionID.equals(offerDataNym.getTransaction_id())) {
            nymOfferDetails.setPrice(offerDataNym.getPrice_per_scale());
            nymOfferDetails.setMinIncrement(offerDataNym.getMinimum_increment());
            nymOfferDetails.setTotalAssetsOnOffer(offerDataNym.getTotal_assets());
            double assetCount = -1;
            try {
                assetCount = Double.parseDouble(offerDataNym.getTotal_assets()) - Double.parseDouble(offerDataNym.getFinished_so_far());
            } catch (NumberFormatException nfe) {
                nfe.printStackTrace();
            }
            nymOfferDetails.setAssetsStillOnOffer(assetCount == -1 ? "" : String.valueOf(assetCount));
            break;
        }
    }
    return nymOfferDetails;
}
Also used : OfferListNym(org.opentransactions.otapi.OfferListNym) OfferDataNym(org.opentransactions.otapi.OfferDataNym) NymOfferDetails(com.moneychanger.core.dataobjects.NymOfferDetails)

Aggregations

NymOfferDetails (com.moneychanger.core.dataobjects.NymOfferDetails)2 AWTException (java.awt.AWTException)1 OfferDataNym (org.opentransactions.otapi.OfferDataNym)1 OfferListNym (org.opentransactions.otapi.OfferListNym)1