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 / InstallStatusCellEditor.java @ 40560
History | View | Annotate | Download (3.16 KB)
1 | 40560 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 40435 | jjdelcerro | *
|
4 | 40560 | jjdelcerro | * Copyright (C) 2007-2013 gvSIG Association.
|
5 | 40435 | jjdelcerro | *
|
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 | 40560 | jjdelcerro | * as published by the Free Software Foundation; either version 3
|
9 | 40435 | jjdelcerro | * 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 | 40560 | jjdelcerro | * For any additional information, do not hesitate to contact us
|
22 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
23 | 40435 | jjdelcerro | */
|
24 | package org.gvsig.installer.swing.impl.execution.panel.renderers; |
||
25 | |||
26 | import java.awt.Component; |
||
27 | |||
28 | import javax.swing.DefaultCellEditor; |
||
29 | import javax.swing.JCheckBox; |
||
30 | import javax.swing.JTable; |
||
31 | |||
32 | import org.gvsig.installer.swing.impl.execution.panel.SelectPackagesPanel; |
||
33 | import org.gvsig.installer.swing.impl.execution.panel.model.PackagesTableModel.PackageStatus; |
||
34 | |||
35 | /**
|
||
36 | * @author gvSIG Team
|
||
37 | * @version $Id$
|
||
38 | *
|
||
39 | */
|
||
40 | public class InstallStatusCellEditor extends DefaultCellEditor { |
||
41 | |||
42 | private static final long serialVersionUID = 1271382732175530111L; |
||
43 | PackageStatus status; |
||
44 | SelectPackagesPanel panel; |
||
45 | |||
46 | public InstallStatusCellEditor(SelectPackagesPanel selectPackagesPanel) {
|
||
47 | super(new JCheckBox()); |
||
48 | this.panel = selectPackagesPanel;
|
||
49 | } |
||
50 | |||
51 | @Override
|
||
52 | public Component getTableCellEditorComponent(JTable arg0, Object value, |
||
53 | boolean isSelected, int row, int col) { |
||
54 | JCheckBox check = (JCheckBox) this.getComponent(); |
||
55 | status = (PackageStatus) value; |
||
56 | |||
57 | switch (status) {
|
||
58 | |||
59 | case INSTALLED:
|
||
60 | check.setEnabled(true);
|
||
61 | check.setSelected(false);
|
||
62 | break;
|
||
63 | |||
64 | case TO_REINSTALL:
|
||
65 | check.setEnabled(true);
|
||
66 | check.setSelected(true);
|
||
67 | break;
|
||
68 | |||
69 | case NOT_INSTALLED:
|
||
70 | check.setEnabled(true);
|
||
71 | check.setSelected(false);
|
||
72 | break;
|
||
73 | |||
74 | case TO_INSTALL:
|
||
75 | check.setEnabled(true);
|
||
76 | check.setSelected(true);
|
||
77 | break;
|
||
78 | |||
79 | case INSTALLED_NOT_INSTALLABLE:
|
||
80 | check.setEnabled(false);
|
||
81 | break;
|
||
82 | |||
83 | case INSTALLATION_NOT_AVAILABLE:
|
||
84 | check.setEnabled(false);
|
||
85 | check.setSelected(false);
|
||
86 | break;
|
||
87 | |||
88 | case BROKEN:
|
||
89 | check.setEnabled(false);
|
||
90 | check.setSelected(false);
|
||
91 | break;
|
||
92 | |||
93 | default:
|
||
94 | check.setSelected(false);
|
||
95 | check.setEnabled(false);
|
||
96 | break;
|
||
97 | } |
||
98 | return check;
|
||
99 | } |
||
100 | |||
101 | @Override
|
||
102 | public Object getCellEditorValue() { |
||
103 | JCheckBox check = (JCheckBox) this.getComponent(); |
||
104 | switch (status) {
|
||
105 | case INSTALLED:
|
||
106 | if (check.isSelected()) {
|
||
107 | status = PackageStatus.TO_REINSTALL; |
||
108 | } |
||
109 | break;
|
||
110 | |||
111 | case TO_REINSTALL:
|
||
112 | if (!check.isSelected()) {
|
||
113 | status = PackageStatus.INSTALLED; |
||
114 | } |
||
115 | break;
|
||
116 | |||
117 | case NOT_INSTALLED:
|
||
118 | if (check.isSelected()) {
|
||
119 | status = PackageStatus.TO_INSTALL; |
||
120 | } |
||
121 | break;
|
||
122 | |||
123 | case TO_INSTALL:
|
||
124 | if (!check.isSelected()) {
|
||
125 | status = PackageStatus.NOT_INSTALLED; |
||
126 | } |
||
127 | break;
|
||
128 | |||
129 | default:
|
||
130 | break;
|
||
131 | } |
||
132 | return status;
|
||
133 | } |
||
134 | } |