KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sync4j > syncclient > ipod > panels > RemoteSetPanel


1 /**
2  * Copyright (C) 2005 Funambol
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18 package sync4j.syncclient.ipod.panels;
19
20 import java.util.Hashtable JavaDoc;
21
22 import java.awt.Color JavaDoc;
23 import java.awt.event.ActionEvent JavaDoc;
24 import java.awt.event.ActionListener JavaDoc;
25
26 import javax.swing.JDialog JavaDoc;
27 import javax.swing.JPanel JavaDoc;
28 import javax.swing.JButton JavaDoc;
29 import javax.swing.UIManager JavaDoc;
30 import javax.swing.JLabel JavaDoc;
31 import javax.swing.JTextField JavaDoc;
32 import javax.swing.border.*;
33 import javax.swing.SwingConstants JavaDoc;
34
35 import sync4j.syncclient.ipod.MainWindow;
36 import sync4j.syncclient.ipod.utils.*;
37
38 /**
39  * The Remote Synchronization settings window.
40  *
41  * @author Luigia Fassina @ Funambol
42  * @version $Id: RemoteSetPanel.java,v 1.4 2005/04/01 13:06:12 luigiafassina Exp $
43  */

44 public class RemoteSetPanel extends JDialog JavaDoc
45 implements ActionListener JavaDoc, Constants JavaDoc {
46
47     // ------------------------------------------- Private Data
48
private Hashtable JavaDoc htFields = new Hashtable JavaDoc();
49     private MainWindow mainWindow ;
50     private JPanel JavaDoc jpOver ;
51     private JPanel JavaDoc jpUp ;
52     private JLabel JavaDoc jLabel1 ;
53     private JLabel JavaDoc jLabel2 ;
54     private JLabel JavaDoc jLabel3 ;
55     private JTextField JavaDoc jtContact ;
56     private JTextField JavaDoc jtCalendar ;
57     private JTextField JavaDoc jtNote ;
58     private JButton JavaDoc btOk ;
59     private JButton JavaDoc btCancel ;
60
61     private Hashtable JavaDoc htContactValues = null;
62     private Hashtable JavaDoc htCalendarValues = null;
63     private Hashtable JavaDoc htNoteValues = null;
64
65     // ------------------------------------------ Public Methods
66

67     /** Creates new form JDialog */
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     /**
81      * This method is called from within the constructor to
82      * initialize the form.
83      */

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 JavaDoc();
98         jpUp = new JPanel JavaDoc();
99         jLabel1 = new JLabel JavaDoc();
100         jLabel2 = new JLabel JavaDoc();
101         jLabel3 = new JLabel JavaDoc();
102         jtContact = new JTextField JavaDoc();
103         jtCalendar = new JTextField JavaDoc();
104         jtNote = new JTextField JavaDoc();
105         btOk = new JButton JavaDoc();
106         btCancel = new JButton JavaDoc();
107
108         try {
109             UIManager.setLookAndFeel(lookAndFeel);
110         } catch(Exception JavaDoc e) {
111             e.printStackTrace();
112         }
113
114         //
115
// Set up the window.
116
//
117
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         //
134
// Internal panel for Remote Settings
135
//
136
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 JavaDoc(204,204,204), 1, true),
141                             Language.getMessage(Language.LABEL_TITLE_REMOTESET),
142                             1,
143                             0,
144                             font,
145                             new Color JavaDoc(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 JavaDoc 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     /**
232      * Sets the fields with some of the values contained
233      * in the specified Hashtables.
234      */

235     private void setRemoteConfigStored() {
236
237         String JavaDoc contactSourceURI = (String JavaDoc)htContactValues.get(PARAM_SYNCSOURCEURI);
238         String JavaDoc calendarSourceURI = (String JavaDoc)htCalendarValues.get(PARAM_SYNCSOURCEURI);
239         String JavaDoc noteSourceURI = (String JavaDoc)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