Mercurial > repos > timpalpant > java_genomics_toolkit
comparison gui/edu/unc/genomics/JobQueueCellRenderer.java @ 2:e16016635b2a
Uploaded
| author | timpalpant |
|---|---|
| date | Mon, 13 Feb 2012 22:12:06 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:a54db233ee3d | 2:e16016635b2a |
|---|---|
| 1 package edu.unc.genomics; | |
| 2 | |
| 3 import java.awt.Color; | |
| 4 import java.awt.Component; | |
| 5 import java.awt.Dimension; | |
| 6 import java.awt.FlowLayout; | |
| 7 import java.awt.Font; | |
| 8 import java.awt.event.ActionEvent; | |
| 9 import java.awt.event.ActionListener; | |
| 10 | |
| 11 import javax.swing.BorderFactory; | |
| 12 import javax.swing.Box; | |
| 13 import javax.swing.BoxLayout; | |
| 14 import javax.swing.ImageIcon; | |
| 15 import javax.swing.JButton; | |
| 16 import javax.swing.JLabel; | |
| 17 import javax.swing.JList; | |
| 18 import javax.swing.JPanel; | |
| 19 import javax.swing.JProgressBar; | |
| 20 import javax.swing.ListCellRenderer; | |
| 21 import javax.swing.SwingConstants; | |
| 22 import javax.swing.border.EtchedBorder; | |
| 23 | |
| 24 /** | |
| 25 * @author timpalpant | |
| 26 * | |
| 27 */ | |
| 28 public class JobQueueCellRenderer extends JPanel implements ListCellRenderer<SubmittedJob> { | |
| 29 | |
| 30 private static final long serialVersionUID = 4270263302075586018L; | |
| 31 | |
| 32 private static final ImageIcon inProgressIcon = new ImageIcon(ResourceManager.getImagesDirectory().resolve("beachball.png").toString()); | |
| 33 private static final ImageIcon rerunIcon = new ImageIcon(ResourceManager.getImagesDirectory().resolve("arrow-circle.png").toString()); | |
| 34 private static final ImageIcon infoIcon = new ImageIcon(ResourceManager.getImagesDirectory().resolve("information-white.png").toString()); | |
| 35 private static final ImageIcon logIcon = new ImageIcon(ResourceManager.getImagesDirectory().resolve("sticky-note-text.png").toString()); | |
| 36 private static final ImageIcon showFileIcon = new ImageIcon(ResourceManager.getImagesDirectory().resolve("eye_icon.png").toString()); | |
| 37 | |
| 38 private static final ImageIcon successIcon = new ImageIcon(ResourceManager.getImagesDirectory().resolve("icon_success_sml.gif").toString()); | |
| 39 private static final ImageIcon errorIcon = new ImageIcon(ResourceManager.getImagesDirectory().resolve("icon_error_sml.gif").toString()); | |
| 40 private static final ImageIcon warningIcon = new ImageIcon(ResourceManager.getImagesDirectory().resolve("icon_warning_sml.gif").toString()); | |
| 41 | |
| 42 private JLabel statusIconLabel = new JLabel(inProgressIcon); | |
| 43 private JLabel nameLabel = new JLabel(); | |
| 44 | |
| 45 public JobQueueCellRenderer() { | |
| 46 FlowLayout flowLayout = new FlowLayout(FlowLayout.LEADING, 5, 2); | |
| 47 setPreferredSize(new Dimension(190, 48)); | |
| 48 setLayout(flowLayout); | |
| 49 setBorder(BorderFactory.createLineBorder(Color.GRAY, 1, true)); | |
| 50 | |
| 51 JPanel statusPanel = new JPanel(); | |
| 52 statusPanel.setBorder(BorderFactory.createEmptyBorder(0, 3, 16, 0)); | |
| 53 statusPanel.setLayout(new BoxLayout(statusPanel, BoxLayout.PAGE_AXIS)); | |
| 54 statusPanel.add(statusIconLabel); | |
| 55 add(statusPanel); | |
| 56 | |
| 57 JPanel mainPanel = new JPanel(); | |
| 58 mainPanel.setAlignmentX(LEFT_ALIGNMENT); | |
| 59 mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.PAGE_AXIS)); | |
| 60 | |
| 61 JPanel namePanel = new JPanel(); | |
| 62 namePanel.setLayout(flowLayout); | |
| 63 nameLabel.setPreferredSize(new Dimension(145, 16)); | |
| 64 nameLabel.setHorizontalTextPosition(SwingConstants.LEFT); | |
| 65 nameLabel.setFont(nameLabel.getFont().deriveFont(Font.BOLD)); | |
| 66 namePanel.add(nameLabel); | |
| 67 mainPanel.add(namePanel); | |
| 68 | |
| 69 JPanel buttonsPanel = new JPanel(); | |
| 70 buttonsPanel.setLayout(flowLayout); | |
| 71 mainPanel.add(buttonsPanel); | |
| 72 | |
| 73 ButtonLabel rerunLabel = new ButtonLabel(rerunIcon); | |
| 74 rerunLabel.addActionListener(new ActionListener() { | |
| 75 public void actionPerformed(ActionEvent e) { | |
| 76 //addJobToQueue(); | |
| 77 } | |
| 78 }); | |
| 79 buttonsPanel.add(rerunLabel); | |
| 80 ButtonLabel infoLabel = new ButtonLabel(infoIcon); | |
| 81 infoLabel.addActionListener(new ActionListener() { | |
| 82 public void actionPerformed(ActionEvent e) { | |
| 83 //addJobToQueue(); | |
| 84 } | |
| 85 }); | |
| 86 buttonsPanel.add(infoLabel); | |
| 87 ButtonLabel logLabel = new ButtonLabel(logIcon); | |
| 88 logLabel.addActionListener(new ActionListener() { | |
| 89 public void actionPerformed(ActionEvent e) { | |
| 90 //addJobToQueue(); | |
| 91 } | |
| 92 }); | |
| 93 buttonsPanel.add(logLabel); | |
| 94 ButtonLabel showFileLabel = new ButtonLabel(showFileIcon); | |
| 95 showFileLabel.addActionListener(new ActionListener() { | |
| 96 public void actionPerformed(ActionEvent e) { | |
| 97 //addJobToQueue(); | |
| 98 } | |
| 99 }); | |
| 100 buttonsPanel.add(showFileLabel); | |
| 101 | |
| 102 add(mainPanel); | |
| 103 } | |
| 104 | |
| 105 @Override | |
| 106 public Component getListCellRendererComponent( | |
| 107 JList<? extends SubmittedJob> list, SubmittedJob value, int index, | |
| 108 boolean isSelected, boolean cellHasFocus) { | |
| 109 | |
| 110 nameLabel.setText(value.toString()); | |
| 111 if (value.isRunning()) { | |
| 112 statusIconLabel.setIcon(inProgressIcon); | |
| 113 nameLabel.setForeground(Color.BLACK); | |
| 114 } else if (value.succeeded()) { | |
| 115 statusIconLabel.setIcon(successIcon); | |
| 116 nameLabel.setForeground(Color.BLACK); | |
| 117 } else { | |
| 118 statusIconLabel.setIcon(errorIcon); | |
| 119 nameLabel.setForeground(Color.RED); | |
| 120 } | |
| 121 | |
| 122 return this; | |
| 123 } | |
| 124 | |
| 125 } |
