Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / panels / attributesTree / CheckBoxTreeCellRenderer.java @ 8388

History | View | Annotate | Download (3.28 KB)

1
package com.iver.cit.gvsig.gui.panels.attributesTree;
2

    
3
import java.awt.Component;
4
import java.awt.Dimension;
5

    
6
import javax.swing.JButton;
7
import javax.swing.JLabel;
8
import javax.swing.JTree;
9
import javax.swing.UIManager;
10
import javax.swing.tree.DefaultTreeCellRenderer;
11
import javax.swing.tree.TreePath;
12

    
13
import org.gvsig.remoteClient.gml.schemas.IXMLType;
14
import org.gvsig.remoteClient.gml.schemas.XMLElement;
15

    
16
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
17
 *
18
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
19
 *
20
 * This program is free software; you can redistribute it and/or
21
 * modify it under the terms of the GNU General Public License
22
 * as published by the Free Software Foundation; either version 2
23
 * of the License, or (at your option) any later version.
24
 *
25
 * This program is distributed in the hope that it will be useful,
26
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28
 * GNU General Public License for more details.
29
 *
30
 * You should have received a copy of the GNU General Public License
31
 * along with this program; if not, write to the Free Software
32
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
33
 *
34
 * For more information, contact:
35
 *
36
 *  Generalitat Valenciana
37
 *   Conselleria d'Infraestructures i Transport
38
 *   Av. Blasco Ib??ez, 50
39
 *   46010 VALENCIA
40
 *   SPAIN
41
 *
42
 *      +34 963862235
43
 *   gvsig@gva.es
44
 *      www.gvsig.gva.es
45
 *
46
 *    or
47
 *
48
 *   IVER T.I. S.A
49
 *   Salamanca 50
50
 *   46005 Valencia
51
 *   Spain
52
 *
53
 *   +34 963163400
54
 *   dac@iver.es
55
 */
56
/* CVS MESSAGES:
57
 *
58
 * $Id: CheckBoxTreeCellRenderer.java 8388 2006-10-27 11:33:19Z jorpiell $
59
 * $Log$
60
 * Revision 1.1  2006-10-27 11:33:19  jorpiell
61
 * A?adida la treetable con los check box para seleccionar los atributos
62
 *
63
 *
64
 */
65
/**
66
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
67
 */
68
public class CheckBoxTreeCellRenderer extends DefaultTreeCellRenderer{ 
69
        private JTree tree;
70
        private AttributesTreeTable treetable;
71
        
72
        public CheckBoxTreeCellRenderer(AttributesTreeTable treetable) {
73
                this.treetable = treetable;
74
                this.tree = (JTree)treetable.getTree();
75
        }
76
        
77
        /*
78
         *  (non-Javadoc)
79
         * @see javax.swing.tree.TreeCellRenderer#getTreeCellRendererComponent(javax.swing.JTree, java.lang.Object, boolean, boolean, boolean, int, boolean)
80
         */
81
        public Component getTreeCellRendererComponent(JTree tree, Object value,
82
                        boolean selected, boolean expanded, boolean leaf, int row,
83
                        boolean hasFocus) {
84
                        int[] rows = tree.getSelectionRows();
85
                        TreePath path = tree.getPathForRow(row);
86
                        if (path != null){
87
                                Object node = path.getLastPathComponent();
88
                                if ((node != null) && (node instanceof CheckBoxNode)){
89
                                        CheckBoxNode selectedNode = (CheckBoxNode)node;
90
                                        if (selected){
91
                                                selectedNode.setBackground(UIManager.getColor("Tree.selectionBackground"));
92
                                                if (hasFocus){
93
                                                        if (!(selectedNode.getElement().getEntityType().getType() == IXMLType.GML_GEOMETRY)){
94
                                                                treetable.setUpdated(true);
95
                                                                selectedNode.setSelected(!selectedNode.isSelected());
96
                                                                selectedNode.setColor(TetraStateCheckBox.WHITE);
97
                                                        }
98
                                                }
99
                                        }else{
100
                                                selectedNode.setBackground(UIManager.getColor("Tree.textBackground"));
101
                                        }                                        
102
                                        return selectedNode;
103
                                }
104
                        }        
105
                        JLabel label = new JLabel(CheckBoxNode.fillNameWithBlancs("Feature"));
106
                return label;
107
        }        
108

    
109
        
110
}