Search in sources :

Example 1 with ContactAcctPanel

use of com.moneychanger.ui.panels.ContactAcctPanel 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

ContactDetails (com.moneychanger.core.dataobjects.ContactDetails)1 ContactDetailsTableModel (com.moneychanger.ui.model.ContactDetailsTableModel)1 ContactTableModel (com.moneychanger.ui.model.ContactTableModel)1 BlankPanel (com.moneychanger.ui.panels.BlankPanel)1 ContactAcctPanel (com.moneychanger.ui.panels.ContactAcctPanel)1 ContactNymPanel (com.moneychanger.ui.panels.ContactNymPanel)1 CardLayout (java.awt.CardLayout)1 ListSelectionEvent (javax.swing.event.ListSelectionEvent)1 ListSelectionListener (javax.swing.event.ListSelectionListener)1