Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

DiagnosisEditor.java

Go to the documentation of this file.
00001 import java.util.Vector;
00002 
00003 public class DiagnosisEditor extends Widget
00004 {
00005   public int active;
00006   public Vector diagnoses;
00007         public ActionButton action;
00008 
00009         public static final int SAVE = 1;
00010         public static final int SAVEADD = 2;
00011         public static final int CANCEL = 3;
00012 
00013         public TextBox name, description;
00014 
00015         boolean done = false;
00016         boolean more = false;
00017 
00018         public DiagnosisEditor(int active, Vector diagnoses, String prefix, Form form)
00019         {
00020           super(prefix, form);
00021           this.active = active;
00022           this.diagnoses = diagnoses;
00023     name = new TextBox(0,40, n("name"), form);
00024     description = new TextBox(10, 40, n("description"), form);
00025     action = new ActionButton(n("action"), form);
00026 
00027     addChild(name);
00028     addChild(description);
00029     addChild(action);
00030         }
00031 
00032   public void save()
00033   {
00034     Diagnosis d;
00035     if (active < 0)
00036     {
00037       d = new Diagnosis();
00038       diagnoses.add(d);
00039     }
00040     else
00041     {
00042       d = (Diagnosis) diagnoses.get(active);
00043     }
00044 
00045     d.name = name.text;
00046     d.description = description.text;
00047   }
00048 
00049   public void loadDefaults()
00050   {
00051     if (active < 0) return;
00052     Diagnosis load = (Diagnosis) diagnoses.get(active);
00053     name.text = load.name;
00054     description.text = load.description;
00055   }
00056 
00057         public void loadValues()
00058         {
00059     super.loadValues();
00060 
00061     switch(action.action)
00062     {
00063       case SAVE:
00064         done = true;
00065         save();
00066       break;
00067       case CANCEL:
00068         done = true;
00069       break;
00070       case SAVEADD:
00071         more = true;
00072         save();
00073       break;
00074     }
00075         }
00076 
00077         public void display(boolean hidden)
00078   {
00079     if (hidden)
00080     {
00081       name.display(true);
00082       description.display(true);
00083       action.display(true);
00084       return;
00085     }
00086     p(
00087 "\n"+
00088 "<h4>Diagnosis</h4>\n"+
00089 "<table>\n"+
00090 "<tr>\n"+
00091 "  <td valign=top>Name:</td>\n"+
00092 "  <td>"); name.display(); p("</td>\n"+
00093 "</tr>\n"+
00094 "<tr>\n"+
00095 "  <td valign=top>Description:</td>\n"+
00096 "  <td>"); description.display(); p("</td>\n"+
00097 "</tr>\n"+
00098 "<tr>\n"+
00099 "  <td>&nbsp;</td>\n"+
00100 "  <td>\n"+
00101 "");
00102     action.display("Save", SAVE);
00103     action.display("Save and Add Another", SAVEADD);
00104     action.display("Cancel", CANCEL); p("\n"+
00105 "  </td>\n"+
00106 "</tr>\n"+
00107 "</table>\n"+
00108 "");
00109   }
00110 };

Generated on Mon Mar 6 23:34:34 2006 by  doxygen 1.4.4