1 19 20 package org.netbeans.modules.tasklist.usertasks.renderers; 21 22 import java.awt.Component ; 23 import java.awt.Font ; 24 25 import javax.swing.ImageIcon ; 26 import javax.swing.JTree ; 27 import javax.swing.tree.DefaultTreeCellRenderer ; 28 import org.netbeans.modules.tasklist.usertasks.model.UserTask; 29 import org.netbeans.modules.tasklist.usertasks.UserTaskListTreeTableNode; 30 import org.netbeans.modules.tasklist.usertasks.UserTaskTreeTableNode; 31 32 import org.openide.util.NbBundle; 33 34 37 public class SummaryTreeCellRenderer extends DefaultTreeCellRenderer { 38 private static final long serialVersionUID = 1; 39 40 private Font boldFont, normalFont; 41 private ImageIcon icon = new ImageIcon (); 42 43 public SummaryTreeCellRenderer() { 44 ImageIcon icon = new ImageIcon (); 45 46 setLeafIcon(icon); 48 setOpenIcon(icon); 49 setClosedIcon(icon); 50 } 51 52 public Component getTreeCellRendererComponent(JTree tree, Object value, 53 boolean selected, boolean expanded, 54 boolean leaf, int row, boolean hasFocus) { 55 super.getTreeCellRendererComponent(tree, value, selected, expanded, 56 leaf, row, hasFocus); 57 if (normalFont == null || !normalFont.equals(tree.getFont())) { 58 normalFont = tree.getFont(); 59 boldFont = normalFont.deriveFont(Font.BOLD); 60 } 61 if (value instanceof UserTaskTreeTableNode) { 62 UserTaskTreeTableNode utl = (UserTaskTreeTableNode) value; 63 UserTask ut = utl.getUserTask(); 64 setFont(ut.isStarted() ? boldFont : normalFont); 65 setText(ut.getSummary()); 66 icon.setImage(UserTaskIconProvider.getUserTaskImage(ut, utl.isUnmatched())); 67 } 68 setIcon(icon); 69 return this; 70 } 71 } 72 | Popular Tags |