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 @ 41804

History | View | Annotate | Download (3.17 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
                
64
                String oslabel = osArch.os;
65
                if( InstallerManager.OS.LINUX.equalsIgnoreCase(osArch.os) ) {
66
                    oslabel = "Linux";
67
                } else if( InstallerManager.OS.WINDOWS.equalsIgnoreCase(osArch.os) ) {
68
                    oslabel = "Windows";
69
                }
70
                
71
                if( InstallerManager.ARCH.ALL.equalsIgnoreCase(osArch.arch) ) {
72
                    tooltip = oslabel;
73
                } else if( InstallerManager.ARCH.X86.equalsIgnoreCase(osArch.arch) ) {
74
                    tooltip = oslabel + " 32 bits";
75
                } else if( InstallerManager.ARCH.X86_64.equalsIgnoreCase(osArch.arch) ) {
76
                    tooltip = oslabel + " 64 bits";
77
                } else {
78
                    tooltip = oslabel + " (" + osArch.arch +")";
79
                }
80

    
81
                try {
82
                        resource = this.getClass().getResource("/images/platform_14x14_"+osArch.os+"_"+osArch.arch+".png");
83
                } catch( Exception ex) {
84
                        resource = null;
85
                }
86
                if( resource == null ) {
87
                        resource = this.getClass().getResource("/images/platform_14x14_unknow_unknow.png");
88
                }
89
                icon = new ImageIcon(resource);
90
                check.setIcon(icon);
91
                check.setToolTipText(tooltip);
92
                return check;
93
        }
94

    
95
}