Search in sources :

Example 1 with ContactDetailsTableModel

use of com.moneychanger.ui.model.ContactDetailsTableModel in project otapij by FellowTraveler.

the class AddressBookDialog method populateContactDetails.

private void populateContactDetails(ContactDetails contactDetails, int mode) {
    this.contactDetails = contactDetails;
    if (contactDetails != null) {
        jTextField1.setText(contactDetails.getLabel());
        jTextField2.setText(contactDetails.getEmail());
        jTextArea1.setText(contactDetails.getPublicKey());
        jTextArea2.setText(contactDetails.getMemo());
        List list = mode == 1 ? contactDetails.getContactAccts() : contactDetails.getContactNyms();
        ((ContactDetailsTableModel) jTable6.getModel()).setValue(list);
    }
}
Also used : List(java.util.List) ContactDetailsTableModel(com.moneychanger.ui.model.ContactDetailsTableModel)

Example 2 with ContactDetailsTableModel

use of com.moneychanger.ui.model.ContactDetailsTableModel in project otapij by FellowTraveler.

the class AddressBookDialog method jButton4ActionPerformed.

//GEN-LAST:event_jTable6MouseClicked
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
    //GEN-FIRST:event_jButton4ActionPerformed
    String value = "account";
    boolean status = false;
    if (mode == 2) {
        value = "nym";
    }
    if (jTable6.getSelectedRow() < 0) {
        JOptionPane.showMessageDialog(null, "Please select contact " + value, "Contact Error", JOptionPane.ERROR_MESSAGE);
        return;
    }
    List list = null;
    if (mode == 1) {
        status = AddressBookHelper.removeContactAcct(contactID, jTable6.getSelectedRow());
        list = AddressBookHelper.getContactDetails(contactID, mode).getContactAccts();
    } else if (mode == 2) {
        status = AddressBookHelper.removeContactNym(contactID, jTable6.getSelectedRow());
        list = AddressBookHelper.getContactDetails(contactID, mode).getContactNyms();
    }
    if (status) {
        JOptionPane.showMessageDialog(null, "Contact " + value + " deleted successfull", "Contact Account", JOptionPane.INFORMATION_MESSAGE);
        ((ContactDetailsTableModel) jTable6.getModel()).setValue(list);
        clearDetails(mode);
    } else {
        JOptionPane.showMessageDialog(null, "Cannot delete contact " + value, "Contact Error", JOptionPane.ERROR_MESSAGE);
    }
}
Also used : List(java.util.List) ContactDetailsTableModel(com.moneychanger.ui.model.ContactDetailsTableModel)

Example 3 with ContactDetailsTableModel

use of com.moneychanger.ui.model.ContactDetailsTableModel 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

ContactDetailsTableModel (com.moneychanger.ui.model.ContactDetailsTableModel)3 List (java.util.List)2 ContactDetails (com.moneychanger.core.dataobjects.ContactDetails)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