Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.installer / org.gvsig.installer.swing / org.gvsig.installer.swing.impl / src / main / java / org / gvsig / installer / swing / impl / execution / panel / renderers / OfficialRecommendedCellRenderer.java @ 40560

History | View | Annotate | Download (3.29 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.installer.swing.impl.execution.panel.renderers;
25

    
26
import java.awt.Component;
27
import java.net.URL;
28

    
29
import javax.swing.Icon;
30
import javax.swing.ImageIcon;
31
import javax.swing.JLabel;
32
import javax.swing.JTable;
33
import javax.swing.table.DefaultTableCellRenderer;
34

    
35
import org.gvsig.installer.swing.api.SwingInstallerLocator;
36
import org.gvsig.installer.swing.impl.DefaultSwingInstallerManager;
37
import org.gvsig.installer.swing.impl.execution.panel.model.PackagesTableModel.PackageOfficialRecommended;
38

    
39
/**
40
 * @author gvSIG Team
41
 * @version $Id$
42
 * 
43
 */
44
public class OfficialRecommendedCellRenderer extends DefaultTableCellRenderer {
45

    
46
        private static final long serialVersionUID = 1195015856704835320L;
47

    
48
        private DefaultSwingInstallerManager swingInstallerManager;
49

    
50
        public OfficialRecommendedCellRenderer() {
51
                swingInstallerManager = (DefaultSwingInstallerManager) SwingInstallerLocator
52
                                .getSwingInstallerManager();
53
        }
54

    
55
        @Override
56
        public Component getTableCellRendererComponent(JTable table, Object value,
57
                        boolean isSelected, boolean hasFocus, int row, int column) {
58

    
59
                Icon icon;
60
                PackageOfficialRecommended status = (PackageOfficialRecommended) value;
61
                JLabel check = new JLabel();
62
                URL resource;
63

    
64
                switch (status) {
65

    
66
                case OFFICIAL_RECOMMENDED:
67
                        resource = this.getClass().getResource(
68
                                        "/images/officialRecommended.png");
69
                        icon = new ImageIcon(resource);
70
                        check.setToolTipText(swingInstallerManager
71
                                        .getText("_official_recommended"));
72
                        check.setIcon(icon);
73

    
74
                        return check;
75

    
76
                case OFFICIAL_NOT_RECOMMENDED:
77
                        resource = this.getClass().getResource(
78
                                        "/images/officialNotRecommended.png");
79
                        icon = new ImageIcon(resource);
80
                        check.setToolTipText(swingInstallerManager.getText("_official"));
81
                        check.setIcon(icon);
82

    
83
                        return check;
84

    
85
                case NOT_OFFICIAL_RECOMMENDED:
86
                        resource = this.getClass().getResource(
87
                                        "/images/notOfficialRecommended.png");
88
                        icon = new ImageIcon(resource);
89
                        check.setIcon(icon);
90
                        check.setToolTipText(swingInstallerManager
91
                                        .getText("_not_official_recommended"));
92
                        return check;
93

    
94
                case NOT_OFFICIAL_NOT_RECOMMENDED:
95
                        resource = this.getClass().getResource("/images/notOfficial.png");
96
                        icon = new ImageIcon(resource);
97
                        check.setIcon(icon);
98
                        check
99
                                        .setToolTipText(swingInstallerManager
100
                                                        .getText("_not_official"));
101
                        return check;
102

    
103
                default:
104
                        // no image as default
105
                        return check;
106

    
107
                }
108
        }
109

    
110
}