1 19 20 package org.netbeans.modules.tasklist.usertasks.renderers; 21 22 import org.netbeans.modules.tasklist.core.PriorityListCellRenderer; 23 import java.awt.Component ; 24 import java.awt.Image ; 25 import javax.swing.*; 26 import javax.swing.table.DefaultTableCellRenderer ; 27 import org.netbeans.modules.tasklist.usertasks.model.UserTask; 28 import org.openide.util.Utilities; 29 30 35 public final class PriorityTableCellRenderer extends DefaultTableCellRenderer { 36 private static final Image LOW = Utilities.loadImage( 37 "org/netbeans/modules/tasklist/usertasks/renderers/low.gif"); private static final Image MEDIUM_LOW = Utilities.loadImage( 39 "org/netbeans/modules/tasklist/usertasks/renderers/medium-low.gif"); private static final Image HIGH = Utilities.loadImage( 41 "org/netbeans/modules/tasklist/usertasks/renderers/high.gif"); private static final Image MEDIUM_HIGH = Utilities.loadImage( 43 "org/netbeans/modules/tasklist/usertasks/renderers/medium-high.gif"); private static final Image MEDIUM = Utilities.loadImage( 45 "org/netbeans/modules/tasklist/usertasks/renderers/empty.gif"); 47 private static final long serialVersionUID = 1; 48 49 private ImageIcon icon = new ImageIcon(); 50 51 public Component getTableCellRendererComponent(JTable table, Object value, 52 boolean isSelected, boolean cellHasFocus, int row, int col) { 53 super.getTableCellRendererComponent(table, value, isSelected, 54 cellHasFocus, row, col); 55 if (value != null) { 56 int prio = ((Integer ) value).intValue(); 57 setText(UserTask.getPriorityNames()[prio - 1]); 58 if (!isSelected) { 59 setForeground(PriorityListCellRenderer.COLORS[prio - 1]); 60 } 61 62 Image im; 63 switch (prio) { 64 case UserTask.HIGH: 65 im = HIGH; 66 break; 67 case UserTask.LOW: 68 im = LOW; 69 break; 70 case UserTask.MEDIUM_HIGH: 71 im = MEDIUM_HIGH; 72 break; 73 case UserTask.MEDIUM_LOW: 74 im = MEDIUM_LOW; 75 break; 76 default: 77 im = MEDIUM; 78 } 79 icon.setImage(im); 80 setIcon(icon); 81 } else { 82 icon.setImage(MEDIUM); 83 setIcon(icon); 84 } 85 return this; 86 } 87 88 @Override 90 protected void setValue(Object arg0) { 91 } 92 } 93 | Popular Tags |