Search in sources :

Example 1 with OpenTransactionAccount

use of com.moneychanger.core.OpenTransactionAccount in project otapij by FellowTraveler.

the class MainPage method loadAccount.

public static void loadAccount(String assetID, String serverID, String nymID, String selectedID) {
    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();
                if (i == 0) {
                    account.clearOTAccountList();
                }
                account.loadAccount(assetID, serverID, nymID);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    ((AccountTableModel) jTable_AccountTable.getModel()).setValue(account.getOTAccountList(), jTable_AccountTable);
    for (int i = 0; i < jTable_AccountTable.getModel().getRowCount(); i++) {
        System.out.println("selectedID:" + selectedID + "jTable5.getModel().getValueAt(i, 3" + (String) jTable_AccountTable.getModel().getValueAt(i, 3));
        if (Utility.VerifyStringVal(selectedID) && jTable_AccountTable.getModel().getValueAt(i, 3) != null && selectedID.equals(jTable_AccountTable.getModel().getValueAt(i, 3))) {
            jTable_AccountTable.setRowSelectionInterval(i, i);
            break;
        }
    }
}
Also used : OpenTransactionAccount(com.moneychanger.core.OpenTransactionAccount) RippleAccount(com.moneychanger.core.RippleAccount) Account(com.moneychanger.core.Account) AccountTableModel(com.moneychanger.ui.model.AccountTableModel) Point(java.awt.Point) AWTException(java.awt.AWTException)

Example 2 with OpenTransactionAccount

use of com.moneychanger.core.OpenTransactionAccount 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 OpenTransactionAccount

use of com.moneychanger.core.OpenTransactionAccount in project otapij by FellowTraveler.

the class MainPage method initOtherTab.

