KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sellwin > gui > AlarmDialog


1 package sellwin.gui;
2
3 import javax.swing.*;
4
5 import sellwin.domain.*;
6 import sellwin.utils.*;
7
8 // SellWin http://sourceforge.net/projects/sellwincrm
9
//Contact support@open-app.com for commercial help with SellWin
10
//This software is provided "AS IS", without a warranty of any kind.
11

12 /**
13  * this class implements a pop up dialog to show a
14  * user's alarms...after which, the user can elect
15  * to forget the alarm or be reminded of the alarm
16  * later on
17  */

18 public class AlarmDialog extends javax.swing.JDialog JavaDoc implements GUIChars {
19
20     private Activity act;
21     private Whiteboard wb=null;
22
23     /**
24      * Creates new form AlarmDialog
25      * @param parent the parent frame for this dialog
26      * @param modal is this dialog to be modal or not
27      * @param act the Activity to display on this dialog
28      */

29     public AlarmDialog(java.awt.Frame JavaDoc parent, boolean modal, Activity act) {
30         super(parent, modal);
31         this.act = act;
32         wb = MainWindow.getWhiteboard();
33         initComponents();
34         setActivity(act);
35         setColors();
36         setFonts();
37         setLang();
38         setSize(300, 150);
39     }
40
41     /**
42      * set this dialog's Activity to display
43      * @param a the Activity to display
44      */

45     private final void setActivity(Activity a) {
46         activityLabel.setText(a.getSubject());
47         startDateLabel.setText(Prefs.dateTimeFormat.format(a.getStartDate()));
48         byLabel.setText(a.getModifiedBy());
49     }
50
51     /**
52      * This method is called from within the constructor to
53      * initialize the form.
54      */

55     private final void initComponents() {
56         buttonPanel = new JPanel();
57         remindButton = new JButton();
58         forgetButton = new JButton();
59         mainPanel = new JPanel();
60         jLabel1 = new JLabel();
61         jLabel2 = new JLabel();
62         jLabel3 = new JLabel();
63         activityLabel = new JLabel();
64         startDateLabel = new JLabel();
65         byLabel = new JLabel();
66         
67         setTitle("Alarm Details");
68         addWindowListener(new java.awt.event.WindowAdapter JavaDoc() {
69             public void windowClosing(java.awt.event.WindowEvent JavaDoc evt) {
70                 closeDialog(evt);
71             }
72         });
73         
74         remindButton.setText("Remind Later");
75         remindButton.addActionListener(new java.awt.event.ActionListener JavaDoc() {
76             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
77                 remindAction(evt);
78             }
79         });
80         
81         buttonPanel.add(remindButton);
82         
83         forgetButton.setText("Forget");
84         forgetButton.addActionListener(new java.awt.event.ActionListener JavaDoc() {
85             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
86                 forgetAction(evt);
87             }
88         });
89         
90         buttonPanel.add(forgetButton);
91         
92         getContentPane().add(buttonPanel, java.awt.BorderLayout.SOUTH);
93         
94         mainPanel.setLayout(new java.awt.GridBagLayout JavaDoc());
95         java.awt.GridBagConstraints JavaDoc gridBagConstraints1;
96         
97         mainPanel.setBorder(new javax.swing.border.EtchedBorder JavaDoc());
98         jLabel1.setText("Activity");
99         gridBagConstraints1 = new java.awt.GridBagConstraints JavaDoc();
100         gridBagConstraints1.ipadx = 10;
101         gridBagConstraints1.ipady = 10;
102         gridBagConstraints1.anchor = java.awt.GridBagConstraints.EAST;
103         mainPanel.add(jLabel1, gridBagConstraints1);
104         
105         jLabel2.setText("Alarm Date");
106         gridBagConstraints1 = new java.awt.GridBagConstraints JavaDoc();
107         gridBagConstraints1.gridx = 0;
108         gridBagConstraints1.gridy = 1;
109         gridBagConstraints1.ipadx = 10;
110         gridBagConstraints1.ipady = 10;
111         gridBagConstraints1.anchor = java.awt.GridBagConstraints.EAST;
112         mainPanel.add(jLabel2, gridBagConstraints1);
113         
114         jLabel3.setText("By");
115         gridBagConstraints1 = new java.awt.GridBagConstraints JavaDoc();
116         gridBagConstraints1.gridx = 0;
117         gridBagConstraints1.gridy = 2;
118         gridBagConstraints1.ipadx = 10;
119         gridBagConstraints1.ipady = 10;
120         gridBagConstraints1.anchor = java.awt.GridBagConstraints.EAST;
121         mainPanel.add(jLabel3, gridBagConstraints1);
122         
123         activityLabel.setText("activityLabel");
124         gridBagConstraints1 = new java.awt.GridBagConstraints JavaDoc();
125         gridBagConstraints1.gridx = 1;
126         gridBagConstraints1.gridy = 0;
127         gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
128         mainPanel.add(activityLabel, gridBagConstraints1);
129         
130         startDateLabel.setText("startDateLabel");
131         gridBagConstraints1 = new java.awt.GridBagConstraints JavaDoc();
132         gridBagConstraints1.gridx = 1;
133         gridBagConstraints1.gridy = 1;
134         gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
135         mainPanel.add(startDateLabel, gridBagConstraints1);
136         
137         byLabel.setText("byLabel");
138         gridBagConstraints1 = new java.awt.GridBagConstraints JavaDoc();
139         gridBagConstraints1.gridx = 1;
140         gridBagConstraints1.gridy = 2;
141         gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
142         mainPanel.add(byLabel, gridBagConstraints1);
143         
144         getContentPane().add(mainPanel, java.awt.BorderLayout.CENTER);
145         
146         pack();
147     }
148
149     /**
150      * the action that gets called when the 'forget' button is
151      * pressed
152      * @param evt the ActionEvent that gets called
153      */

