-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNurse_Menu_Panel.java
More file actions
executable file
·361 lines (241 loc) · 9.8 KB
/
Nurse_Menu_Panel.java
File metadata and controls
executable file
·361 lines (241 loc) · 9.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
/*****************************************************************************************************
* A Nurse menu to display to the user 3 options, modify, lookup, record lookup. Each button takes you
* to a different panel, the modify panel is an inner class in this file, the other 2 are seperate files
* named Nurse_Lookup_Panel and Nurse_Record_Lookup_Panel.
*****************************************************************************************************/
public class Nurse_Menu_Panel extends JPanel
{
/* Pointer to the main java window to access its get() methods for other panels */
protected Hospital_Frame main_frame;
/* Button to return the screen to the main menu */
protected JPanel main_menu_button;
/* Current interface displayed to the user, displaying either button options or an interface based
* on button pressed */
protected JPanel current_panel;
/*********************************************************************************
* Main constructor used for setting up the Nurse_Menu_Panel.
*********************************************************************************/
public Nurse_Menu_Panel(Hospital_Frame main)
{
this.main_frame = main;
//setLayout(new GridLayout(2, 1));
setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
add(current_panel = new Nurse_Button_Options());
// skip a row in the grid layout
//add(new JLabel(""));
add(main_menu_button = new Main_Menu_Button(main_frame));
}
/*********************************************************************************
* Switches the current main panel to the passed in one.
*********************************************************************************/
protected void changeCurrentPanel(JPanel panel)
{
removeAll();
add(current_panel = panel);
// re-add the main menu button so it appears after the panel again
add(main_menu_button = new Main_Menu_Button(main_frame));
revalidate();
repaint();
} // end changeCurrentPanel()
/*********************************************************************************
* Different button options for the user for interacting with the Nurse tuples
* in the database.
*********************************************************************************/
protected class Nurse_Button_Options extends JPanel
{
/*********************************************************************************
* Main constructor for the Nurse_Button_Options class.
*********************************************************************************/
public Nurse_Button_Options()
{
setLayout(new GridBagLayout());
add(new Search_Nurses_Button());
add(new Search_Records_Nurses_Button());
}
/*********************************************************************************
* Button to take user to search Nurses panel by switching the current panel
* to an instance of Search_Nurses_Panel.
*********************************************************************************/
private class Search_Nurses_Button extends JButton
{
public Search_Nurses_Button()
{
super("Search Nurses");
addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
changeCurrentPanel(new Nurse_Lookup_Panel());
}
});
}
}
/*********************************************************************************
* Button to take user to search Nurses panel by switching the current panel
* to an instance of Search_Records_Nurses_Panel.
*********************************************************************************/
private class Search_Records_Nurses_Button extends JButton
{
public Search_Records_Nurses_Button()
{
super("Search Records for a Nurse");
addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
changeCurrentPanel(new Nurse_Record_Lookup_Panel());
}
});
}
}
} // end Nurse_Button_Options class
/********************************************************************************************************
* Displayed when the user selects 'modify' in the Nurse_Menu_Panel.
********************************************************************************************************/
private class Modify_Nurse_Info_Panel extends JPanel
{
/*******************************************************************************************
* Main constructor for the Nurse_Button_Options class.
*******************************************************************************************/
public Modify_Nurse_Info_Panel()
{
setLayout(new GridBagLayout());
add(new Back_Button());
add(new Select_Attribute_Panel());
}
/*******************************************************************************************
* Displayed after modify clicked on the Modify_Nurse_Info_Panel in the Nurse_Menu_Panel.
*******************************************************************************************/
private class Select_Attribute_Panel extends JPanel
{
/******************************************************************************
* Main constructor for Select_Attribute_Panel.
******************************************************************************/
public Select_Attribute_Panel()
{
add(new JLabel("Modify : "));
add(new Supervisor_Button());
}
/******************************************************************************
* Button in the Modify_Nurse_Info_Panel to take the user to the
* Supervisor_Modificaton_Panel when pressed.
******************************************************************************/
private class Supervisor_Button extends JButton
{
/******************************************************************
* Main constructor for Supervisor_Button.
******************************************************************/
public Supervisor_Button()
{
super("Supervisor");
addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
changeCurrentPanel(new Supervisor_Modificaton_Panel());
}
});
}
} // end Supervisor_Button Class
} // end Select_Attribute_Panel Class
/*******************************************************************************************
* Panel displayed when user selects to modify a Nurse's age in the Select_Attribute_Panel.
*******************************************************************************************/
private class Supervisor_Modificaton_Panel extends JPanel
{
private JTextField supervisor_field, ssn_field;
private String ssn, supervisor;
/******************************************************************************
* Main constructor for Supervisor_Modificaton_Panel.
******************************************************************************/
public Supervisor_Modificaton_Panel()
{
setLayout(new GridBagLayout());
add(new Back_Button());
add(new JLabel(" Change Supervisor To "));
add(supervisor_field = new JTextField(10));
add(new JLabel(" for Nurse with SSN "));
add(ssn_field = new JTextField(7));
add(new Submit_Button());
}
/******************************************************************************
* Submit button for Supervisor_Modificaton_Panel class.
******************************************************************************/
private class Submit_Button extends JButton
{
/******************************************************************
* Main construcot for Submit_Button.
******************************************************************/
public Submit_Button()
{
super("Submit");
addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
loadText();
String input = ssn + supervisor;
// pass input into Nurse instance to modify tuple
}
});
}
/******************************************************************
* Load input from supervisor and ssn fields into corresponding int and
* string variables.
*
* If load is successful, true is returned, otherwise, false
* is returned.
******************************************************************/
private boolean loadText()
{
// get ssn from field
try
{
ssn = ssn_field.getText();
}
catch (Exception e)
{
JOptionPane.showMessageDialog(new JPanel(), "SSN input invalid", "Error", JOptionPane.ERROR_MESSAGE);
return false;
}
// get supervisor from field
try
{
supervisor = supervisor_field.getText();
}
catch (Exception e)
{
JOptionPane.showMessageDialog(new JPanel(), "Supervisor input invalid", "Error", JOptionPane.ERROR_MESSAGE);
return false;
}
// if this point is reached supervisor and ssn were successfully retrieved
return true;
}
} // end Submit_Button class
} // end Supervisor_Modificaton_Panel class
} // end Modify_Nurse_Info_Panel class
/*********************************************************************************
* Returns the user to the Nurse menu.
*********************************************************************************/
private class Back_Button extends JButton
{
/******************************************************************
* Main constructor for Back_Button
******************************************************************/
public Back_Button()
{
super("<- Back");
addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
changeCurrentPanel(new Nurse_Button_Options());
//main_frame.changeScreen(new Nurse_Menu_Panel(main_frame));
}
});
}
} // end Back_Button class
} // end Nurse menu class