Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
NoteComboRenderer |
|
| 2.0;2 |
1 | package org.jtheque.primary.view.impl.renderers; | |
2 | ||
3 | /* | |
4 | * This file is part of JTheque. | |
5 | * | |
6 | * JTheque is free software: you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation, either version 3 of the License. | |
9 | * | |
10 | * JTheque is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with JTheque. If not, see <http://www.gnu.org/licenses/>. | |
17 | */ | |
18 | ||
19 | import org.jdesktop.swingx.JXImagePanel; | |
20 | import org.jtheque.core.managers.Managers; | |
21 | import org.jtheque.core.managers.resource.IResourceManager; | |
22 | import org.jtheque.core.utils.db.DaoNotes; | |
23 | import org.jtheque.core.utils.db.Note; | |
24 | import org.jtheque.core.utils.ui.Borders; | |
25 | ||
26 | import javax.swing.BorderFactory; | |
27 | import javax.swing.JList; | |
28 | import javax.swing.ListCellRenderer; | |
29 | import java.awt.Component; | |
30 | ||
31 | /** | |
32 | * A combo box renderer to display star(s) depending on the note. | |
33 | * | |
34 | * @author Baptiste Wicht | |
35 | */ | |
36 | public final class NoteComboRenderer extends JXImagePanel implements ListCellRenderer { | |
37 | /** | |
38 | * Construct a new <code>NoteComboRenderer</code>. | |
39 | */ | |
40 | public NoteComboRenderer(){ | |
41 | 0 | super(); |
42 | ||
43 | 0 | setOpaque(false); |
44 | 0 | } |
45 | ||
46 | @Override | |
47 | public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus){ | |
48 | 0 | if (value != null){ |
49 | 0 | setImage(DaoNotes.getImage((Note) value)); |
50 | } | |
51 | ||
52 | 0 | if (isSelected){ |
53 | 0 | setBorder(BorderFactory.createLineBorder(Managers.getManager(IResourceManager.class).getColor("filthyInputBorderColor"), 2)); |
54 | } else { | |
55 | 0 | setBorder(Borders.EMPTY_BORDER); |
56 | } | |
57 | ||
58 | 0 | return this; |
59 | } | |
60 | } |