1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  package ca.uhn.hl7v2.testpanel.ui;
27  
28  import java.awt.Component;
29  
30  import javax.swing.JTable;
31  
32  import ca.uhn.hl7v2.testpanel.model.ActivityBase;
33  import ca.uhn.hl7v2.testpanel.model.ActivityIncomingBytes;
34  import ca.uhn.hl7v2.testpanel.model.ActivityIncomingMessage;
35  import ca.uhn.hl7v2.testpanel.model.ActivityInfo;
36  import ca.uhn.hl7v2.testpanel.model.ActivityInfoError;
37  import ca.uhn.hl7v2.testpanel.model.ActivityOutgoingBytes;
38  import ca.uhn.hl7v2.testpanel.model.ActivityOutgoingMessage;
39  import ca.uhn.hl7v2.testpanel.model.ActivityValidationOutcome;
40  
41  public class ActivityTypeCellRenderer extends ActivityCellRendererBase {
42  
43  	private String myOutgoingDescription;
44  	private String myIncomingDescription;
45  	private String myOutgoingBytesDescription;
46  	private String myIncomingBytesDescription;
47  
48  	public ActivityTypeCellRenderer(ActivityTable theTablePanel, boolean theForIncomingInterface) {
49  		super(theTablePanel);
50  		
51  		if (theForIncomingInterface) {
52  			myIncomingDescription = "Incoming";
53  			myOutgoingDescription = "Response";
54  			myIncomingBytesDescription = "Incoming Bytes";
55  			myOutgoingBytesDescription = "Response Bytes";
56  		} else {
57  			myIncomingDescription = "Response";
58  			myOutgoingDescription = "Outgoing";
59  			myIncomingBytesDescription = "Response Bytes";
60  			myOutgoingBytesDescription = "Outgoing Bytes";
61  		}
62  		
63  
64  
65  
66  
67  
68  
69  	}
70  
71  	@Override
72  	public Component getTableCellRendererComponent(JTable theTable, Object theValue, boolean theIsSelected, boolean theHasFocus, int theRow, int theColumn) {
73  		super.getTableCellRendererComponent(theTable, theValue, theIsSelected, theHasFocus, theRow, theColumn);
74  
75  		ActivityBase obj = (ActivityBase) theValue;
76  
77  		
78  		if (obj instanceof ActivityIncomingMessage) {
79  			setText(myIncomingDescription);
80  			setIcon(ImageFactory.getMessageIn());
81  
82  		} else if (obj instanceof ActivityOutgoingMessage) {
83  			setText(myOutgoingDescription);
84  			setIcon(ImageFactory.getMessageOut());
85  
86  		} else if (obj instanceof ActivityIncomingBytes) {
87  			setText(myIncomingBytesDescription);
88  			setIcon(ImageFactory.getMessageIn());
89  		} else if (obj instanceof ActivityOutgoingBytes) {
90  			setText(myOutgoingBytesDescription);
91  			setIcon(ImageFactory.getMessageOut());
92  		} else if (obj instanceof ActivityValidationOutcome) {
93  			ActivityValidationOutcome v = (ActivityValidationOutcome)obj;
94  			if (v.isValidated()) {
95  				setIcon(ImageFactory.getValPassedGreen());
96  			} else {
97  				setIcon(ImageFactory.getValFailed());
98  			}
99  			setText("Validation");
100 
101 		} else if (obj instanceof ActivityInfoError) {
102 			setText("Error");
103 			setIcon(null);
104 		} else if (obj instanceof ActivityInfo) {
105 			setText("Info");
106 			setIcon(null);
107 		} else {
108 			setIcon(null);
109 		}
110 
111 
112 
113 
114 
115 
116 		return this;
117 	}
118 
119 }