Search in sources :

Example 1 with BlankPanel

use of com.moneychanger.ui.panels.BlankPanel 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 2 with BlankPanel

use of com.moneychanger.ui.panels.BlankPanel in project otapij by FellowTraveler.

the class AddressBookDialog method initValues.

private void initValues() {
    ContactTableModel.removeCols(jTable5);
    switch(mode) {
        case 1:
            {
                jRadioButton1.setSelected(true);
                ((ContactDetailsTableModel) jTable6.getModel()).setColumnNames(new String[] { "Account List" });
                System.out.println("In case1");
            }
            break;
        case 2:
            {
                jRadioButton2.setSelected(true);
                ((ContactDetailsTableModel) jTable6.getModel()).setColumnNames(new String[] { "Nym List" });
            }
            break;
        case 3:
            break;
        default:
            break;
    }
    ((ContactTableModel) jTable5.getModel()).setValue(AddressBookHelper.getContactList());
    jPanel3.setLayout(new CardLayout());
    jPanel3.add(new BlankPanel(), "BlankPanel");
    jPanel3.add(new ContactNymPanel(), "ContactNymPanel");
    jPanel3.add(new ContactAcctPanel(), "ContactAcctPanel");
    jTable6.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting()) {
                return;
            }
            if (jTable6.getSelectedRow() >= 0) {
                CardLayout cardLayout = (CardLayout) jPanel3.getLayout();
                if (mode == 1) {
                    cardLayout.show(jPanel3, "ContactAcctPanel");
                    contactDetails = AddressBookHelper.getContactDetails(contactID, mode);
                    if (contactDetails != null) {
                        ContactAcctPanel.setValues(jTable6.getSelectedRow(), contactID);
                        ContactAcctPanel.populateDetails(AddressBookHelper.getContactAccDetails(contactDetails.getContact(), jTable6.getSelectedRow()));
                    }
                // Set details panel here
                } else if (mode == 2) {
                    cardLayout.show(jPanel3, "ContactNymPanel");
                    contactDetails = AddressBookHelper.getContactDetails(contactID, mode);
                    if (contactDetails != null) {
                        ContactNymPanel.setValues(jTable6.getSelectedRow(), contactID);
                        ContactNymPanel.populateDetails(AddressBookHelper.getContactNymDetails(contactDetails.getContact(), jTable6.getSelectedRow()));
                    }
                } else {
                    cardLayout.show(jPanel3, "BlankPanel");
                }
            }
        }
    });
    jTable5.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting()) {
                return;
            }
            if (jTable5.getSelectedRow() >= 0) {
                if (!jRadioButton1.isSelected() && !jRadioButton2.isSelected()) {
                    JOptionPane.showMessageDialog(null, "Please select mode", "Mode Error", JOptionPane.ERROR_MESSAGE);
                    return;
                }
                if (jRadioButton2.isSelected()) {
                    jButton2.setEnabled(false);
                    jButton3.setEnabled(true);
                    ((ContactDetailsTableModel) jTable6.getModel()).setColumnNames(new String[] { "Nym List" });
                    mode = 2;
                } else if (jRadioButton1.isSelected()) {
                    jButton2.setEnabled(true);
                    jButton3.setEnabled(false);
                    ((ContactDetailsTableModel) jTable6.getModel()).setColumnNames(new String[] { "Account List" });
                    mode = 1;
                }
                contactID = (String) jTable5.getModel().getValueAt(jTable5.getSelectedRow(), 1);
                ContactDetails contactDetails = AddressBookHelper.getContactDetails(contactID, mode);
                populateContactDetails(contactDetails, mode);
            }
        }
    });
}
Also used : ContactTableModel(com.moneychanger.ui.model.ContactTableModel) CardLayout(java.awt.CardLayout) ContactNymPanel(com.moneychanger.ui.panels.ContactNymPanel) ContactDetails(com.moneychanger.core.dataobjects.ContactDetails) ListSelectionEvent(javax.swing.event.ListSelectionEvent) BlankPanel(com.moneychanger.ui.panels.BlankPanel) ContactAcctPanel(com.moneychanger.ui.panels.ContactAcctPanel) ListSelectionListener(javax.swing.event.ListSelectionListener) ContactDetailsTableModel(com.moneychanger.ui.model.ContactDetailsTableModel)

Aggregations

BlankPanel (com.moneychanger.ui.panels.BlankPanel)2 CardLayout (java.awt.CardLayout)2 ListSelectionEvent (javax.swing.event.ListSelectionEvent)2 ListSelectionListener (javax.swing.event.ListSelectionListener)2 Account (com.moneychanger.core.Account)1 OpenTransactionAccount (com.moneychanger.core.OpenTransactionAccount)1 RippleAccount (com.moneychanger.core.RippleAccount)1 BitcoinDetails (com.moneychanger.core.dataobjects.BitcoinDetails)1 ContactDetails (com.moneychanger.core.dataobjects.ContactDetails)1 ComboObject (com.moneychanger.core.util.ComboObject)1 ContactDetailsTableModel (com.moneychanger.ui.model.ContactDetailsTableModel)1 ContactTableModel (com.moneychanger.ui.model.ContactTableModel)1 OtherTabAccountModel (com.moneychanger.ui.model.OtherTabAccountModel)1 ContactAcctPanel (com.moneychanger.ui.panels.ContactAcctPanel)1 ContactNymPanel (com.moneychanger.ui.panels.ContactNymPanel)1 AWTException (java.awt.AWTException)1 Point (java.awt.Point)1 JPanel (javax.swing.JPanel)1