use of com.moneychanger.core.dataobjects.ContactDetails 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);
}
}
});
}
use of com.moneychanger.core.dataobjects.ContactDetails in project otapij by FellowTraveler.
the class AddressBookHelper method getContactDetails.
public static ContactDetails getContactDetails(String contactID, int mode) {
ContactDetails contactDetails = null;
AddressBook addressBook = Helpers.getAddressBook();
if (addressBook == null) {
System.out.println("getContactDetails - addressBook returns null");
return null;
}
for (int i = 0; i < addressBook.GetContactCount(); i++) {
Contact contact = addressBook.GetContact(i);
if (contact == null)
continue;
if (contactID.equals(contact.getContact_id())) {
contactDetails = new ContactDetails();
contactDetails.setEmail(contact.getEmail());
contactDetails.setLabel(contact.getGui_label());
contactDetails.setPublicKey(contact.getPublic_key());
contactDetails.setMemo(contact.getMemo());
contactDetails.setContact(contact);
List data = new ArrayList();
System.out.println("mode:" + mode + " contact.GetContactAcctCount():" + contact.GetContactAcctCount());
if (mode == 1) {
for (int j = 0; j < contact.GetContactAcctCount(); j++) {
if (contact.GetContactAcct(j) == null)
continue;
data.add(new String[] { contact.GetContactAcct(j).getGui_label() });
}
contactDetails.setContactAccts(data);
} else {
for (int j = 0; j < contact.GetContactNymCount(); j++) {
if (contact.GetContactNym(j) == null)
continue;
data.add(new String[] { contact.GetContactNym(j).getGui_label() });
}
contactDetails.setContactNyms(data);
}
break;
}
}
return contactDetails;
}
Aggregations