svn-gvsig-desktop / branches / v2_0_0_prep / extensions / 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 @ 37857
History | View | Annotate | Download (3.25 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
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 2
|
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 |
*/
|
22 |
package org.gvsig.installer.swing.impl.execution.panel.renderers; |
23 |
|
24 |
import java.awt.Component; |
25 |
import java.net.URL; |
26 |
|
27 |
import javax.swing.Icon; |
28 |
import javax.swing.ImageIcon; |
29 |
import javax.swing.JLabel; |
30 |
import javax.swing.JTable; |
31 |
import javax.swing.table.DefaultTableCellRenderer; |
32 |
|
33 |
import org.gvsig.installer.lib.api.InstallerManager; |
34 |
import org.gvsig.installer.swing.impl.execution.panel.model.PackagesTableModel.PackageOsAndArchitecture; |
35 |
|
36 |
/**
|
37 |
* @author gvSIG Team
|
38 |
* @version $Id$
|
39 |
*
|
40 |
*/
|
41 |
public class OsAndArchitectureCellRenderer extends DefaultTableCellRenderer { |
42 |
|
43 |
private static final long serialVersionUID = 3767874502044161245L; |
44 |
|
45 |
public OsAndArchitectureCellRenderer() {
|
46 |
} |
47 |
|
48 |
@Override
|
49 |
public Component getTableCellRendererComponent(JTable table, Object value, |
50 |
boolean isSelected, boolean hasFocus, int row, int column) { |
51 |
|
52 |
String tooltip;
|
53 |
Icon icon;
|
54 |
URL resource;
|
55 |
JLabel check = new JLabel(); |
56 |
PackageOsAndArchitecture osArch = (PackageOsAndArchitecture) value; |
57 |
|
58 |
if( InstallerManager.OS.ALL.equalsIgnoreCase(osArch.os) ) {
|
59 |
return check;
|
60 |
|
61 |
} else if( InstallerManager.OS.LINUX.equalsIgnoreCase(osArch.os) ) { |
62 |
if( InstallerManager.ARCH.X86.equalsIgnoreCase(osArch.arch) ) {
|
63 |
tooltip = "Linux 32 bits";
|
64 |
} else if( InstallerManager.ARCH.X86_64.equalsIgnoreCase(osArch.arch) ) { |
65 |
tooltip = "Linux 64 bits";
|
66 |
} else {
|
67 |
tooltip = "Linux " + osArch;
|
68 |
} |
69 |
} else if( InstallerManager.OS.WINDOWS.equalsIgnoreCase(osArch.os) ) { |
70 |
if( InstallerManager.ARCH.X86.equalsIgnoreCase(osArch.arch) ) {
|
71 |
tooltip = "Windows 32 bits";
|
72 |
} else if( InstallerManager.ARCH.X86_64.equalsIgnoreCase(osArch.arch) ) { |
73 |
tooltip = "Windows 64 bits";
|
74 |
} else {
|
75 |
tooltip = "Windows " + osArch;
|
76 |
} |
77 |
} else {
|
78 |
if( InstallerManager.ARCH.X86.equalsIgnoreCase(osArch.arch) ) {
|
79 |
tooltip = osArch.os + " 32 bits";
|
80 |
} else if( InstallerManager.ARCH.X86_64.equalsIgnoreCase(osArch.arch) ) { |
81 |
tooltip = osArch.os + " 64 bits";
|
82 |
} else {
|
83 |
tooltip = osArch.os + " " + osArch.arch;
|
84 |
} |
85 |
} |
86 |
try {
|
87 |
resource = this.getClass().getResource("/images/platform_14x14_"+osArch.os+"_"+osArch.arch+".png"); |
88 |
} catch( Exception ex) { |
89 |
resource = null;
|
90 |
} |
91 |
if( resource == null ) { |
92 |
resource = this.getClass().getResource("/images/platform_14x14_unknow_unknow.png"); |
93 |
} |
94 |
icon = new ImageIcon(resource); |
95 |
check.setIcon(icon); |
96 |
check.setToolTipText(tooltip); |
97 |
return check;
|
98 |
} |
99 |
|
100 |
} |