1 18 19 package sync4j.syncclient.demo; 20 21 import java.awt.BorderLayout ; 22 import java.awt.Button ; 23 import java.awt.GridLayout ; 24 import java.awt.Label ; 25 import java.awt.Panel ; 26 import java.awt.event.ActionEvent ; 27 import java.awt.event.ActionListener ; 28 29 import sync4j.foundation.pdi.contact.Contact; 30 31 38 public class ContactModify 39 extends Panel 40 implements ActionListener , ConfigurationParameters { 41 42 44 46 private MainWindow mw = null ; 50 51 private ContactForm form = null ; 52 private CheckContactFields cfields = null ; 53 54 private Language ln = new Language() ; 55 56 58 63 public ContactModify(MainWindow mw) { 64 65 Button butCancel = null ; 66 Button butOk = null ; 67 Label title = null ; 68 Panel buttonPanel = null ; 69 70 this.mw = mw; 71 72 setLayout(new BorderLayout ()); 73 title = new Label (ln.getString ("contact_modify")); 74 75 form = new ContactForm(mw); 76 77 butOk = new Button (ln.getString ("ok" ) ) ; 78 butOk.setActionCommand ("ok" ) ; 79 butOk.addActionListener (this ) ; 80 81 butCancel = new Button (ln.getString ("cancel" ) ) ; 82 butCancel.setActionCommand ("cancel" ) ; 83 butCancel.addActionListener (this ) ; 84 85 buttonPanel = new Panel (); 86 buttonPanel.setLayout(new GridLayout (1, 2)); 87 buttonPanel.add (butOk ) ; 88 buttonPanel.add (butCancel ) ; 89 90 add(title , BorderLayout.NORTH ) ; 91 add(form , BorderLayout.CENTER ) ; 92 add(buttonPanel , BorderLayout.SOUTH ) ; 93 } 94 95 100 public void actionPerformed(ActionEvent evt) { 101 102 if (evt.getActionCommand().equals("ok")) { 103 104 cfields = new CheckContactFields(mw, form); 105 106 if (!cfields.areFieldsRight()) { 107 cfields.show(); 108 mw.setEnabled(false); 109 } else { 110 saveContact(); 111 } 112 113 } else if (evt.getActionCommand().equals("cancel")) { 114 mw.show(KEY_CONTACTLIST); 115 } 116 } 117 118 120 126 protected void fillFields(Contact contact) { 127 form.setFields(contact); 128 } 129 130 132 135 private void saveContact() { 136 mw.writeModContact(form.getFields(),mw.getCurrentIndex().intValue()); 137 mw.show(KEY_CONTACTLIST); 138 } 139 140 } | Popular Tags |