Source Code Cross Referenced for EpilepsyMeds.java in  » XML-UI » xui32 » com » xoetrope » medical » forms » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » XML UI » xui32 » com.xoetrope.medical.forms 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:package com.xoetrope.medical.forms;
002:
003:import com.xoetrope.medical.forms.Outcome;
004:import com.xoetrope.swing.table.XAltRowTableCellRenderer;
005:import com.xoetrope.swing.table.XTableHeaderRenderer;
006:import java.awt.Color;
007:import java.awt.event.ActionEvent;
008:import java.awt.event.ActionListener;
009:import java.awt.event.KeyEvent;
010:import java.awt.event.MouseEvent;
011:import javax.swing.JMenuItem;
012:import javax.swing.JPopupMenu;
013:import javax.swing.JOptionPane;
014:import javax.swing.SwingConstants;
015:import javax.swing.table.TableColumn;
016:import javax.swing.table.TableColumnModel;
017:import javax.swing.table.TableCellRenderer;
018:import net.xoetrope.optional.annotation.Find;
019:import net.xoetrope.swing.XButton;
020:import net.xoetrope.swing.XDialog;
021:import net.xoetrope.swing.XTable;
022:import net.xoetrope.swing.table.ColumnGroup;
023:import net.xoetrope.swing.table.GroupableTableHeader;
024:import net.xoetrope.xui.XPage;
025:import net.xoetrope.registry.ComponentCustomizer;
026:import net.xoetrope.xui.data.XBaseModel;
027:
028:/**
029: * A prototype user interface for Epilepsy Medications
030: *
031: * @author luano
032: * <p> Copyright (c) Xoetrope Ltd., 2002-2006, This software is licensed under
033: * the GNU Public License (GPL), please see license.txt for more details</p>
034: */
035:public class EpilepsyMeds extends XPage implements  ActionListener
036:{
037:  public static final int CURRENT_AED_ACTION = 1;
038:  private static final int PRIOR_AED_ACTION = 2;
039:  
040:  @Find
041:  private XTable currentAED, priorAED;  
042:  
043:  @Find
044:  private XButton disCurAedBtn, respCurAedBtn, addExistAedBtn, respPriorAedBtn;
045:
046:  private int id;
047:  
048:  /**
049:   * Creates a new instance of EpilepsyMeds
050:   */
051:  public EpilepsyMeds()
052:  {
053:  }
054:  
055:  public void pageActivated()
056:  { 
057:    // Setup the current AEDs --------------------------------------------------
058:    TableColumnModel columnModel = currentAED.getColumnModel();
059:    TableCellRenderer renderer = columnModel.getColumn( 0 ).getHeaderRenderer();
060:
061:    ColumnGroup dosageGroup = new ColumnGroup( renderer, "Current Dosage Details" );
062:    dosageGroup.add( columnModel.getColumn( 2 ));
063:    dosageGroup.add( columnModel.getColumn( 3 ));
064:    dosageGroup.add( columnModel.getColumn( 4 ));
065:    dosageGroup.add( columnModel.getColumn( 5 ));
066:
067:    GroupableTableHeader header = (GroupableTableHeader)currentAED.getTableHeader();
068:    header.addColumnGroup( dosageGroup );
069:
070:    columnModel.getColumn( 0 ).setMinWidth( 180 );
071:    columnModel.getColumn( 1 ).setMinWidth( 100 );
072:    columnModel.getColumn( 6 ).setMinWidth( 80 );
073:    columnModel.getColumn( 7 ).setMinWidth( 190 );
074:    
075:    currentAED.setSelectedRow( 0 );
076:
077:    // Setup the Prior AEDs ----------------------------------------------------
078:    columnModel = priorAED.getColumnModel();
079:    renderer = columnModel.getColumn( 0 ).getHeaderRenderer();
080:
081:    dosageGroup = new ColumnGroup( renderer, "Dosage Details" );
082:    dosageGroup.add( columnModel.getColumn( 3 ));
083:    dosageGroup.add( columnModel.getColumn( 4 ));
084:    dosageGroup.add( columnModel.getColumn( 5 ));
085:    dosageGroup.add( columnModel.getColumn( 6 ));
086:
087:    header = (GroupableTableHeader)priorAED.getTableHeader();
088:    header.addColumnGroup( dosageGroup );
089:
090:    columnModel.getColumn( 0 ).setMinWidth( 150 );
091:    columnModel.getColumn( 1 ).setMinWidth( 80 );
092:    columnModel.getColumn( 2 ).setMinWidth( 80 );
093:    columnModel.getColumn( 4 ).setMinWidth( 65 );
094:    columnModel.getColumn( 7 ).setMinWidth( 80 );
095:    columnModel.getColumn( 8 ).setMinWidth( 190 );
096:
097:    priorAED.setSelectedRow( 0 );
098:  }
099:    
100://  public void pageActivated()
101://  { 
102://    updateButtonState();
103://  }
104:  
105:  /**
106:   * Reset the button state to match the selection state for the table(s)
107:   */
108:  public void updateButtonState()
109:  {
110:    boolean state = ( currentAED.getSelectedRowCount() > 0 );
111:    disCurAedBtn.setEnabled( state );
112:    respCurAedBtn.setEnabled( state );
113:    addExistAedBtn.setEnabled( state );
114:  }
115:  
116:  /**
117:   * Respond to mouse interaction with the currentAED table
118:   */
119:  public void currentAEDAction()
120:  {
121:    // Enable/disable the buttons
122:    updateButtonState();
123:    
124:    if ( wasMouseDoubleClicked()) {
125:        // View the side-effects
126:        
127:        // if the Outcome column is selected
128:        //if ( currentAED.getSelectedColumn() == 7 )
129:          showCurrentOutcomeDialog();
130:    }
131:    else if ( wasMouseRightClicked() && ( currentAED.getSelectedRowCount() > 0 )) {
132:      JPopupMenu popupMenu = new JPopupMenu();
133:      
134:      JMenuItem mi = new JMenuItem( "Add a side-effect..." );
135:      mi.addActionListener( this  );
136:      popupMenu.add( mi );
137:
138:      mi = new JMenuItem( "Add a responder...", KeyEvent.VK_R );
139:      mi.addActionListener( this  );
140:      popupMenu.add( mi );
141:      
142:      popupMenu.addSeparator();
143:      mi = new JMenuItem( "Discontinue...", KeyEvent.VK_D );
144:      mi.addActionListener( this  );
145:      popupMenu.add( mi );
146:
147:      mi = new JMenuItem( "Delete...", KeyEvent.VK_DELETE );
148:      mi.addActionListener( this  );
149:      popupMenu.add( mi );
150:
151:      popupMenu.addSeparator();
152:      mi = new JMenuItem( "Add an existing medication...", KeyEvent.VK_A );
153:      mi.addActionListener( this  );
154:      popupMenu.add( mi );
155:
156:      mi = new JMenuItem( "Add a new medication...", KeyEvent.VK_N );
157:      mi.addActionListener( this  );
158:      popupMenu.add( mi );
159:      
160:      MouseEvent me = (MouseEvent)getCurrentEvent();
161:      popupMenu.show( currentAED, me.getX(), me.getY());
162:    }
163:  }
164:  
165:  /**
166:   * Respond to mouse interaction with the priorAED table
167:   */
168:  public void priorAEDAction()
169:  {
170:    respPriorAedBtn.setEnabled( priorAED.getSelectedRowCount() > 0 );
171:    
172:    if ( wasMouseDoubleClicked()) {
173:      // View the side-effects
174:      //showMessage( "add", "Response" );
175:
176:      // if the Outcome column is selected
177:      //if ( priorAED.getSelectedColumn () == 8 )
178:        showPriorOutcomeDialog();
179:    }
180:    
181:    if ( wasMouseRightClicked() && ( priorAED.getSelectedRowCount() > 0 )) {
182:      JPopupMenu popupMenu = new JPopupMenu();
183:      
184:      JMenuItem mi = new JMenuItem( "Add a response..." );
185:      mi.addActionListener( this  );
186:      popupMenu.add( mi );
187:
188:      mi = new JMenuItem( "Add a prior medication...", KeyEvent.VK_D );
189:      mi.addActionListener( this  );
190:      popupMenu.add( mi );
191:            
192:      MouseEvent me = (MouseEvent)getCurrentEvent();
193:      popupMenu.show( priorAED, me.getX(), me.getY());
194:    }
195:  }
196:  
197:  /**
198:   * Respond to actions
199:   * @param e the action event
200:   */
201:  public void actionPerformed( ActionEvent e )
202:  {   
203:    String cmd = e.getActionCommand();
204:    if ( cmd.equals( "Add a side-effect..." ))
205:      showCurrentResponseDialog();
206:    else if ( cmd.equals( "Add a responder..." ))
207:      showCurrentResponseDialog();
208:    else if ( cmd.equals( "Discontinue..." ))
209:      showDiscontinueDialog();
210:    else if ( cmd.equals( "Delete..." ))
211:      deleteCurrentAED();
212:    else if ( cmd.equals( "Add an existing medication..." ))
213:      showAddExMedDialog();
214:    else if ( cmd.equals( "Add a new medication..." ))
215:      showAddNewDialog();     
216:    else if ( cmd.equals( "Add a response..." ))
217:      showPriorResponseDialog();
218:    else if ( cmd.equals( "Add a prior medication..." ))
219:      showAddPriorDialog();
220:  } 
221:  //------------------------------------------------------------------------------  
222:  
223:  //------------------------------------------------------------------------------  
224:  public void deleteCurrentAED()
225:  {
226:    int rowIdx = currentAED.getSelectedRow();
227:    int rc = JOptionPane.showConfirmDialog( this , "Are you sure you want to delete this medication?", "Delete CurrentAED", JOptionPane.YES_NO_OPTION );
228:    if ( rc == JOptionPane.YES_OPTION ) {
229:      XBaseModel currentAEDModel = (XBaseModel)rootModel.get ( "currentAED" );
230:      XBaseModel currentMed = (XBaseModel)currentAEDModel.get( rowIdx + 1 );
231:      currentAEDModel.remove( currentMed );
232:      currentAED.update();
233:      currentAED.updateTable();
234:
235:      // obtain reference to priorAED table 
236:      XBaseModel priorAEDModel = (XBaseModel)rootModel.get ( "priorAED" );
237:      
238:      // add new node to the priorAED table
239:      XBaseModel newRow = (XBaseModel)priorAEDModel.get("newNode" + id++ );
240:      newRow.setAttribValue (XBaseModel.VALUE_ATTRIBUTE, ("newNode" + id));    
241:
242:      // add values to appropriate columns in table
243:      newRow.set("1", getDeletedText( ((XBaseModel)currentMed.get( "1" )).get().toString()));
244:      newRow.set("2", getDeletedText( ((XBaseModel)currentMed.get( "2" )).get().toString()));
245:      newRow.set("3", getDeletedText( ((XBaseModel)currentMed.get( "3" )).get().toString()));
246:      newRow.set("4", getDeletedText( ((XBaseModel)currentMed.get( "4" )).get().toString()));
247:      newRow.set("5", getDeletedText( ((XBaseModel)currentMed.get( "5" )).get().toString()));
248:      newRow.set("6", getDeletedText( ((XBaseModel)currentMed.get( "6" )).get().toString()));
249:      newRow.set("7", getDeletedText( ((XBaseModel)currentMed.get( "7" )).get().toString()));
250:      newRow.set("8", getDeletedText( ((XBaseModel)currentMed.get( "8" )).get().toString()));
251:      newRow.set("9", getDeletedText( "Deleted" ));
252:      
253:      priorAED.update();
254:    }
255:  }
256:  
257:  private String getDeletedText( String t )
258:  {
259:    if ( t.indexOf( "<html>" ) > 0 )
260:      return "<html><strike>" + t.substring( 6, t.length() - 6 ) + "</strike></html>";
261:    else      
262:      return "<html><strike>" + t + "</strike></html>";
263:  }
264:  
265:  // These calls could be placed in the XML, but it is clearer here as the constants
266:  // make the usage more obvious
267:  public void showDiscontinueDialog()
268:  {
269:    showDialog( "Discontinue", "Current AED Medication", CURRENT_AED_ACTION, 0 );     
270:  }  
271:  
272:  public void showAddExMedDialog()
273:  {
274:    showDialog( "AddMedication", "Current AED Medication", CURRENT_AED_ACTION, AddMedication.ADD_EXISTING_MEDICATION );     
275:  } 
276:  
277:  public void showAddNewDialog()
278:  {
279:    showDialog( "AddMedication", "Current AED Medication", CURRENT_AED_ACTION, AddMedication.ADD_NEW_MEDICATION );
280:  }
281:  
282:  public void showAddPriorDialog()
283:  {
284:    showDialog( "AddPrior", "Prior AED Medication", PRIOR_AED_ACTION, 0 );
285:  }
286:  
287:  public void showCurrentOutcomeDialog()   
288:  {
289:    showDialog( "Outcome", "Current AED Medication", CURRENT_AED_ACTION, Outcome.CURRENT_OUTCOME ); 
290:  }  
291:  
292:  public void showPriorOutcomeDialog()  
293:  {
294:    showDialog( "Outcome", "Prior AED Medication", PRIOR_AED_ACTION, Outcome.PRIOR_OUTCOME );
295:  }
296:  
297:  public void showCurrentResponseDialog()   
298:  {
299:    showDialog( "Outcome", "Current AED Medication", CURRENT_AED_ACTION, Outcome.CURRENT_RESPONSE );   
300:  } 
301:  
302:  public void showPriorResponseDialog() 
303:  {
304:    showDialog( "Outcome", "Prior AED Medication", PRIOR_AED_ACTION, Outcome.PRIOR_RESPONSE );
305:  } 
306:  //------------------------------------------------------------------------------  
307:  
308:  public void showDialog( String page, String title, int context, int type )
309:  {   
310:    // Record the selected medication
311:    setSelectedRow( ( context == CURRENT_AED_ACTION ) ? currentAED : priorAED );
312:
313:    // Add an integer to the root model which is later used by the dialogs
314:    // do determine the context and then self configure
315:    rootModel.set( "dlgType", type );
316:    
317:    XDialog dlg = (XDialog)pageMgr.loadPage( page );
318:    dlg.pack();
319:    dlg.showDialog( this , title, null ); 
320:    
321:    // When the dialog is dismissed update the button state to reflect the selections
322:    updateButtonState();
323:  } 
324:  
325:  /**
326:   * Save the row selection
327:   */
328:  private void setSelectedRow( XTable table )
329:  {
330:    rootModel.set( "selectedAedRow", new Integer( table.getSelectedRow()));
331:  }
332:}
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.