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 / PresentCellEditor.java @ 40557

History | View | Annotate | Download (2.5 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 PresentCellEditor extends IconOptionCellEditor implements TableCellEditor {
46
        public PresentCellEditor(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.isPresent(index)) {
54
                                                eml.setPresent(index);
55
                                                setIcon(getSel());
56
                                        }
57
                                        stopCellEditing();
58
                                }
59
                                table.repaint();
60
                        }
61

    
62
                        public void mouseEntered(MouseEvent e) {
63
                        }
64

    
65
                        public void mouseExited(MouseEvent e) {
66
                        }
67

    
68
                        public void mousePressed(MouseEvent e) {
69
                        }
70

    
71
                        public void mouseReleased(MouseEvent e) {
72
                        }
73

    
74
                });
75
        }
76

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