154     private void forgetAction(java.awt.event.ActionEvent JavaDoc evt) {
155         // Add your handling code here:
156
act.setAlarmAck(true);
157         try {
158             wb.updateActivity(wb.getCurrentOpportunity().getPK(), act);
159             hide();
160         } catch (Exception JavaDoc e) {
161             ErrorHandler.show(this, e);
162         }
163     }
164
165     /**
166      * called when the 'remind' button is pressed
167      * @evt the ActionEvent that we receive by our friend "mr java"
168      */

169     private void remindAction(java.awt.event.ActionEvent JavaDoc evt) {
170         setVisible(false);
171         dispose();
172     }
173
174     /**
175      * Closes the dialog
176      * @param evt the WindowEvent we get
177      */

178     private final void closeDialog(java.awt.event.WindowEvent JavaDoc evt) {
179         setVisible(false);
180         dispose();
181     }
182
183
184     /**
185      * set the screen's colors
186      */

187     public final void setColors() {
188         jLabel1.setForeground(MainWindow.LETTERS);
189         jLabel2.setForeground(MainWindow.LETTERS);
190         jLabel3.setForeground(MainWindow.LETTERS);
191         activityLabel.setForeground(MainWindow.LETTERS);
192         startDateLabel.setForeground(MainWindow.LETTERS);
193         byLabel.setForeground(MainWindow.LETTERS);
194     }
195
196     /**
197      * set the screen's fonts
198      */

199     public final void setFonts() {
200         jLabel1.setFont(MainWindow.LABEL_FONT);
201         jLabel2.setFont(MainWindow.LABEL_FONT);
202         jLabel3.setFont(MainWindow.LABEL_FONT);
203         remindButton.setFont(MainWindow.LABEL_FONT);
204         forgetButton.setFont(MainWindow.LABEL_FONT);
205         activityLabel.setFont(MainWindow.FIELD_FONT);
206         startDateLabel.setFont(MainWindow.FIELD_FONT);
207         byLabel.setFont(MainWindow.FIELD_FONT);
208     };
209
210     /**
211      * set the dialog's language
212      */

213     public final void setLang() {
214         setTitle(wb.getLang().getString("alarmInfo"));
215         jLabel1.setText(wb.getLang().getString("activity"));
216         jLabel2.setText(wb.getLang().getString("startDate"));
217         jLabel3.setText(wb.getLang().getString("by"));
218         remindButton.setText(wb.getLang().getString("remind"));
219         forgetButton.setText(wb.getLang().getString("forget"));
220     }
221
222     private JPanel buttonPanel;
223     private JButton remindButton;
224     private JButton forgetButton;
225     private JPanel mainPanel;
226     private JLabel jLabel1;
227     private JLabel jLabel2;
228     private JLabel jLabel3;
229     private JLabel activityLabel;
230     private JLabel startDateLabel;
231     private JLabel byLabel;
232     
233 }
234
Popular Tags