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

ReferralList Class Reference

Inheritance diagram for ReferralList:

Widget List of all members.

Public Member Functions

 ReferralList (String prefix, Form form)
void loadValues ()
void display (boolean hidden)

Static Public Attributes

static final int ADD = 1
static final int EDIT = 2
static final int DELETE = 3

Package Attributes

ActionButton action
ReferralEditor editor
Vector referrals = new Vector()
int active

Detailed Description

Definition at line 4 of file ReferralList.java.


Constructor & Destructor Documentation

ReferralList::ReferralList String  prefix,
Form  form
[inline]
 

Definition at line 15 of file ReferralList.java.

References action, Widget::addChild(), and Widget::n().

00016         {
00017     super(prefix, form); 
00018     action = new ActionButton(n("action"), form);
00019     addChild(action);
00020         }


Member Function Documentation

void ReferralList::display boolean  hidden  )  [inline]
 

Reimplemented from Widget.

Definition at line 71 of file ReferralList.java.

References action, active, ADD, Query::close(), Form::connectDb(), DELETE, ActionButton::display(), ReferralEditor::display(), Referral::doctor_id, EDIT, editor, Widget::form, Referral::incoming, Widget::modal, Widget::p(), Widget::printAttribute(), Form::pw, Query::query(), Query::r, referrals, and Widget::serialize().

00072         {
00073     printAttribute("referrals", serialize(referrals));
00074 
00075     if (modal)
00076     {
00077       printAttribute("modal", "1");
00078       printAttribute("active", Integer.toString(active));
00079       editor.display(hidden);
00080       return;
00081     }
00082     else if (hidden)
00083       return;
00084     
00085     if (referrals.size() <= 0)
00086     {
00087       action.display("Add a referral...", ADD);
00088     }
00089     else
00090     {
00091       action.display("Add another referral...", ADD);
00092       p("<br>\n<table>\n");
00093       int l = referrals.size();
00094       
00095       Query q = new Query(form.connectDb(), form.pw);
00096       try
00097       {
00098         for(int i = 0; i < l; ++i)
00099         {
00100           Referral r = (Referral) referrals.get(i);
00101           
00102           q.query("\n"+
00103 "            SELECT d.name, p.name\n"+
00104 "            FROM doctors AS d\n"+
00105 "            INNER JOIN practices AS p USING (practice_id)\n"+
00106 "            WHERE d.doctor_ID = " + r.doctor_id
00107           );
00108           
00109           if (q.r == null) continue;
00110           
00111           String doctor = "unknown";
00112           String practice = "unknown";
00113           if (q.r.next() && q.r.isLast())
00114           {
00115             doctor = q.r.getString(1);
00116             practice = q.r.getString(2);
00117           }
00118 
00119           p(
00120 "\n"+
00121 "<tr>\n"+
00122 "  <td>\n"+
00123 "    <table border=1 RULES=NONE FRAME=BOX>\n"+
00124 "    <tr><td colspan=2><strong>Referral " + (r.incoming ? "From" : "To") + "</strong></td></tr>\n"+
00125 "    <tr>\n"+
00126 "      <td valign=top><i>Doctor:</i></td>\n"+
00127 "      <td>" + doctor + "</td>  \n"+
00128 "    </tr>\n"+
00129 "    <tr>\n"+
00130 "      <td valign=top><i>Practice:</i></td>\n"+
00131 "      <td>" + practice + "</td>  \n"+
00132 "    </tr>    \n"+
00133 "    </table>\n"+
00134 "  </td>\n"+
00135 "  <td>\n"+
00136 "  "); 
00137     action.display("Edit...", EDIT, i); p(" ");
00138     action.display("Delete", DELETE, i); p("\n"+
00139 "  </td>\n"+
00140 "</tr>\n"+
00141 "");
00142         } // for
00143       } // try
00144       catch (SQLException e)
00145       {
00146         p(e);
00147       }
00148       finally
00149       {
00150         q.close();
00151       }
00152       p("</table>\n");     
00153     }
00154         }

void ReferralList::loadValues  )  [inline]
 

Reimplemented from Widget.

Definition at line 22 of file ReferralList.java.

References ActionButton::action, action, active, ADD, DELETE, ReferralEditor::done, EDIT, editor, Widget::form, Widget::loadAttribute(), ReferralEditor::loadDefaults(), ReferralEditor::loadValues(), Widget::modal, ReferralEditor::more, Widget::n(), ActionButton::param, referrals, Widget::toInt(), and Widget::unserialize().

00023         {
00024     super.loadValues();
00025     
00026     modal = loadAttribute("modal") != null;
00027     
00028     String l = loadAttribute("referrals");
00029     if (l != null) referrals = (Vector) unserialize(l);
00030     
00031     String a = loadAttribute("active");    
00032     
00033     for(;;)
00034     if (modal)
00035     {
00036       if (a != null) active = toInt(a, -1);      
00037       editor = new ReferralEditor(active, referrals, n("editor"), form);
00038       if (a == null) editor.loadDefaults(); else editor.loadValues();        
00039       
00040       if (editor.done)
00041         modal = false;
00042       else if (editor.more)
00043       {
00044         a = null;
00045         active = -1;
00046       }
00047       else
00048          return;
00049     }   
00050     else
00051     {   
00052       switch (action.action)
00053       {
00054         case ADD:
00055           modal = true;
00056           active = -1;
00057         break;
00058         case EDIT:
00059           modal = true;
00060           active = action.param;
00061         break;
00062         case DELETE:
00063           referrals.remove(action.param);
00064           return;
00065         default:
00066           return;
00067       }
00068     }
00069         }


Member Data Documentation

ActionButton ReferralList::action [package]
 

Definition at line 6 of file ReferralList.java.

int ReferralList::active [package]
 

Definition at line 9 of file ReferralList.java.

final int ReferralList::ADD = 1 [static]
 

Definition at line 11 of file ReferralList.java.

final int ReferralList::DELETE = 3 [static]
 

Definition at line 13 of file ReferralList.java.

final int ReferralList::EDIT = 2 [static]
 

Definition at line 12 of file ReferralList.java.

ReferralEditor ReferralList::editor [package]
 

Definition at line 7 of file ReferralList.java.

Vector ReferralList::referrals = new Vector() [package]
 

Definition at line 8 of file ReferralList.java.


The documentation for this class was generated from the following file:
Generated on Mon Mar 6 23:34:35 2006 by  doxygen 1.4.4