1 19 20 package org.netbeans.modules.tasklist.timerwin; 21 22 import java.awt.Component ; 23 import javax.swing.DefaultListCellRenderer ; 24 import javax.swing.ImageIcon ; 25 import javax.swing.JList ; 26 import org.netbeans.modules.tasklist.usertasks.Settings; 27 import org.netbeans.modules.tasklist.usertasks.model.Duration; 28 import org.netbeans.modules.tasklist.usertasks.model.UserTask; 29 import org.netbeans.modules.tasklist.usertasks.renderers.UserTaskIconProvider; 30 import org.openide.util.NbBundle; 31 32 37 public class UserTaskListCellRenderer extends DefaultListCellRenderer { 38 private static final String NONE = NbBundle.getMessage( 39 UserTaskListCellRenderer.class, "None"); 41 private ImageIcon icon = new ImageIcon (); 42 43 46 public UserTaskListCellRenderer() { 47 } 48 49 public Component getListCellRendererComponent( 50 JList list, 51 Object value, 52 int index, 53 boolean isSelected, 54 boolean cellHasFocus) 55 { 56 super.getListCellRendererComponent(list, value, index, isSelected, 57 cellHasFocus); 58 if (value == null) { 59 setText(NONE); 60 setIcon(null); 61 } else { 62 UserTask ut = (UserTask) value; 63 Settings set = Settings.getDefault(); 64 Duration d = new Duration(ut.getSpentTime(), set.getHoursPerDay(), 65 set.getDaysPerWeek()); 66 setText("[" + d.format() + "] " + ut.getSummary()); 67 icon.setImage(UserTaskIconProvider.getUserTaskImage( 68 (UserTask) value, false)); 69 setIcon(icon); 70 } 71 return this; 72 } 73 } 74 | Popular Tags |