Statistics
| Revision:

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 / InstallStatusCellEditor.java @ 37584

History | View | Annotate | Download (2.79 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

    
26
import javax.swing.DefaultCellEditor;
27
import javax.swing.JCheckBox;
28
import javax.swing.JTable;
29

    
30
import org.gvsig.installer.swing.impl.execution.panel.SelectPackagesPanel;
31
import org.gvsig.installer.swing.impl.execution.panel.model.PackagesTableModel.PackageStatus;
32

    
33
/**
34
 * @author gvSIG Team
35
 * @version $Id$
36
 * 
37
 */
38
public class InstallStatusCellEditor extends DefaultCellEditor {
39

    
40
        private static final long serialVersionUID = 1271382732175530111L;
41
        PackageStatus status;
42
        SelectPackagesPanel panel;
43

    
44
        public InstallStatusCellEditor(SelectPackagesPanel selectPackagesPanel) {
45
                super(new JCheckBox());
46
                this.panel = selectPackagesPanel;
47
        }
48

    
49
        @Override
50
        public Component getTableCellEditorComponent(JTable arg0, Object value,
51
                        boolean isSelected, int row, int col) {
52
                JCheckBox check = (JCheckBox) this.getComponent();
53
                status = (PackageStatus) value;
54

    
55
                switch (status) {
56

    
57
                case INSTALLED:
58
                        check.setSelected(false);
59
                        break;
60

    
61
                case TO_REINSTALL:
62
                        check.setSelected(true);
63
                        break;
64

    
65
                case NOT_INSTALLED:
66
                        check.setSelected(false);
67
                        break;
68

    
69
                case TO_INSTALL:
70
                        check.setSelected(true);
71
                        break;
72

    
73
                case INSTALLED_NOT_INSTALLABLE:
74
                        check.setEnabled(false);
75
                        break;
76

    
77
                default:
78
                        check.setSelected(false);
79
                        break;
80
                }
81
                return check;
82
        }
83

    
84
        @Override
85
        public Object getCellEditorValue() {
86
                JCheckBox check = (JCheckBox) this.getComponent();
87
                switch (status) {
88
                case INSTALLED:
89
                        if (check.isSelected()) {
90
                                status = PackageStatus.TO_REINSTALL;
91
                        }
92
                        break;
93

    
94
                case TO_REINSTALL:
95
                        if (!check.isSelected()) {
96
                                status = PackageStatus.INSTALLED;
97
                        }
98
                        break;
99

    
100
                case NOT_INSTALLED:
101
                        if (check.isSelected()) {
102
                                status = PackageStatus.TO_INSTALL;
103
                        }
104
                        break;
105

    
106
                case TO_INSTALL:
107
                        if (!check.isSelected()) {
108
                                status = PackageStatus.NOT_INSTALLED;
109
                        }
110
                        break;
111

    
112
                default:
113
                        break;
114
                }
115
                return status;
116
        }
117
}