private void initOtherTab() {
    try {
        jPanel27.setLayout(new CardLayout());
        jPanel28.setLayout(new CardLayout());
        System.out.println("in initOtherTab");
        //load servers here
        loadOtherTabServers();
        jTable4.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

            public void valueChanged(ListSelectionEvent e) {
                if (e.getValueIsAdjusting()) {
                    return;
                }
                System.out.println("selectedRow:" + jTable4.getSelectedRow());
                if (jTable4.getSelectedRow() >= 0) {
                    String serverID = (String) jTable4.getModel().getValueAt(jTable4.getSelectedRow(), 2);
                    String type = (String) jTable4.getModel().getValueAt(jTable4.getSelectedRow(), 1);
                    System.out.println("selected serverID:" + serverID + " type:" + type);
                    if ("BitcoinAccount".equals(type)) {
                        Account account = null;
                        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                        try {
                            try {
                                account = (Account) (Class.forName("com.moneychanger.core." + type)).newInstance();
                                account.setServerID(serverID);
                            } 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);
                        }
                        /*if (type.contains("Bitcoin")) {
                            account = new BitcoinAccount(serverID);
                            }*/
                        try {
                            account.loadAccount("", serverID, "");
                            ((OtherTabAccountModel) jTable3.getModel()).setValue(account.getAccountList(), jTable3);
                        } catch (Exception ex) {
                            System.out.println("In BTC load exception:" + ex);
                            JOptionPane.showMessageDialog(null, "Cannot connect to bitcoin service - Connection refused", "Connection Error", JOptionPane.ERROR_MESSAGE);
                        //jTable4.setRowSelectionInterval(WIDTH, WIDTH);
                        } finally {
                            setCursor(Cursor.getDefaultCursor());
                        }
                    } else if ("RippleAccount".equalsIgnoreCase(type)) {
                        CardLayout topLayout = (CardLayout) (jPanel27.getLayout());
                        CardLayout bottomlayout = (CardLayout) (jPanel28.getLayout());
                        topLayout.show(jPanel27, "BlankTop");
                        bottomlayout.show(jPanel28, "BlankBottom");
                        ((OtherTabAccountModel) jTable3.getModel()).clearValue();
                        String[] details = new RippleAccount().loadServerDetails(serverID);
                        if (details != null) {
                            RippleAccountTopPanel.openBrowser(details[0], details[1], details[2], details[3], details[4]);
                        }
                    }
                }
            }
        });
        //((OtherTabServerTableModel) jTable4.getModel()).setValue(new NYM().loadNYM(), jTable4);
        jTable3.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

            public void valueChanged(ListSelectionEvent e) {
                if (e.getValueIsAdjusting()) {
                    return;
                }
                System.out.println("valueChanged Action Listener :" + jTable3.getSelectedRow() + "e:" + e.getSource());
                if (jTable3.getSelectedRow() >= 0) {
                    try {
                        jPanel27.setVisible(true);
                        jPanel28.setVisible(true);
                        CardLayout topLayout = (CardLayout) (jPanel27.getLayout());
                        CardLayout bottomlayout = (CardLayout) (jPanel28.getLayout());
                        String type = null;
                        String accountID = null;
                        type = (String) jTable3.getModel().getValueAt(jTable3.getSelectedRow(), 2);
                        accountID = (String) jTable3.getModel().getValueAt(jTable3.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(jPanel27, type + "TopPanel");
                                    bottomlayout.show(jPanel28, type + "BottomPanel");
                                    Class obj = Class.forName("com.moneychanger.core." + type);
                                    Account account = (Account) obj.newInstance();
                                    account.setServerID((String) jTable4.getModel().getValueAt(jTable4.getSelectedRow(), 2));
                                    Object details = account.getAccountDetails(accountID);
                                    if (details == null) {
                                        JOptionPane.showMessageDialog(null, "Error loading details", "Details Error", JOptionPane.ERROR_MESSAGE);
                                        break;
                                    }
                                    if ("BitcoinAccount".equalsIgnoreCase(type)) {
                                        BitcoinDetails btcDetails = (BitcoinDetails) details;
                                        populateBitcoinDetails(btcDetails);
                                    }
                                //}
                                } 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());
                    }
                }
            }
        });
        jPanel27.add(new BlankPanel(), "BlankTop");
        jPanel28.add(new BlankPanel(), "BlankBottom");
        for (int i = 0; i < Account.allAccounts.length; i++) {
            try {
                System.out.println("in initOtherTabloop");
                if (!"OpenTransactionAccount".equals(Account.allAccounts[i]) && !"CashPurseAccount".equals(Account.allAccounts[i])) {
                    System.out.println("initOtherTabloop --- Account.allAccounts[i]:" + Account.allAccounts[i]);
                    Class obj1 = Class.forName("com.moneychanger.ui.panels." + Account.allAccounts[i] + "TopPanel");
                    JPanel topPanel = (JPanel) obj1.newInstance();
                    jPanel27.add(topPanel, Account.allAccounts[i] + "TopPanel");
                    Class obj2 = Class.forName("com.moneychanger.ui.panels." + Account.allAccounts[i] + "BottomPanel");
                    JPanel bottomPanel = (JPanel) obj2.newInstance();
                    // Setting the account account to retrieve in bottom panel
                    jPanel28.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);
            }
        }
        // TODO might need to uncomment
        //loadOtherTabAccount("");
        OtherTabAccountModel.removeCols(jTable3);
        OtherTabServerTableModel.removeCols(jTable4);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
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) ListSelectionEvent(javax.swing.event.ListSelectionEvent) BlankPanel(com.moneychanger.ui.panels.BlankPanel) OtherTabAccountModel(com.moneychanger.ui.model.OtherTabAccountModel) AWTException(java.awt.AWTException) Point(java.awt.Point) ListSelectionListener(javax.swing.event.ListSelectionListener) ComboObject(com.moneychanger.core.util.ComboObject) RippleAccount(com.moneychanger.core.RippleAccount) BitcoinDetails(com.moneychanger.core.dataobjects.BitcoinDetails)

Example 4 with OpenTransactionAccount

use of com.moneychanger.core.OpenTransactionAccount in project otapij by FellowTraveler.

the class OTAccountAdditionDialog method jButton1ActionPerformed.

//GEN-LAST:event_jComboBox3ActionPerformed
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    //GEN-FIRST:event_jButton1ActionPerformed
    String nymID = "";
    String assetID = "";
    String serverID = "";
    nymID = ((String[]) nymMap.get((Integer) jComboBox1.getSelectedIndex()))[1];
    assetID = ((String[]) assetMap.get((Integer) jComboBox3.getSelectedIndex()))[1];
    serverID = ((String[]) serverMap.get((Integer) jComboBox2.getSelectedIndex()))[1];
    System.out.print("On click assetID:" + assetID);
    System.out.print("On click serverID:" + serverID);
    System.out.print("On click  nymiiidL:" + nymID);
    try {
        OpenTransactionAccount openTransaction = new OpenTransactionAccount(serverID, nymID, assetID, label);
        this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        boolean result = openTransaction.createAccount();
        this.setCursor(Cursor.getDefaultCursor());
        if (result) {
            JOptionPane.showMessageDialog(this, "Account created successfully", "Account Creation", JOptionPane.INFORMATION_MESSAGE);
            MainPage.loadAccount(assetIDMainPage, serverIDMainPage, nymIDMainPage, selectedID);
            MainPage.refreshMarketNym(serverIDMainPage);
        } else
            JOptionPane.showMessageDialog(this, "Account creation failed", "Account Creation", JOptionPane.ERROR_MESSAGE);
    } catch (Exception ex) {
        Logger.getLogger(OTAccountAdditionDialog.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        this.setCursor(Cursor.getDefaultCursor());
    }
    this.dispose();
}
Also used : OpenTransactionAccount(com.moneychanger.core.OpenTransactionAccount)

