Statistics
| Revision:

root / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / panels / fieldstree / CheckBoxTreeCellRenderer.java @ 27077

History | View | Annotate | Download (4.24 KB)

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

    
3
import java.awt.Component;
4

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

    
11
import org.gvsig.remoteClient.gml.types.IXMLType;
12

    
13
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
14
 *
15
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
16
 *
17
 * This program is free software; you can redistribute it and/or
18
 * modify it under the terms of the GNU General Public License
19
 * as published by the Free Software Foundation; either version 2
20
 * of the License, or (at your option) any later version.
21
 *
22
 * This program is distributed in the hope that it will be useful,
23
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25
 * GNU General Public License for more details.
26
 *
27
 * You should have received a copy of the GNU General Public License
28
 * along with this program; if not, write to the Free Software
29
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
30
 *
31
 * For more information, contact:
32
 *
33
 *  Generalitat Valenciana
34
 *   Conselleria d'Infraestructures i Transport
35
 *   Av. Blasco Ib??ez, 50
36
 *   46010 VALENCIA
37
 *   SPAIN
38
 *
39
 *      +34 963862235
40
 *   gvsig@gva.es
41
 *      www.gvsig.gva.es
42
 *
43
 *    or
44
 *
45
 *   IVER T.I. S.A
46
 *   Salamanca 50
47
 *   46005 Valencia
48
 *   Spain
49
 *
50
 *   +34 963163400
51
 *   dac@iver.es
52
 */
53
/* CVS MESSAGES:
54
 *
55
 * $Id$
56
 * $Log$
57
 * Revision 1.3  2007-09-19 16:14:50  jaume
58
 * removed unnecessary imports
59
 *
60
 * Revision 1.2  2006/12/26 10:25:37  ppiqueras
61
 * Corregidas las dependencias con las nuevas ubicaciones de clases: IXMLType, XMLElement, IXMLComplexType, etc. (en libRemoteServices)
62
 *
63
 * Revision 1.1  2006/12/26 09:12:48  ppiqueras
64
 * Cambiado "atttibutes" en todas las aparaciones en atributos, m?todos, clases, paquetes o comentarios por "fields". (S?lo a aquellas que afectan a clases dentro del proyecto extWFS2). (En este caso se ha cambiado el nombre del paquete aparte de alguno otro nombre que puede haber cambiado).
65
 *
66
 * Revision 1.3  2006/10/31 12:24:04  jorpiell
67
 * Comprobado el caso en el que los atributos no tienen tipo
68
 *
69
 * Revision 1.2  2006/10/31 09:39:44  jorpiell
70
 * Se devuelve el tipo de la entidad completo, y no sus hijos
71
 *
72
 * Revision 1.1  2006/10/27 11:33:19  jorpiell
73
 * A?adida la treetable con los check box para seleccionar los atributos
74
 *
75
 *
76
 */
77
/**
78
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
79
 */
80
public class CheckBoxTreeCellRenderer extends DefaultTreeCellRenderer{ 
81
        private JTree tree;
82
        private FieldsTreeTable treetable;
83
        
84
        public CheckBoxTreeCellRenderer(FieldsTreeTable treetable) {
85
                this.treetable = treetable;
86
                this.tree = (JTree)treetable.getTree();
87
        }
88
        
89
        /*
90
         *  (non-Javadoc)
91
         * @see javax.swing.tree.TreeCellRenderer#getTreeCellRendererComponent(javax.swing.JTree, java.lang.Object, boolean, boolean, boolean, int, boolean)
92
         */
93
        public Component getTreeCellRendererComponent(JTree tree, Object value,
94
                        boolean selected, boolean expanded, boolean leaf, int row,
95
                        boolean hasFocus) {
96
                        int[] rows = tree.getSelectionRows();
97
                        TreePath path = tree.getPathForRow(row);
98
                        if (path != null){
99
                                Object node = path.getLastPathComponent();
100
                                if ((node != null) && (node instanceof CheckBoxNode)){
101
                                        CheckBoxNode selectedNode = (CheckBoxNode)node;
102
                                        if (selectedNode.getParent() == null){
103
                                                tree.expandRow(0);
104
                                        }
105
                                        if (selected){
106
                                                selectedNode.setBackground(UIManager.getColor("Tree.selectionBackground"));
107
                                                if (hasFocus){
108
                                                        if ((selectedNode.getElement().getEntityType() == null) || 
109
                                                                !(selectedNode.getElement().getEntityType().getType() == IXMLType.GML_GEOMETRY)){
110
                                                                treetable.setApplicable(true);
111
                                                                selectedNode.setSelected(!selectedNode.isSelected());
112
                                                                selectedNode.setColor(TetraStateCheckBox.WHITE);
113
                                                        }
114
                                                }
115
                                        }else{
116
                                                selectedNode.setBackground(UIManager.getColor("Tree.textBackground"));
117
                                        }                                        
118
                                        return selectedNode;
119
                                }
120
                        }        
121
                        JLabel label = new JLabel(CheckBoxNode.fillNameWithBlancs("Feature"));
122
                return label;
123
        }        
124

    
125
        
126
}