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 27 import java.awt.event.ActionEvent ; 28 import java.awt.event.ActionListener ; 29 30 import sync4j.foundation.pdi.event.Calendar; 31 32 40 public class CalendarModify 41 extends Panel 42 implements ActionListener , ConfigurationParameters { 43 44 46 48 private MainWindow mw = null ; 52 53 private CalendarForm form = null ; 54 private CheckCalendarFields cfields = null ; 55 56 private Language ln = new Language() ; 57 58 60 65 public CalendarModify(MainWindow mw) { 66 67 Button butOk = null ; 68 Button butCancel = null ; 69 Panel buttonPanel = null ; 70 71 Label title = null ; 72 73 this.mw = mw; 74 75 setLayout(new BorderLayout ()); 76 title = new Label (ln.getString ("calendar_modify") ); 77 78 form = new CalendarForm(mw); 79 80 butOk = new Button (ln.getString ("ok") ) ; 81 butOk.setActionCommand ("ok" ) ; 82 butOk.addActionListener (this ) ; 83 84 butCancel = new Button (ln.getString ("cancel") ) ; 85 butCancel.setActionCommand ("cancel" ) ; 86 butCancel.addActionListener (this ) ; 87 88 buttonPanel = new Panel (); 89 buttonPanel.setLayout(new GridLayout (1,2)); 90 buttonPanel.add (butOk ) ; 91 buttonPanel.add (butCancel ) ; 92 93 add(title , BorderLayout.NORTH ) ; 94 add(form , BorderLayout.CENTER ) ; 95 add(buttonPanel , BorderLayout.SOUTH ) ; 96 } 97 98 103 public void actionPerformed(ActionEvent evt) { 104 105 if (evt.getActionCommand().equals("ok")) { 106 cfields = new CheckCalendarFields(mw, form); 107 if (!cfields.areFieldsRight()) { 108 cfields.show(); 109 mw.setEnabled(false); 110 } else { 111 saveCalendar(); 112 } 113 114 } else if (evt.getActionCommand().equals("cancel")) { 115 mw.show(KEY_CALENDARLIST); 116 } 117 } 118 119 121 128 protected void fillFields(Calendar calendar) { 129 form.setFields(calendar); 130 } 131 132 134 137 private void saveCalendar() { 138 mw.writeModCalendar(form.getFields(),mw.getCurrentIndex().intValue()); 139 mw.show(KEY_CALENDARLIST); 140 } 141 142 } | Popular Tags |