View Javadoc
1 /*** 2 * $Header: 3 */ 4 package com.sun.xml.registry.client.browser; 5 6 import java.util.*; 7 import java.awt.*; 8 import java.awt.event.*; 9 import javax.swing.*; 10 import javax.swing.table.*; 11 import javax.swing.tree.*; 12 import javax.xml.registry.*; 13 import javax.xml.registry.infomodel.*; 14 15 /*** 16 * @author <a href="mailto:nikola.stojanovic@acm.org">Nikola Stojanovic</a> 17 */ 18 19 public class AuditableEventsTableModel extends AbstractTableModel { 20 21 String[] columnNames = {"Event Type", "Timestamp", "User"}; 22 ArrayList auditableEvents = new ArrayList(); 23 RegistryBrowser registryBrowser; 24 25 26 public AuditableEventsTableModel() { 27 28 registryBrowser = RegistryBrowser.getInstance(); 29 } 30 31 32 public int getColumnCount() { 33 34 return columnNames.length; 35 } 36 37 38 public int getRowCount() { 39 40 return auditableEvents.size(); 41 } 42 43 44 public AuditableEvent getObjectAt(int row) { 45 46 AuditableEvent ae = (AuditableEvent) auditableEvents.get(row); 47 return ae; 48 } 49 50 51 public Object getValueAt(int row, int col) { 52 53 AuditableEvent auditableEvent = (AuditableEvent) auditableEvents.get(row); 54 Object value = null; 55 InternationalString iString = null; 56 57 try { 58 switch (col) { 59 case 0: 60 value = RegistryBrowser.getEventTypeAsString(auditableEvent.getEventType()); 61 break; 62 case 1: 63 value = (auditableEvent.getTimestamp()).toString(); 64 break; 65 case 2: 66 User user = null; 67 try { 68 user = auditableEvent.getUser(); 69 } 70 catch (JAXRException e) { 71 //User may have been deleted. Handle gracefully 72 } 73 74 if (user != null) { 75 value = RegistryBrowser.getUserName(auditableEvent.getUser(), 1); 76 } 77 else { 78 com.sun.xml.registry.ebxml.infomodel.RegistryObjectRef userRef = 79 ((com.sun.xml.registry.ebxml.infomodel.AuditableEventImpl)auditableEvent).getUserRef(); 80 value = userRef.getId(); 81 } 82 break; 83 } 84 } 85 catch (JAXRException e) { 86 RegistryBrowser.displayError(e); 87 } 88 return value; 89 } 90 91 92 public String getColumnName(int col) { 93 94 return columnNames[col].toString(); 95 } 96 97 98 void update(Collection auditableEvents) { 99 100 if (auditableEvents.isEmpty()) { 101 JOptionPane.showMessageDialog(null, "No Audit Trail found.", 102 "Registry Browser", 103 JOptionPane.INFORMATION_MESSAGE); 104 auditableEvents = new ArrayList(); 105 } 106 setAuditableEvents(auditableEvents); 107 } 108 109 110 ArrayList getAuditableEvents() { 111 112 return auditableEvents; 113 } 114 115 116 void setAuditableEvents(Collection objects) { 117 auditableEvents.clear(); 118 auditableEvents.addAll(objects); 119 fireTableDataChanged(); 120 } 121 }

This page was automatically generated by Maven