01: package com.xoetrope.medical.forms;
02:
03: import com.xoetrope.swing.XDateEdit;
04: import com.xoetrope.swing.date.XTimeChooser;
05: import net.xoetrope.swing.XComboBox;
06: import net.xoetrope.swing.XDialog;
07: import net.xoetrope.swing.XEdit;
08: import net.xoetrope.xui.data.XBaseModel;
09:
10: /**
11: *
12: * @author kingsley.elmes
13: */
14:
15: // adds functionality to Add Existing and Add New dialogs
16: public class AddPrior extends XDialog {
17: XComboBox drugbox, frequencybox, dosageunit, routebox, targetunit;
18: XDateEdit startdateinput, enddateinput;
19: XEdit dosageamt, targetamt;
20: XTimeChooser timeinput;
21: static int id;
22:
23: public AddPrior() {
24: }
25:
26: public void pageActivated() {
27: id += 1; // increment table entry id
28:
29: // reference XUI components used in dialog
30: drugbox = (XComboBox) findComponent("drugbox");
31: frequencybox = (XComboBox) findComponent("frequencybox");
32: dosageunit = (XComboBox) findComponent("dosageunit");
33: routebox = (XComboBox) findComponent("routebox");
34: startdateinput = (XDateEdit) findComponent("startdateinput");
35: enddateinput = (XDateEdit) findComponent("enddateinput");
36: dosageamt = (XEdit) findComponent("dosageamt");
37: timeinput = (XTimeChooser) findComponent("timeinput");
38: targetamt = (XEdit) findComponent("targetamt");
39: targetunit = (XComboBox) findComponent("targetunit");
40: }
41:
42: public void saveClick() {
43: // obtain reference to priorAED table
44: XBaseModel priorAED = (XBaseModel) rootModel.get("priorAED");
45:
46: // add new node to the priorAED table
47: XBaseModel newRow = (XBaseModel) priorAED.get("newNode" + id);
48: newRow.setAttribValue(XBaseModel.VALUE_ATTRIBUTE,
49: ("newNode" + id));
50:
51: // add values to appropriate columns in table
52: newRow.set("1", drugbox.getSelectedItem().toString());
53: newRow.set("2", startdateinput.getText());
54: newRow.set("3", enddateinput.getText());
55: newRow.set("4", dosageamt.getText() + " "
56: + dosageunit.getSelectedItem().toString());
57: newRow.set("5", frequencybox.getSelectedItem().toString());
58: newRow.set("6", timeinput.getSelectedItem().toString());
59: newRow.set("7", routebox.getSelectedItem().toString());
60: newRow.set("8", targetamt.getText() + " "
61: + targetunit.getSelectedItem().toString());
62: newRow.set("9", "");
63:
64: closeDlg();
65: }
66: }
|