Example 5 with OpenTransactionAccount

use of com.moneychanger.core.OpenTransactionAccount in project otapij by FellowTraveler.

the class DepositChequeDialog method jButton1ActionPerformed.

// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    if (!jTextArea1.getText().trim().startsWith("-----BEGIN SIGNED CHEQUE-----") && !jTextArea1.getText().trim().startsWith("-----BEGIN SIGNED VOUCHER-----")) {
        JOptionPane.showMessageDialog(this, "Please enter valid cheque", "Error", JOptionPane.ERROR_MESSAGE);
        return;
    }
    if (!jTextArea1.getText().contains(serverID)) {
        JOptionPane.showMessageDialog(this, "Cheque is not present on this server", "Error", JOptionPane.ERROR_MESSAGE);
        return;
    }
    System.out.println("Deposit Cheque accountID:" + accountID);
    System.out.println("Deposit Cheque cheque value:" + jTextArea1.getText());
    /*hasRecipient="true"
        recipientUserID="Bg2QrSTomOEU5ICfvhfYfBYxQZPktDSnaVPpMLYxUnz"*/
    if (jTextArea1.getText().trim().contains("hasRecipient=\"true\"") && !jTextArea1.getText().contains(nymID)) {
        JOptionPane.showMessageDialog(this, "The recipient NYM ID in cheque and your NYM ID do no match ", "Error", JOptionPane.ERROR_MESSAGE);
        return;
    }
    OpenTransactionAccount openTransaction = new OpenTransactionAccount();
    try {
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        boolean success = openTransaction.depositCheque(serverID, nymID, accountID, jTextArea1.getText());
        /**
             * Reload the inbox and top accounts panel if success
             */
        if (success) {
            JOptionPane.showMessageDialog(this, "Cheque deposited successfully", "Success", JOptionPane.INFORMATION_MESSAGE);
            Helpers.reloadOTDetails(accountID);
            MainPage.reLoadAccount();
        } else
            JOptionPane.showMessageDialog(this, "Error in cheque deposit", "Error", JOptionPane.ERROR_MESSAGE);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        setCursor(Cursor.getDefaultCursor());
        this.dispose();
    }
}
Also used : OpenTransactionAccount(com.moneychanger.core.OpenTransactionAccount)

Aggregations

OpenTransactionAccount (com.moneychanger.core.OpenTransactionAccount)22 Account (com.moneychanger.core.Account)5 AWTException (java.awt.AWTException)5 Point (java.awt.Point)5 RippleAccount (com.moneychanger.core.RippleAccount)4 OTDetails (com.moneychanger.core.dataobjects.OTDetails)2 ComboObject (com.moneychanger.core.util.ComboObject)2 ExchangeBasketDialog (com.moneychanger.ui.dialogs.ExchangeBasketDialog)2 AccountTableModel (com.moneychanger.ui.model.AccountTableModel)2 OtherTabAccountModel (com.moneychanger.ui.model.OtherTabAccountModel)2 CardLayout (java.awt.CardLayout)2 JPanel (javax.swing.JPanel)2 ListSelectionEvent (javax.swing.event.ListSelectionEvent)2 ListSelectionListener (javax.swing.event.ListSelectionListener)2 Contract (com.moneychanger.core.Contract)1 NYM (com.moneychanger.core.NYM)1 BitcoinDetails (com.moneychanger.core.dataobjects.BitcoinDetails)1 CashPurseDetails (com.moneychanger.core.dataobjects.CashPurseDetails)1 DepositCashDialog (com.moneychanger.ui.dialogs.DepositCashDialog)1 BlankPanel (com.moneychanger.ui.panels.BlankPanel)1