Search in sources :

Example 6 with NYM

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

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

the class IssueAssetContractDialog method initValues.

// End of variables declaration//GEN-END:variables
private void initValues() {
    Contract contract = new Contract();
    serverMap = contract.loadServerContract();
    Helpers.populateCombo(serverMap, jComboBox2);
    nymMap = new NYM().loadNYM();
    Helpers.populateCombo(nymMap, jComboBox1);
}
Also used : NYM(com.moneychanger.core.NYM) Contract(com.moneychanger.core.Contract)

Example 8 with NYM

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

the class NYMEditDialog method jButton1ActionPerformed.

// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    //GEN-FIRST:event_jButton1ActionPerformed
    boolean status = new NYM().editLabel(nymID, nymID, jTextField1.getText());
    if (status)
        JOptionPane.showMessageDialog(this, "NYM edited successfully", "Edit Success", JOptionPane.INFORMATION_MESSAGE);
    else
        JOptionPane.showMessageDialog(this, "NYM could not be edited", "Failure", JOptionPane.ERROR_MESSAGE);
    this.dispose();
}
Also used : NYM(com.moneychanger.core.NYM)

Example 9 with NYM

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

the class OTAccountAdditionDialog method initValues.

// End of variables declaration//GEN-END:variables
private void initValues() {
    nymMap = new NYM().loadNYM();
    Helpers.populateCombo(nymMap, jComboBox1);
    Contract contract = new Contract();
    serverMap = contract.loadServerContract();
    Helpers.populateCombo(serverMap, jComboBox2);
    assetMap = contract.loadAssetContract();
    Helpers.populateCombo(assetMap, jComboBox3);
}
Also used : NYM(com.moneychanger.core.NYM) Contract(com.moneychanger.core.Contract)

Example 10 with NYM

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

the class DeleteNYMDialog method jButton1ActionPerformed.

// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    //GEN-FIRST:event_jButton1ActionPerformed
    String serverID = null;
    if (jComboBox1.getSelectedIndex() > -1) {
        serverID = ((String[]) serverMap.get((Integer) jComboBox1.getSelectedIndex()))[1];
    }
    System.out.println("In DeleteNYM Dialog, server ID:" + serverID + " nymID:" + nymID);
    try {
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        boolean status = new NYM().deleteNym(nymID, serverID, serverMap.size() > 1 ? false : true);
        if (status) {
            JOptionPane.showMessageDialog(this, "Nym deleted sucessfully from the server", "NYM deletion success", JOptionPane.INFORMATION_MESSAGE);
            // Not required
            MainPage.refreshNYMSList();
            MainPage.refreshMarketNym(serverID);
        } else {
            JOptionPane.showMessageDialog(this, "Cannot delete nym from server", "Error", JOptionPane.ERROR_MESSAGE);
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    } finally {
        setCursor(Cursor.getDefaultCursor());
        dispose();
    }
}
Also used : NYM(com.moneychanger.core.NYM)

Aggregations

NYM (com.moneychanger.core.NYM)19 Point (java.awt.Point)5 Map (java.util.Map)4 ListSelectionEvent (javax.swing.event.ListSelectionEvent)4 ListSelectionListener (javax.swing.event.ListSelectionListener)4 Contract (com.moneychanger.core.Contract)3 AWTException (java.awt.AWTException)3 NYMBoxTableModel (com.moneychanger.ui.model.NYMBoxTableModel)2 NYMOutboxTableModel (com.moneychanger.ui.model.NYMOutboxTableModel)2 NYMTableModel (com.moneychanger.ui.model.NYMTableModel)2 Account (com.moneychanger.core.Account)1 OpenTransactionAccount (com.moneychanger.core.OpenTransactionAccount)1 RippleAccount (com.moneychanger.core.RippleAccount)1 CashPurseDetails (com.moneychanger.core.dataobjects.CashPurseDetails)1 OTDetails (com.moneychanger.core.dataobjects.OTDetails)1 ComboObject (com.moneychanger.core.util.ComboObject)1 DateField (com.moneychanger.ui.custom.DateField)1 DeleteNYMDialog (com.moneychanger.ui.dialogs.DeleteNYMDialog)1 MarketTableModel (com.moneychanger.ui.model.MarketTableModel)1 MarketTradesTableModel (com.moneychanger.ui.model.MarketTradesTableModel)1