View Javadoc

1   package ca.uhn.hl7v2.testpanel.ui.conf;
2   
3   import java.awt.Color;
4   import java.awt.Component;
5   
6   import javax.swing.JTable;
7   import javax.swing.border.LineBorder;
8   import javax.swing.table.DefaultTableCellRenderer;
9   import javax.swing.tree.DefaultMutableTreeNode;
10  
11  import ca.uhn.hl7v2.testpanel.ui.ImageFactory;
12  import ca.uhn.hl7v2.testpanel.ui.conf.ConformanceEditorPanel.ProfileNode;
13  
14  public class ProfilesTreeRenderer extends DefaultTableCellRenderer {
15  
16  	private ConformanceEditorPanel myPanel;
17  
18  	public ProfilesTreeRenderer(ConformanceEditorPanel thePanel) {
19  		myPanel = thePanel;
20  	}
21  
22  	/*
23  	 * (non-Javadoc)
24  	 * 
25  	 * @see
26  	 * javax.swing.table.DefaultTableCellRenderer#getTableCellRendererComponent
27  	 * (javax.swing.JTable, java.lang.Object, boolean, boolean, int, int)
28  	 */
29  	@Override
30  	public Component getTableCellRendererComponent(JTable theTable, Object theValue, boolean theIsSelected, boolean theHasFocus, int theRow, int theColumn) {
31  		Component retVal = super.getTableCellRendererComponent(theTable, theValue, theIsSelected, theHasFocus, theRow, theColumn);
32  
33  		DefaultMutableTreeNode node = myPanel.getNodeForRow(theRow);
34  		if (node instanceof ProfileNode) {
35  
36  			if (theColumn == ConformanceEditorPanel.MyProfilesRowModel.COL_TABLES + 1) {
37  				if (theValue != null) {
38  					setIcon(ImageFactory.getTable());
39  				} else {
40  					setText("None");
41  					setIcon(ImageFactory.getNo());
42  				}
43  			} else {
44  				setIcon(null);
45  			}
46  			setBorder(new LineBorder(Color.lightGray, 1, true));
47  			
48  		} else {
49  			
50  			setIcon(null);
51  			setBorder(null);
52  			
53  		}
54  		
55  		
56  		return this;
57  	}
58  
59  }