root / branches / v2_0_0_prep / extensions / extI18n / src / main / java / org / gvsig / i18n / extension / preferences / table / RadioButtonCellEditor.java @ 38564
History | View | Annotate | Download (2.39 KB)
1 | 25963 | cordinyana | /* gvSIG. Geographic Information System of the Valencian Government
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2007-2008 Infrastructures and Transports Department
|
||
4 | 31544 | cordinyana | * of the Valencian Government (CIT)
|
5 | 25963 | cordinyana | *
|
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 | |||
23 | /*
|
||
24 | * AUTHORS (In addition to CIT):
|
||
25 | * 2008 {DiSiD Technologies} {New extension for installation and update of text translations}
|
||
26 | */
|
||
27 | package org.gvsig.i18n.extension.preferences.table; |
||
28 | |||
29 | import java.awt.Component; |
||
30 | 38564 | jjdelcerro | import java.awt.event.ActionEvent; |
31 | import java.awt.event.ItemEvent; |
||
32 | import java.awt.event.ItemListener; |
||
33 | 25963 | cordinyana | |
34 | import javax.swing.AbstractCellEditor; |
||
35 | import javax.swing.JTable; |
||
36 | import javax.swing.table.TableCellEditor; |
||
37 | |||
38 | /**
|
||
39 | * Allows to edit a cell content with a Radio button.
|
||
40 | *
|
||
41 | * @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a>
|
||
42 | */
|
||
43 | public class RadioButtonCellEditor extends AbstractCellEditor implements |
||
44 | TableCellEditor, ItemListener { |
||
45 | |||
46 | private static final long serialVersionUID = 1000179477526963659L; |
||
47 | |||
48 | private RadioButtonCell delegate = new RadioButtonCell(); |
||
49 | |||
50 | /**
|
||
51 | * Constructor.
|
||
52 | */
|
||
53 | public RadioButtonCellEditor() {
|
||
54 | delegate.getRadioButton().addItemListener(this);
|
||
55 | } |
||
56 | |||
57 | public Object getCellEditorValue() { |
||
58 | return Boolean.valueOf(delegate.getRadioButton().isSelected()); |
||
59 | } |
||
60 | |||
61 | public Component getTableCellEditorComponent(JTable table, Object value, |
||
62 | boolean isSelected, int row, int column) { |
||
63 | return delegate.getTableCellComponent(table, value, isSelected,
|
||
64 | isSelected, row, column); |
||
65 | } |
||
66 | |||
67 | public void actionPerformed(ActionEvent e) { |
||
68 | // Stop editing when the user clicks into the radio button,
|
||
69 | // so other cells get its rendering updated
|
||
70 | fireEditingStopped(); |
||
71 | } |
||
72 | |||
73 | public void itemStateChanged(ItemEvent e) { |
||
74 | fireEditingStopped(); |
||
75 | } |
||
76 | |||
77 | } |