1 18 package sync4j.syncclient.ipod.panels; 19 20 import java.util.Hashtable ; 21 22 import java.awt.Color ; 23 import java.awt.event.ActionEvent ; 24 import java.awt.event.ActionListener ; 25 26 import javax.swing.JDialog ; 27 import javax.swing.JPanel ; 28 import javax.swing.JButton ; 29 import javax.swing.UIManager ; 30 import javax.swing.JLabel ; 31 import javax.swing.JTextField ; 32 import javax.swing.border.*; 33 import javax.swing.SwingConstants ; 34 35 import sync4j.syncclient.ipod.MainWindow; 36 import sync4j.syncclient.ipod.utils.*; 37 38 44 public class RemoteSetPanel extends JDialog 45 implements ActionListener , Constants { 46 47 private Hashtable htFields = new Hashtable (); 49 private MainWindow mainWindow ; 50 private JPanel jpOver ; 51 private JPanel jpUp ; 52 private JLabel jLabel1 ; 53 private JLabel jLabel2 ; 54 private JLabel jLabel3 ; 55 private JTextField jtContact ; 56 private JTextField jtCalendar ; 57 private JTextField jtNote ; 58 private JButton btOk ; 59 private JButton btCancel ; 60 61 private Hashtable htContactValues = null; 62 private Hashtable htCalendarValues = null; 63 private Hashtable htNoteValues = null; 64 65 67 68 public RemoteSetPanel(MainWindow mainWindow, boolean modal) { 69 super(mainWindow, modal); 70 this.mainWindow = mainWindow; 71 72 htContactValues = mainWindow.getXmlContactValues(); 73 htCalendarValues = mainWindow.getXmlCalendarValues(); 74 htNoteValues = mainWindow.getXmlNoteValues(); 75 76 initComponents(); 77 setRemoteConfigStored(); 78 } 79 80 84 private void initComponents() { 85 int xlab = 18 ; 86 int wlab = 80 ; 87 int hlab = 24 ; 88 int xtext = 152; 89 int wtext = 125; 90 int htext = 21 ; 91 int ybt = 150; 92 int wbt = 88 ; 93 int hbt = 24 ; 94 int y = 22 ; 95 int dy = 23 ; 96 97 jpOver = new JPanel (); 98 jpUp = new JPanel (); 99 jLabel1 = new JLabel (); 100 jLabel2 = new JLabel (); 101 jLabel3 = new JLabel (); 102 jtContact = new JTextField (); 103 jtCalendar = new JTextField (); 104 jtNote = new JTextField (); 105 btOk = new JButton (); 106 btCancel = new JButton (); 107 108 try { 109 UIManager.setLookAndFeel(lookAndFeel); 110 } catch(Exception e) { 111 e.printStackTrace(); 112 } 113 114 getContentPane().setLayout(null); 118 119 setTitle(Language.getMessage(Language.LABEL_TITLE_REMOTESET)); 120 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); 121 setSize(310,218); 122 setLocationRelativeTo(null); 123 setFont(font); 124 setName("remoteSetDialog"); 125 setResizable(false); 126 127 jpOver.setLayout(null); 128 jpOver.setBackground(Color.WHITE); 129 jpOver.setForeground(Color.WHITE); 130 jpOver.setBounds(0, 0, 310, 218); 131 getContentPane().add(jpOver); 132 133 jpUp.setLayout(null); 137 jpUp.setBounds(7, 15, 290, 115); 138 jpUp.setBackground(Color.WHITE); 139 jpUp.setBorder(new TitledBorder( 140 new LineBorder(new Color (204,204,204), 1, true), 141 Language.getMessage(Language.LABEL_TITLE_REMOTESET), 142 1, 143 0, 144 font, 145 new Color (0,51,204)) 146 ); 147 jpUp.setName("remoteSet"); 148 149 jLabel1.setText(Language.getMessage(Language.LABEL_REMOTE_CONTACT)); 150 jLabel1.setFont(font); 151 jLabel1.setBounds(xlab, y, wlab, hlab); 152 jLabel1.setVerticalAlignment(SwingConstants.CENTER); 153 jpUp.add(jLabel1); 154 155 jtContact.setText(""); 156 jtContact.setFont(font); 157 jtContact.setBounds(xtext, y, wtext, htext); 158 jtContact.requestFocusInWindow(); 159 jpUp.add(jtContact); 160 161 y +=dy; 162 163 jLabel2.setText(Language.getMessage(Language.LABEL_REMOTE_CALENDAR)); 164 jLabel2.setFont(font); 165 jLabel2.setBounds(xlab, y, wlab, hlab); 166 jLabel2.setVerticalAlignment(SwingConstants.CENTER); 167 jpUp.add(jLabel2); 168 169 jtCalendar.setText(""); 170 jtCalendar.setFont(font); 171 jtCalendar.setBounds(xtext, y, wtext, htext); 172 jpUp.add(jtCalendar); 173 174 y +=dy; 175 176 jLabel3.setText(Language.getMessage(Language.LABEL_REMOTE_NOTE)); 177 jLabel3.setFont(font); 178 jLabel3.setBounds(xlab, y, wlab, hlab); 179 jLabel3.setVerticalAlignment(SwingConstants.CENTER); 180 jLabel3.setVisible(false); 181 jpUp.add(jLabel3); 182 183 jtNote.setText(""); 184 jtNote.setFont(font); 185 jtNote.setBounds(xtext, y, wtext, htext); 186 jtNote.setVisible(false); 187 jpUp.add(jtNote); 188 189 jpOver.add(jpUp); 190 191 btOk.setText(Language.getMessage(Language.BT_OK)); 192 btOk.setActionCommand("OK"); 193 btOk.setName("btOk"); 194 btOk.setFont(font); 195 btOk.setBounds(112, ybt, wbt, hbt); 196 btOk.addActionListener(this); 197 198 jpOver.add(btOk); 199 200 btCancel.setText(Language.getMessage(Language.BT_CANCEL)); 201 btCancel.setActionCommand("CANCEL"); 202 btCancel.setName("btCancel"); 203 btCancel.setBounds(210, ybt, wbt, hbt); 204 btCancel.setFont(font); 205 btCancel.addActionListener(this); 206 jpOver.add(btCancel); 207 208 jtContact.setNextFocusableComponent(jtCalendar); 209 jtCalendar.setNextFocusableComponent(jtNote) ; 210 jtNote.setNextFocusableComponent(btOk) ; 211 btOk.setNextFocusableComponent(btCancel) ; 212 btCancel.setNextFocusableComponent(jtContact) ; 213 } 214 215 public void actionPerformed(ActionEvent evt) { 216 if (evt.getActionCommand().equals("OK")) { 217 htFields.put(PARAM_SOURCEURICONTACT , jtContact.getText() ); 218 htFields.put(PARAM_SOURCEURICALENDAR, jtCalendar.getText()); 219 htFields.put(PARAM_SOURCEURINOTE , jtNote.getText() ); 220 221 mainWindow.writeRemoteSettings(htFields); 222 223 removeAll(); 224 setVisible(false); 225 } else if (evt.getActionCommand().equals("CANCEL")) { 226 removeAll(); 227 setVisible(false); 228 } 229 } 230 231 235 private void setRemoteConfigStored() { 236 237 String contactSourceURI = (String )htContactValues.get(PARAM_SYNCSOURCEURI); 238 String calendarSourceURI = (String )htCalendarValues.get(PARAM_SYNCSOURCEURI); 239 String noteSourceURI = (String )htNoteValues.get(PARAM_SYNCSOURCEURI); 240 241 htFields.put(PARAM_SOURCEURICONTACT , contactSourceURI ); 242 htFields.put(PARAM_SOURCEURICALENDAR, calendarSourceURI); 243 htFields.put(PARAM_SOURCEURINOTE , noteSourceURI ); 244 245 jtContact.setText(contactSourceURI); 246 jtCalendar.setText(calendarSourceURI); 247 jtNote.setText(noteSourceURI); 248 } 249 } 250 | Popular Tags |