Search in sources :

Example 1 with OTDetails

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

the class OpenTransactionAccount method getOTAccountDetails.

public OTDetails getOTAccountDetails(String accountID) {
    System.out.println("In getOTAccountDetails: ");
    OTDetails otDetails = new OTDetails();
    if (!Utility.VerifyStringVal(accountID)) {
        System.out.println("Failure: accountID is null.");
        return otDetails;
    }
    // ---------------------------------------------
    otDetails.setAccountID(accountID);
    // ---------------------------------------------
    String strServerID = otapiJNI.OTAPI_Basic_GetAccountWallet_ServerID(accountID);
    if (!Utility.VerifyStringVal(strServerID)) {
        System.out.println("Failure: serverID is null for accountID: " + accountID);
        return otDetails;
    }
    otDetails.setServerID(strServerID);
    String serverName = otapiJNI.OTAPI_Basic_GetServer_Name(strServerID);
    if (!Utility.VerifyStringVal(serverName)) {
        System.out.println("Failure: serverName is null for serverID: " + strServerID);
        return otDetails;
    }
    otDetails.setServerName(serverName);
    // ---------------------------------------------
    String strAssetID = otapiJNI.OTAPI_Basic_GetAccountWallet_AssetTypeID(accountID);
    if (!Utility.VerifyStringVal(strAssetID)) {
        System.out.println("Failure: assetID is null for accountID: " + accountID);
        return otDetails;
    }
    otDetails.setAssetID(strAssetID);
    String assetName = otapiJNI.OTAPI_Basic_GetAssetType_Name(strAssetID);
    if (!Utility.VerifyStringVal(assetName)) {
        System.out.println("Failure: assetName is null for assetID: " + strAssetID);
        return otDetails;
    }
    otDetails.setAssetName(assetName);
    // ---------------------------------------------
    String strAccountName = otapiJNI.OTAPI_Basic_GetAccountWallet_Name(accountID);
    if (!Utility.VerifyStringVal(strAccountName)) {
        System.out.println("Failure: strAccountName is null for accountID: " + accountID);
        return otDetails;
    }
    otDetails.setAccountName(strAccountName);
    // ---------------------------------------------
    String strNymID = otapiJNI.OTAPI_Basic_GetAccountWallet_NymID(accountID);
    if (!Utility.VerifyStringVal(strNymID)) {
        System.out.println("Failure: nymID is null for accountID: " + accountID);
        return otDetails;
    }
    otDetails.setNymID(strNymID);
    String strNymName = !Utility.VerifyStringVal(strNymID) ? "" : otapiJNI.OTAPI_Basic_GetNym_Name(strNymID);
    if (!Utility.VerifyStringVal(strNymName)) {
        System.out.println("Failure: strNymName is null for nymID: " + strNymID);
        return otDetails;
    }
    otDetails.setNymName(strNymName);
    // ----------------------------------        
    try {
        if (Helpers.getIntermediaryFiles(strServerID, strNymID, accountID)) {
            otDetails.setInboxData(getInboxData(accountID));
            otDetails.setOutboxData(getOutboxData(accountID));
        } else {
            System.out.println("getOTAccountDetails: Failed in Utility.getIntermediaryFiles()");
        }
    } catch (InterruptedException ex) {
        Logger.getLogger(OpenTransactionAccount.class.getName()).log(Level.SEVERE, null, ex);
    }
    // ----------------------------------
    String strBalance = otapiJNI.OTAPI_Basic_GetAccountWallet_Balance(accountID);
    if (!Utility.VerifyStringVal(strBalance)) {
        System.out.println("Failure: strBalance is null for accountID: " + accountID);
        return otDetails;
    }
    otDetails.setBalance(strBalance);
    if (otapiJNI.OTAPI_Basic_IsBasketCurrency(otapiJNI.OTAPI_Basic_GetAccountWallet_AssetTypeID(accountID))) {
        otDetails.setBasketName(otapiJNI.OTAPI_Basic_GetAssetType_Name(otapiJNI.OTAPI_Basic_GetAccountWallet_AssetTypeID(accountID)) == null ? "" : otapiJNI.OTAPI_Basic_GetAssetType_Name(otapiJNI.OTAPI_Basic_GetAccountWallet_AssetTypeID(accountID)));
    }
    return otDetails;
}
Also used : OTDetails(com.moneychanger.core.dataobjects.OTDetails)

