View Javadoc
1   /**
2    * The contents of this file are subject to the Mozilla Public License Version 1.1
3    * (the "License"); you may not use this file except in compliance with the License.
4    * You may obtain a copy of the License at http://www.mozilla.org/MPL/
5    * Software distributed under the License is distributed on an "AS IS" basis,
6    * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the
7    * specific language governing rights and limitations under the License.
8    *
9    * The Original Code is ""  Description:
10   * ""
11   *
12   * The Initial Developer of the Original Code is University Health Network. Copyright (C)
13   * 2001.  All Rights Reserved.
14   *
15   * Contributor(s): ______________________________________.
16   *
17   * Alternatively, the contents of this file may be used under the terms of the
18   * GNU General Public License (the  "GPL"), in which case the provisions of the GPL are
19   * applicable instead of those above.  If you wish to allow use of your version of this
20   * file only under the terms of the GPL and not to allow others to use your version
21   * of this file under the MPL, indicate your decision by deleting  the provisions above
22   * and replace  them with the notice and other provisions required by the GPL License.
23   * If you do not delete the provisions above, a recipient may use your version of
24   * this file under either the MPL or the GPL.
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  //		myContainerPanel.add(this, BorderLayout.WEST);
64  //		
65  //		myActionsLabel = new JLabel("Actions ");
66  //		myActionsLabel.setForeground(Color.blue);
67  //		
68  //		myContainerPanel.add(myActionsLabel, BorderLayout.EAST);
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  //		boolean actionLabelVisible = false;
77  		
78  		if (obj instanceof ActivityIncomingMessage) {
79  			setText(myIncomingDescription);
80  			setIcon(ImageFactory.getMessageIn());
81  //			actionLabelVisible = true;
82  		} else if (obj instanceof ActivityOutgoingMessage) {
83  			setText(myOutgoingDescription);
84  			setIcon(ImageFactory.getMessageOut());
85  //			actionLabelVisible = true;
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 //			setIcon(null);
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 //		myActionsLabel.setVisible(actionLabelVisible);
112 //		myContainerPanel.setBackground(this.getBackground());
113 //		
114 //		return myContainerPanel;
115 
116 		return this;
117 	}
118 
119 }