Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.editing.app / org.gvsig.editing.app.mainplugin / src / main / java / org / gvsig / editing / project / documents / view / legend / edition / gui / DisabledCellEditor.java @ 40557

History | View | Annotate | Download (2.58 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.editing.project.documents.view.legend.edition.gui;
25

    
26
import java.awt.Component;
27
import java.awt.event.MouseEvent;
28
import java.awt.event.MouseListener;
29

    
30
import javax.swing.ImageIcon;
31
import javax.swing.JTable;
32
import javax.swing.table.TableCellEditor;
33

    
34
import org.gvsig.editing.fmap.rendering.EditionManagerLegend;
35

    
36

    
37

    
38

    
39
/**
40
 * Cell Editor de iconos. Controla los eventos de edici?n que se realicen
41
 * sobre la columna de iconos.
42
 *
43
 * @author Vicente Caballero Navarro
44
 */
45
public class DisabledCellEditor extends IconOptionCellEditor implements TableCellEditor {
46
        public DisabledCellEditor(EditionManagerLegend el,JTable tab,ImageIcon sel, ImageIcon notSel) {
47
                super(el,tab,sel,notSel);
48
                addMouseListener(new MouseListener(){
49

    
50
                        public void mouseClicked(MouseEvent e) {
51
//                                if (e.getClickCount()==2){
52
                                        int index=table.getSelectedRow();
53
                                        if (eml.isDisable(index)) {
54
                                                setIcon(getNotSel());
55
                                                eml.setDisable(index,false);
56

    
57
                                        }else {
58
                                                eml.setDisable(index,true);
59
                                                setIcon(getSel());
60
                                        }
61
                                        stopCellEditing();
62
//                                }
63
                                table.repaint();
64
                        }
65

    
66
                        public void mouseEntered(MouseEvent e) {
67
                        }
68

    
69
                        public void mouseExited(MouseEvent e) {
70
                        }
71

    
72
                        public void mousePressed(MouseEvent e) {
73
                        }
74

    
75
                        public void mouseReleased(MouseEvent e) {
76
                        }
77

    
78
                });
79
        }
80

    
81
        //Implement the one method defined by TableCellEditor.
82
        public Component getTableCellEditorComponent(JTable table, Object value,
83
                boolean isSelected, int row, int column) {
84
//                if (table.getSelectedRow()==row)
85
//                setSelected(true);
86
//        else
87
                setSelected(isSelected);
88
                if (eml.isDisable(row)) {
89
                        setIcon(getSel());
90
                }else {
91
                        setIcon(getNotSel());
92
                }
93
                return this;
94
        }
95
}