Example 2 with OTDetails

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

the class MainPage method initMainTab.

private void initMainTab() {
    jPanel_TopPanel.setLayout(new CardLayout());
    jPanel_BottomPanel.setLayout(new CardLayout());
    jTable_AccountTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting()) {
                return;
            }
            System.out.println("valueChanged Action Listener :" + jTable_AccountTable.getSelectedRow() + "e:" + e.getSource());
            if (jTable_AccountTable.getSelectedRow() >= 0) {
                try {
                    jPanel_TopPanel.setVisible(true);
                    jPanel_BottomPanel.setVisible(true);
                    CardLayout topLayout = (CardLayout) (jPanel_TopPanel.getLayout());
                    CardLayout bottomlayout = (CardLayout) (jPanel_BottomPanel.getLayout());
                    String type = null;
                    String accountID = null;
                    type = (String) jTable_AccountTable.getModel().getValueAt(jTable_AccountTable.getSelectedRow(), 2);
                    accountID = (String) jTable_AccountTable.getModel().getValueAt(jTable_AccountTable.getSelectedRow(), 3);
                    System.out.println("Type:" + type);
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    for (int i = 0; i < Account.allAccounts.length; i++) {
                        if (Account.allAccounts[i].equalsIgnoreCase(type)) {
                            try {
                                topLayout.show(jPanel_TopPanel, type + "TopPanel");
                                bottomlayout.show(jPanel_BottomPanel, type + "BottomPanel");
                                Class obj = Class.forName("com.moneychanger.core." + type);
                                Account account = (Account) obj.newInstance();
                                Object details = account.getAccountDetails(accountID);
                                if (details == null) {
                                    JOptionPane.showMessageDialog(null, "Error loading details", "Details Error", JOptionPane.ERROR_MESSAGE);
                                    break;
                                }
                                if ("OpenTransactionAccount".equalsIgnoreCase(type)) {
                                    OTDetails otDetails = (OTDetails) details;
                                    Helpers.populateOTDetails(otDetails);
                                    ((AccountTableModel) jTable_AccountTable.getModel()).setValueAt(otDetails.getBalance(), jTable_AccountTable.getSelectedRow(), 1);
                                } else if ("CashPurseAccount".equalsIgnoreCase(type)) {
                                    CashPurseDetails cashDetails = (CashPurseDetails) details;
                                    populateCashPurseDetails(cashDetails, cashDetails.getBalance());
                                }
                                break;
                            } catch (InstantiationException ex) {
                                Logger.getLogger(MainPage.class.getName()).log(Level.SEVERE, null, ex);
                            } catch (IllegalAccessException ex) {
                                Logger.getLogger(MainPage.class.getName()).log(Level.SEVERE, null, ex);
                            } catch (ClassNotFoundException ex) {
                                Logger.getLogger(MainPage.class.getName()).log(Level.SEVERE, null, ex);
                            }
                            repaint();
                        }
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                } finally {
                    setCursor(Cursor.getDefaultCursor());
                }
            }
        }
    });
    nymMap = new NYM().loadNYM();
    jComboBox_Nyms.addItem(new ComboObject("ALL"));
    jComboBoxServerContracts.addItem(new ComboObject("ALL"));
    jComboBox_AssetContracts.addItem(new ComboObject("ALL"));
    Helpers.populateCombo(nymMap, jComboBox_Nyms);
    Contract contract = new Contract();
    serverMap = contract.loadServerContract();
    Helpers.populateCombo(serverMap, jComboBoxServerContracts);
    assetMap = contract.loadAssetContract();
    Helpers.populateCombo(assetMap, jComboBox_AssetContracts);
    Account account = null;
    for (int i = 0; i < Account.allAccounts.length; i++) {
        try {
            if ("OpenTransactionAccount".equals(Account.allAccounts[i]) || "CashPurseAccount".equals(Account.allAccounts[i])) {
                Class obj = Class.forName("com.moneychanger.core." + Account.allAccounts[i]);
                account = (Account) obj.newInstance();
                try {
                    account.loadAccount("ALL", "ALL", "ALL");
                } catch (Exception ex) {
                    Logger.getLogger(MainPage.class.getName()).log(Level.SEVERE, null, ex);
                }
                Class obj1 = Class.forName("com.moneychanger.ui.panels." + Account.allAccounts[i] + "TopPanel");
                JPanel topPanel = (JPanel) obj1.newInstance();
                jPanel_TopPanel.add(topPanel, Account.allAccounts[i] + "TopPanel");
                Class obj2 = Class.forName("com.moneychanger.ui.panels." + Account.allAccounts[i] + "BottomPanel");
                JPanel bottomPanel = (JPanel) obj2.newInstance();
                jPanel_BottomPanel.add(bottomPanel, Account.allAccounts[i] + "BottomPanel");
            }
        } catch (InstantiationException ex) {
        //Logger.getLogger(MainPage.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
        ///Logger.getLogger(MainPage.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
        //Logger.getLogger(MainPage.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
Also used : CardLayout(java.awt.CardLayout) OpenTransactionAccount(com.moneychanger.core.OpenTransactionAccount) RippleAccount(com.moneychanger.core.RippleAccount) Account(com.moneychanger.core.Account) JPanel(javax.swing.JPanel) NYM(com.moneychanger.core.NYM) CashPurseDetails(com.moneychanger.core.dataobjects.CashPurseDetails) ListSelectionEvent(javax.swing.event.ListSelectionEvent) AWTException(java.awt.AWTException) Point(java.awt.Point) ListSelectionListener(javax.swing.event.ListSelectionListener) OTDetails(com.moneychanger.core.dataobjects.OTDetails) ComboObject(com.moneychanger.core.util.ComboObject) ComboObject(com.moneychanger.core.util.ComboObject) Contract(com.moneychanger.core.Contract)

Example 3 with OTDetails

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

the class Helpers method reloadOTDetails.

// OT Helpers
public static void reloadOTDetails(String accountID) {
    Account account = new OpenTransactionAccount();
    Object details = account.getAccountDetails(accountID);
    OTDetails otDetails = (OTDetails) details;
    populateOTDetails(otDetails);
    JTable table = MainPage.getAccountTable();
    ((AccountTableModel) table.getModel()).setValueAt(otDetails.getBalance(), table.getSelectedRow(), 1);
}
Also used : Account(com.moneychanger.core.Account) OpenTransactionAccount(com.moneychanger.core.OpenTransactionAccount) AccountTableModel(com.moneychanger.ui.model.AccountTableModel) JTable(javax.swing.JTable) OpenTransactionAccount(com.moneychanger.core.OpenTransactionAccount) OTDetails(com.moneychanger.core.dataobjects.OTDetails)

Aggregations

OTDetails (com.moneychanger.core.dataobjects.OTDetails)3 Account (com.moneychanger.core.Account)2 OpenTransactionAccount (com.moneychanger.core.OpenTransactionAccount)2 Contract (com.moneychanger.core.Contract)1 NYM (com.moneychanger.core.NYM)1 RippleAccount (com.moneychanger.core.RippleAccount)1 CashPurseDetails (com.moneychanger.core.dataobjects.CashPurseDetails)1 ComboObject (com.moneychanger.core.util.ComboObject)1 AccountTableModel (com.moneychanger.ui.model.AccountTableModel)1 AWTException (java.awt.AWTException)1 CardLayout (java.awt.CardLayout)1 Point (java.awt.Point)1 JPanel (javax.swing.JPanel)1 JTable (javax.swing.JTable)1 ListSelectionEvent (javax.swing.event.ListSelectionEvent)1 ListSelectionListener (javax.swing.event.ListSelectionListener)1