1 7 8 package org.gjt.jclasslib.browser.detail.attributes; 9 10 import org.gjt.jclasslib.browser.AbstractDetailPane; 11 import org.gjt.jclasslib.browser.detail.ListDetailPane; 12 import org.gjt.jclasslib.util.ExtendedTableCellRenderer; 13 14 import javax.swing.*; 15 import javax.swing.table.TableCellRenderer ; 16 import java.awt.*; 17 18 24 public class LinkRenderer implements TableCellRenderer { 25 26 private ExtendedTableCellRenderer linkLineRenderer; 27 private ExtendedTableCellRenderer infoLineRenderer; 28 private Color standardForeground; 29 private JPanel panel; 30 31 34 public LinkRenderer() { 35 36 linkLineRenderer = new ExtendedTableCellRenderer(); 37 linkLineRenderer.setVerticalAlignment(JLabel.TOP); 38 infoLineRenderer = new ExtendedTableCellRenderer(); 39 40 standardForeground = linkLineRenderer.getForeground(); 41 42 panel = new JPanel(new BorderLayout()); 43 panel.add(linkLineRenderer, BorderLayout.NORTH); 44 panel.add(infoLineRenderer, BorderLayout.SOUTH); 45 } 46 47 public Component getTableCellRendererComponent(JTable table, 48 Object value, 49 boolean isSelected, 50 boolean hasFocus, 51 int row, 52 int column) 53 { 54 55 boolean standardLabel = value.toString().equals(ListDetailPane.CPINFO_LINK_TEXT + "0"); 56 linkLineRenderer.setForeground(standardLabel ? standardForeground : AbstractDetailPane.COLOR_LINK); 57 linkLineRenderer.setUnderlined(!standardLabel); 58 linkLineRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); 59 60 if (value instanceof LinkCommentValue) { 61 infoLineRenderer.getTableCellRendererComponent(table, ((LinkCommentValue)value).commentValue, isSelected, false, row, column); 62 panel.setBorder(linkLineRenderer.getBorder()); 63 linkLineRenderer.setBorder(infoLineRenderer.getBorder()); 64 infoLineRenderer.setVisible(true); 65 } else { 66 infoLineRenderer.setVisible(false); 67 } 68 69 panel.setBackground(linkLineRenderer.getBackground()); 70 71 return panel; 72 } 73 74 77 public static class LinkCommentValue { 78 79 private String linkValue; 80 private String commentValue; 81 82 87 public LinkCommentValue(String linkValue, String commentValue) { 88 this.linkValue = linkValue; 89 this.commentValue = commentValue; 90 } 91 92 public String toString() { 93 return linkValue; 94 } 95 } 96 97 } 98 | Popular Tags |