EMMA Coverage Report (generated Sun Apr 20 22:38:01 CEST 2008)
[all classes][net.sf.jomic.ui]

COVERAGE SUMMARY FOR SOURCE FILE [FileArchiveListCellRenderer.java]

nameclass, %method, %block, %line, %
FileArchiveListCellRenderer.java100% (1/1)100% (3/3)77%  (86/111)85%  (18.6/22)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class FileArchiveListCellRenderer100% (1/1)100% (3/3)77%  (86/111)85%  (18.6/22)
getListCellRendererComponent (JList, Object, int, boolean, boolean): Component 100% (1/1)76%  (53/70)79%  (11/14)
<static initializer> 100% (1/1)80%  (12/15)80%  (0.8/1)
FileArchiveListCellRenderer (): void 100% (1/1)81%  (21/26)97%  (6.8/7)

1// Jomic - a viewer for comic book archives.
2// Copyright (C) 2004-2008 Thomas Aglassinger
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program.  If not, see <http://www.gnu.org/licenses/>.
16package net.sf.jomic.ui;
17 
18import java.awt.Component;
19 
20import javax.swing.JLabel;
21import javax.swing.JList;
22import javax.swing.ListCellRenderer;
23 
24import net.sf.jomic.tools.FileTools;
25import net.sf.wraplog.Logger;
26 
27/**
28 *  ListCellRenderer to show non-comics as disabled.
29 *
30 * @author    Thomas Aglassinger
31 */
32public class FileArchiveListCellRenderer extends JLabel implements ListCellRenderer
33{
34    private FileTools fileTools;
35    private Logger logger;
36 
37    public FileArchiveListCellRenderer() {
38        logger = Logger.getLogger(FileArchiveListCellRenderer.class);
39        fileTools = FileTools.instance();
40 
41        setOpaque(true);
42        setHorizontalAlignment(LEFT);
43        setVerticalAlignment(CENTER);
44    }
45 
46    public Component getListCellRendererComponent(
47            JList list,
48            Object value,
49            int index,
50            boolean isSelected,
51            boolean cellHasFocus) {
52        assert list != null;
53        assert value != null;
54 
55        if (isSelected) {
56            setBackground(list.getSelectionBackground());
57            setForeground(list.getSelectionForeground());
58        } else {
59            setBackground(list.getBackground());
60            setForeground(list.getForeground());
61        }
62 
63        String fileName = value.toString();
64 
65        setText(fileName);
66 
67        boolean enabled = fileTools.isComic(fileName);
68 
69        if (logger.isDebugEnabled()) {
70            logger.debug("enabled = " + enabled + " <- " + fileName);
71        }
72        setEnabled(enabled);
73 
74        return this;
75    }
76}

[all classes][net.sf.jomic.ui]
EMMA 2.0.4217 (C) Vladimir Roubtsov