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 / InstallStatusCellRenderer.java @ 40560

History | View | Annotate | Download (3.97 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.PackageStatus;
38

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

    
46
        private static final long serialVersionUID = 1195015856704835320L;
47

    
48
        private DefaultSwingInstallerManager swingInstallerManager;
49

    
50
        public InstallStatusCellRenderer() {
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
                PackageStatus status = (PackageStatus) value;
61
                JLabel check = new JLabel();
62
                URL resource;
63

    
64
                switch (status) {
65

    
66
                case INSTALLED:
67
                        resource = this.getClass().getResource("/images/installed.png");
68
                        icon = new ImageIcon(resource);
69
                        check.setIcon(icon);
70
                        check.setToolTipText(swingInstallerManager
71
                                        .getText("_already_installed,_check_to_reinstall"));
72
                        return check;
73

    
74
                case TO_REINSTALL:
75
                        resource = this.getClass().getResource("/images/toReinstall.png");
76
                        icon = new ImageIcon(resource);
77
                        check.setIcon(icon);
78
                        check.setToolTipText(swingInstallerManager
79
                                        .getText("_checked_to_reinstall"));
80
                        return check;
81

    
82
                case NOT_INSTALLED:
83
                        resource = this.getClass().getResource("/images/notInstalled.png");
84
                        icon = new ImageIcon(resource);
85
                        check.setIcon(icon);
86
                        check.setToolTipText(swingInstallerManager
87
                                        .getText("_not_installed,_check_to_install"));
88
                        return check;
89

    
90
                case TO_INSTALL:
91
                        resource = this.getClass().getResource("/images/toInstall.png");
92
                        icon = new ImageIcon(resource);
93
                        check.setIcon(icon);
94
                        check.setToolTipText(swingInstallerManager
95
                                        .getText("_checked_to_install"));
96
                        return check;
97

    
98
                case INSTALLED_NOT_INSTALLABLE:
99
                        resource = this.getClass().getResource(
100
                                        "/images/installedNotInstallable.png");
101
                        icon = new ImageIcon(resource);
102
                        check.setIcon(icon);
103
                        check.setToolTipText(swingInstallerManager
104
                                        .getText("_already_installed_but_not_installable"));
105
                        return check;
106
                        
107
                case BROKEN:
108
                        resource = this.getClass().getResource(
109
                                        "/images/broken.png");
110
                        icon = new ImageIcon(resource);
111
                        check.setIcon(icon);
112
                        check.setToolTipText(swingInstallerManager
113
                                        .getText("_broken_package"));
114
                        return check;
115

    
116
                case INSTALLATION_NOT_AVAILABLE:
117
                        resource = this.getClass().getResource(
118
                                        "/images/broken.png");
119
                        icon = new ImageIcon(resource);
120
                        check.setIcon(icon);
121
                        check.setToolTipText(swingInstallerManager
122
                                        .getText("_can_install_package_at_this_moment"));
123
                        return check;
124

    
125
                default:
126
                        return check;
127
                }
128

    
129
        }
130
}