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

History | View | Annotate | Download (3.3 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.lib.api.InstallerManager;
36
import org.gvsig.installer.swing.impl.execution.panel.model.PackagesTableModel.PackageOsAndArchitecture;
37

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

    
45
        private static final long serialVersionUID = 3767874502044161245L;
46

    
47
        public OsAndArchitectureCellRenderer() {
48
        }
49

    
50
        @Override
51
        public Component getTableCellRendererComponent(JTable table, Object value,
52
                        boolean isSelected, boolean hasFocus, int row, int column) {
53

    
54
                String tooltip;
55
                Icon icon;
56
                URL resource;
57
                JLabel check = new JLabel();
58
                PackageOsAndArchitecture osArch = (PackageOsAndArchitecture) value;
59

    
60
                if( InstallerManager.OS.ALL.equalsIgnoreCase(osArch.os) ) {
61
                        return check;
62
                        
63
                } else if( InstallerManager.OS.LINUX.equalsIgnoreCase(osArch.os) ) {
64
                        if( InstallerManager.ARCH.X86.equalsIgnoreCase(osArch.arch) ) {
65
                                tooltip = "Linux 32 bits";
66
                        } else if( InstallerManager.ARCH.X86_64.equalsIgnoreCase(osArch.arch) ) {
67
                                tooltip = "Linux 64 bits";
68
                        } else {
69
                                tooltip = "Linux " + osArch;
70
                        }
71
                } else if( InstallerManager.OS.WINDOWS.equalsIgnoreCase(osArch.os) ) {
72
                        if( InstallerManager.ARCH.X86.equalsIgnoreCase(osArch.arch) ) {
73
                                tooltip = "Windows 32 bits";
74
                        } else if( InstallerManager.ARCH.X86_64.equalsIgnoreCase(osArch.arch) ) {
75
                                tooltip = "Windows 64 bits";
76
                        } else {
77
                                tooltip = "Windows " + osArch;
78
                        }
79
                } else {
80
                        if( InstallerManager.ARCH.X86.equalsIgnoreCase(osArch.arch) ) {
81
                                tooltip = osArch.os + " 32 bits";
82
                        } else if( InstallerManager.ARCH.X86_64.equalsIgnoreCase(osArch.arch) ) {
83
                                tooltip = osArch.os + " 64 bits";
84
                        } else {
85
                                tooltip = osArch.os + " " + osArch.arch;
86
                        }
87
                }
88
                try {
89
                        resource = this.getClass().getResource("/images/platform_14x14_"+osArch.os+"_"+osArch.arch+".png");
90
                } catch( Exception ex) {
91
                        resource = null;
92
                }
93
                if( resource == null ) {
94
                        resource = this.getClass().getResource("/images/platform_14x14_unknow_unknow.png");
95
                }
96
                icon = new ImageIcon(resource);
97
                check.setIcon(icon);
98
                check.setToolTipText(tooltip);
99
                return check;
100
        }
101

    
102
}