Revision 27077

View differences:

trunk/extensions/extWFS2/src/com/iver/cit/gvsig/gui/panels/WFSSelectFieldsPanel.java
15 15

  
16 16
import com.iver.andami.PluginServices;
17 17
import com.iver.cit.gvsig.fmap.layers.WFSLayerNode;
18
import com.iver.cit.gvsig.gui.panels.fieldsTree.FieldsTreeTable;
19
import com.iver.cit.gvsig.gui.panels.fieldsTree.FieldsTreeTableModel;
20
import com.iver.cit.gvsig.gui.panels.fieldsTree.TreeTableModelWithCheckBoxes;
18
import com.iver.cit.gvsig.gui.panels.fieldstree.FieldsTreeTable;
19
import com.iver.cit.gvsig.gui.panels.fieldstree.FieldsTreeTableModel;
20
import com.iver.cit.gvsig.gui.panels.fieldstree.TreeTableModelWithCheckBoxes;
21 21

  
22 22
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
23 23
 *
trunk/extensions/extWFS2/src/com/iver/cit/gvsig/gui/panels/fieldstree/CheckBoxTreeCellEditor.java
1
package com.iver.cit.gvsig.gui.panels.fieldstree;
2

  
3
import java.awt.Component;
4
import java.awt.event.MouseEvent;
5
import java.util.EventObject;
6

  
7
import javax.swing.AbstractCellEditor;
8
import javax.swing.JCheckBox;
9
import javax.swing.JTree;
10
import javax.swing.event.ChangeEvent;
11
import javax.swing.tree.TreeCellEditor;
12
import javax.swing.tree.TreePath;
13

  
14
import org.gvsig.remoteClient.gml.types.IXMLType;
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$
59
 * $Log$
60
 * Revision 1.3  2007-09-19 16:14:50  jaume
61
 * removed unnecessary imports
62
 *
63
 * Revision 1.2  2006/12/26 10:25:37  ppiqueras
64
 * Corregidas las dependencias con las nuevas ubicaciones de clases: IXMLType, XMLElement, IXMLComplexType, etc. (en libRemoteServices)
65
 *
66
 * Revision 1.1  2006/12/26 09:12:48  ppiqueras
67
 * 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).
68
 *
69
 * Revision 1.2  2006/10/31 12:24:04  jorpiell
70
 * Comprobado el caso en el que los atributos no tienen tipo
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 CheckBoxTreeCellEditor extends AbstractCellEditor implements TreeCellEditor {
81
	CheckBoxTreeCellRenderer renderer = null;
82
	ChangeEvent changeEvent = null;
83
	JTree tree;
84
	FieldsTreeTable treetable;
85
	
86
	public CheckBoxTreeCellEditor(FieldsTreeTable treetable) {
87
		this.treetable = treetable;
88
		this.tree = (JTree)treetable.getTree();
89
		this.renderer = new CheckBoxTreeCellRenderer(treetable);
90
	}	
91
	
92
	/*
93
	 *  (non-Javadoc)
94
	 * @see javax.swing.CellEditor#getCellEditorValue()
95
	 */
96
	public Object getCellEditorValue() {
97
		return null;
98
	}
99
	
100
	/*
101
	 *  (non-Javadoc)
102
	 * @see javax.swing.CellEditor#isCellEditable(java.util.EventObject)
103
	 */
104
	public boolean isCellEditable(EventObject event) {
105
		if (event instanceof MouseEvent) {
106
			MouseEvent mouseEvent = (MouseEvent) event;
107
			TreePath path = tree.getPathForLocation(mouseEvent.getX(),
108
					mouseEvent.getY());
109
			if (path != null) {
110
				Object node = path.getLastPathComponent();
111
				if ((node != null) && (node instanceof CheckBoxNode)) {
112
					CheckBoxNode selectedNode = (CheckBoxNode)node;
113
					if (mouseEvent.getClickCount() == 2){
114
						
115
					}else if(mouseEvent.getClickCount() == 1){
116
						changeAllChildren(selectedNode,!selectedNode.isSelected());
117
						changeParentState(selectedNode,!selectedNode.isSelected());
118
						tree.repaint();
119
					}
120
				}
121
			}
122
		}
123
		return false;
124
	}
125
	
126
	/*
127
	 *  (non-Javadoc)
128
	 * @see javax.swing.tree.TreeCellEditor#getTreeCellEditorComponent(javax.swing.JTree, java.lang.Object, boolean, boolean, boolean, int)
129
	 */
130
	public Component getTreeCellEditorComponent(JTree tree, Object value,
131
			boolean selected, boolean expanded, boolean leaf, int row) {
132
		Component editor = renderer.getTreeCellRendererComponent(tree, value,
133
				true, expanded, leaf, row, true);
134
		
135
		if (editor instanceof JCheckBox) {
136
			//((JCheckBox) editor).addItemListener(new CheckBoxListener());
137
		}		
138
		return editor;
139
	}	
140
	
141
	/**
142
	 * It enable or disable the parent node state depending of its children values
143
	 * @param selectedNode
144
	 * Selected node
145
	 * @param isSelected
146
	 * Current node status
147
	 */
148
	private void changeParentState(CheckBoxNode selectedNode,boolean isSelected){
149
		CheckBoxNode parent = selectedNode.getParentNode();
150
		while (parent != null){			
151
			if (isSelected != parent.isSelected()){
152
				parent.setColor(TetraStateCheckBox.GREY);
153
			}else{	
154
				boolean isEnabled = true;
155
				for (int i=0 ; i<parent.getChildren().size() ; i++){
156
					CheckBoxNode child = (CheckBoxNode)parent.getChildren().get(i);
157
					if (child != selectedNode){
158
						if (parent.isSelected() != child.isSelected()){
159
							isEnabled = false;
160
						}
161
					}
162
				}
163
				if (!isEnabled){
164
					parent.setColor(TetraStateCheckBox.GREY);
165
				}else{
166
					parent.setColor(TetraStateCheckBox.WHITE);
167
				}					
168
				
169
			}			
170
			selectedNode = parent;
171
			parent = selectedNode.getParentNode();			
172
		}
173
	}
174
	
175
	
176
	/**
177
	 * It changes all the children status
178
	 * @param selectedNode
179
	 * Root node
180
	 * @param selected
181
	 * New state
182
	 */
183
	private void changeAllChildren(CheckBoxNode selectedNode,boolean selected){
184
		for (int i=0 ; i<selectedNode.getChildren().size() ; i++){
185
			CheckBoxNode child = ((CheckBoxNode)selectedNode.getChildren().get(i));
186
			if ((child.getElement().getEntityType() == null) || 
187
					(child.getElement().getEntityType().getType() != IXMLType.GML_GEOMETRY)){
188
				child.setSelected(selected);	
189
			}
190
			if (child.getChildren().size() > 0){
191
				changeAllChildren(child,selected);
192
			}			
193
		}
194
	}
195
}
0 196

  
trunk/extensions/extWFS2/src/com/iver/cit/gvsig/gui/panels/fieldstree/CheckBoxTreeCellRenderer.java
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
}
0 127

  
trunk/extensions/extWFS2/src/com/iver/cit/gvsig/gui/panels/fieldstree/FieldsTreeTable.java
1
package com.iver.cit.gvsig.gui.panels.fieldstree;
2

  
3
import java.util.ArrayList;
4
import java.util.Vector;
5

  
6
import javax.swing.JToolTip;
7
import javax.swing.JTree;
8

  
9
import org.gvsig.gui.beans.controls.MultiLineToolTip;
10
import org.gvsig.gui.beans.swing.treeTable.TreeTableModelAdapter;
11
import org.gvsig.remoteClient.gml.schemas.XMLElement;
12
import org.gvsig.remoteClient.gml.types.IXMLType;
13

  
14
import com.iver.cit.gvsig.gui.panels.WFSSelectFieldsPanel;
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$
59
 * $Log$
60
 * Revision 1.4  2007-09-19 16:14:50  jaume
61
 * removed unnecessary imports
62
 *
63
 * Revision 1.3  2007/03/15 13:35:47  ppiqueras
64
 * Corregido bug: lanzaba una excepci?n en el m?todo de b?squeda de campo geometr?a cuando el nodo era null.
65
 *
66
 * Revision 1.2  2007/02/19 11:44:42  jorpiell
67
 * Añadidos los filtros por área
68
 *
69
 * Revision 1.1  2006/12/26 09:12:48  ppiqueras
70
 * 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).
71
 *
72
 * Revision 1.5  2006/11/15 17:37:39  jorpiell
73
 * Se copia el padre
74
 *
75
 * Revision 1.4  2006/11/10 13:14:47  ppiqueras
76
 * Corregido un bug: caos que haya campos de una feature de una capa WFS, que no tengan tipo (tipo == null).
77
 *
78
 * Revision 1.3  2006/11/01 17:29:07  jorpiell
79
 * Se ha elimiado el nodo virtual de la raiz. Adem?s ya se cargan los valores de un campo complejo en la pesta?a del filtro
80
 *
81
 * Revision 1.2  2006/10/31 09:39:44  jorpiell
82
 * Se devuelve el tipo de la entidad completo, y no sus hijos
83
 *
84
 * Revision 1.1  2006/10/27 11:33:19  jorpiell
85
 * A?adida la treetable con los check box para seleccionar los atributos
86
 *
87
 * Revision 1.3  2006/10/24 10:13:19  jorpiell
88
 * Se ha eliminado la pesta?a de filter
89
 *
90
 * Revision 1.2  2006/10/24 07:58:14  jorpiell
91
 * Eliminado el parametro booleano que hac?a que apareciesen mas de una columna en el tree table
92
 *
93
 * Revision 1.1  2006/10/24 07:27:56  jorpiell
94
 * Algunos cambios en el modelo que usa la tabla
95
 *
96
 *
97
 */
98

  
99
/**
100
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
101
 */
102
public class FieldsTreeTable extends org.gvsig.gui.beans.swing.treeTable.TreeTable {
103
	WFSSelectFieldsPanel parent = null;
104
	
105
	public FieldsTreeTable(FieldsTreeTableModel treeTableModel) {
106
		super(treeTableModel);
107
		JTree tree = (JTree)getTree();
108
		tree.setCellRenderer(new CheckBoxTreeCellRenderer(this));
109
		tree.setCellEditor(new CheckBoxTreeCellEditor(this));
110
		tree.setEditable(true);		
111
	}
112

  
113
	public FieldsTreeTable(FieldsTreeTableModel treeTableModel,WFSSelectFieldsPanel parent) {
114
		super(treeTableModel);
115
		this.parent = parent;
116
		JTree tree = (JTree)getTree();
117
		tree.setCellRenderer(new CheckBoxTreeCellRenderer(this));
118
		tree.setCellEditor(new CheckBoxTreeCellEditor(this));
119
		tree.setEditable(true);
120
	}
121

  
122
	/**
123
	 * Sets the fields
124
	 * @param fields
125
	 */
126
	public void setFields(Vector vFields){
127
		Object[] fields = new Object[vFields.size()];
128
		for (int i=0 ; i<vFields.size() ; i++){
129
			fields[i] = vFields.get(i);
130
		}
131
		setModel(new FieldsTreeTableModel(fields));
132
		deleteIcons();
133
		setRootVisible(false);
134
	}
135

  
136
	/**
137
	 * Gets the selected layer
138
	 * @return
139
	 */
140
	public Object[] getSelectedValues(){
141
		int[] selectedRows = getSelectedRows();
142
		TreeTableModelAdapter obj = (TreeTableModelAdapter)getModel();
143
		Object[] objects = new Object[selectedRows.length];
144
		for (int i=0 ; i<selectedRows.length ; i++){
145
			objects[i] = obj.nodeForRow(selectedRows[i]);
146
		}
147
		return objects;
148
	}
149

  
150
	/**
151
	 * return the selected elements
152
	 * @return
153
	 */
154
	public XMLElement[] getSelectedElements(){
155
		TreeTableModelAdapter obj = (TreeTableModelAdapter)getModel();
156
		ArrayList elements = new ArrayList();
157
		for (int i=0 ; i< obj.getRowCount() ; i++){
158
			if (obj.nodeForRow(i) instanceof CheckBoxNode){
159
				CheckBoxNode node = (CheckBoxNode)obj.nodeForRow(i);
160
				if (node.isSelected()){
161
					XMLElement element = node.getElement();
162
					CheckBoxNode parentNode = node.getParentNode();
163
					if (parentNode != null){
164
						element.setParentElement(parentNode.getElement());
165
					}
166
					elements.add(element);
167
				}					
168
			}
169
		}
170
	
171
		XMLElement[] selected = new XMLElement[elements.size()];
172
		for (int i=0 ; i<elements.size() ; i++){
173
			selected[i] = (XMLElement)elements.get(i);
174
		}
175
		return selected;
176
	}
177
	
178
	
179
	public void setModel(FieldsTreeTableModel treeTableModel){
180
		super.setModel(treeTableModel);
181
		JTree tree = (JTree)getTree();
182
		tree.setCellRenderer(new CheckBoxTreeCellRenderer(this));
183
		tree.setCellEditor(new CheckBoxTreeCellEditor(this));
184
		tree.setEditable(true);		
185
	}
186
	
187
	/**
188
	 * Gets the geometry field
189
	 * @return
190
	 */
191
	public String getGeometryField(){
192
		TreeTableModelAdapter obj = (TreeTableModelAdapter)getModel();
193
		ArrayList elements = new ArrayList();
194
		for (int i=0 ; i< obj.getRowCount() ; i++){
195
			if (obj.nodeForRow(i) instanceof CheckBoxNode){
196
				CheckBoxNode node = (CheckBoxNode)obj.nodeForRow(i);
197
				XMLElement element = node.getElement();
198
				if (element.getEntityType() != null) {
199
					if (element.getEntityType().getType() == IXMLType.GML_GEOMETRY){
200
						return element.getName();
201
					}
202
				}
203
			}
204
		}
205
		return null;
206
	}
207
	
208
	/**
209
	 * Set the selected fields
210
	 * @param selectedFields
211
	 */
212
	public void setSelectedFields(Vector selectedFields) {
213
		TreeTableModelAdapter obj = (TreeTableModelAdapter)getModel();
214
		JTree tree = (JTree)getTree();
215
	
216
		for (int i = 0; i < tree.getRowCount(); i++) {
217
			tree.expandRow(i);
218
		}	
219
		for (int i=0 ; i<obj.getRowCount() ; i++){
220
			if (obj.nodeForRow(i) instanceof CheckBoxNode){
221
				XMLElement element = ((CheckBoxNode)obj.nodeForRow(i)).getElement();
222
				for (int j=0 ; j<selectedFields.size() ; j++){
223
					//If the name is equals
224
					if (((XMLElement)selectedFields.get(j)).getName().equals(element.getName())){
225
						//If the type is equals					
226
						if ( (element.getEntityType() != null) && (((XMLElement)selectedFields.get(j)).getEntityType() != null) && (((XMLElement)selectedFields.get(j)).getEntityType().getName().equals(element.getEntityType().getName())) ){
227
							((CheckBoxNode)obj.nodeForRow(i)).setSelected(true);
228
						}
229
					}
230
				}
231
			}			
232
		}
233
		
234
	}
235
	
236
	/**
237
	 * <p>Changes the status to applied.</p>
238
	 * 
239
	 * @param applicable a boolean value
240
	 */
241
	public void setApplicable(boolean applicable) {
242
		if (parent != null){
243
			parent.setApplicable(applicable);
244
		}
245
	}
246
	
247
	/*
248
	 * (non-Javadoc)
249
	 * @see javax.swing.JComponent#createToolTip()
250
	 */
251
    public JToolTip createToolTip() {
252
    	// Multiline support
253
    	MultiLineToolTip tip = new MultiLineToolTip();
254
    	tip.setComponent(this);
255
    	return tip;
256
    }
257
}
0 258

  
trunk/extensions/extWFS2/src/com/iver/cit/gvsig/gui/panels/fieldstree/FieldsTreeTableModel.java
1
package com.iver.cit.gvsig.gui.panels.fieldstree;
2

  
3
import java.util.Vector;
4

  
5
import org.gvsig.gui.beans.swing.treeTable.AbstractTreeTableModel;
6
import org.gvsig.gui.beans.swing.treeTable.TreeTableModel;
7
import org.gvsig.remoteClient.gml.schemas.XMLElement;
8
import org.gvsig.remoteClient.gml.types.IXMLType;
9
import org.gvsig.remoteClient.gml.types.XMLComplexType;
10

  
11
import com.iver.andami.PluginServices;
12
import com.iver.cit.gvsig.fmap.drivers.wfs.WFSUtils;
13

  
14
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
15
 *
16
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
17
 *
18
 * This program is free software; you can redistribute it and/or
19
 * modify it under the terms of the GNU General Public License
20
 * as published by the Free Software Foundation; either version 2
21
 * of the License, or (at your option) any later version.
22
 *
23
 * This program is distributed in the hope that it will be useful,
24
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26
 * GNU General Public License for more details.
27
 *
28
 * You should have received a copy of the GNU General Public License
29
 * along with this program; if not, write to the Free Software
30
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
31
 *
32
 * For more information, contact:
33
 *
34
 *  Generalitat Valenciana
35
 *   Conselleria d'Infraestructures i Transport
36
 *   Av. Blasco Ib??ez, 50
37
 *   46010 VALENCIA
38
 *   SPAIN
39
 *
40
 *      +34 963862235
41
 *   gvsig@gva.es
42
 *      www.gvsig.gva.es
43
 *
44
 *    or
45
 *
46
 *   IVER T.I. S.A
47
 *   Salamanca 50
48
 *   46005 Valencia
49
 *   Spain
50
 *
51
 *   +34 963163400
52
 *   dac@iver.es
53
 */
54
/* CVS MESSAGES:
55
 *
56
 * $Id$
57
 * $Log$
58
 * Revision 1.3  2007-01-23 13:11:04  ppiqueras
59
 * Cambios sin importancia.
60
 *
61
 * Revision 1.2  2006/12/26 10:25:37  ppiqueras
62
 * Corregidas las dependencias con las nuevas ubicaciones de clases: IXMLType, XMLElement, IXMLComplexType, etc. (en libRemoteServices)
63
 *
64
 * Revision 1.1  2006/12/26 09:12:48  ppiqueras
65
 * 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).
66
 *
67
 * Revision 1.7  2006/12/14 12:29:58  ppiqueras
68
 * Añadido método para obtener todas las hojas del árbol
69
 *
70
 * Revision 1.6  2006/11/10 13:14:47  ppiqueras
71
 * Corregido un bug: caos que haya campos de una feature de una capa WFS, que no tengan tipo (tipo == null).
72
 *
73
 * Revision 1.5  2006/11/10 09:04:33  ppiqueras
74
 * La geometría no se visualiza en el árbol del panel de filtro, pero sí en el de atributos
75
 *
76
 * Revision 1.4  2006/11/01 17:29:07  jorpiell
77
 * Se ha elimiado el nodo virtual de la raiz. Adem?s ya se cargan los valores de un campo complejo en la pesta?a del filtro
78
 *
79
 * Revision 1.3  2006/10/31 13:51:15  ppiqueras
80
 * Soporte parent Element
81
 *
82
 * Revision 1.2  2006/10/31 12:24:04  jorpiell
83
 * Comprobado el caso en el que los atributos no tienen tipo
84
 *
85
 * Revision 1.1  2006/10/27 11:33:19  jorpiell
86
 * A?adida la treetable con los check box para seleccionar los atributos
87
 *
88
 * Revision 1.2  2006/10/24 07:58:14  jorpiell
89
 * Eliminado el parametro booleano que hac?a que apareciesen mas de una columna en el tree table
90
 *
91
 * Revision 1.1  2006/10/24 07:27:56  jorpiell
92
 * Algunos cambios en el modelo que usa la tabla
93
 *
94
 * Revision 1.2  2006/10/23 08:17:18  jorpiell
95
 * Algunos cambios realizados para tener un ?rbol com m?s de una ra?z
96
 *
97
 * Revision 1.1  2006/10/23 07:37:04  jorpiell
98
 * Ya funciona el filterEncoding
99
 *
100
 *
101
 */
102
/**
103
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
104
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
105
 */
106
public class FieldsTreeTableModel extends AbstractTreeTableModel {
107
	private boolean showGeometry;	
108
	private String[]  cNames = {PluginServices.getText(this,"attributeName"),
109
			PluginServices.getText(this,"attributeType")};
110
	private Class[]  cTypes = {TreeTableModel.class,String.class};
111
			
112
	public FieldsTreeTableModel(Object root) { 
113
		super(root);
114
		showGeometry = true;
115
	}
116
	
117
	public FieldsTreeTableModel(Object root, boolean show_Geometry) { 
118
		super(root);
119
		showGeometry = show_Geometry;
120
	}
121
	
122
	public FieldsTreeTableModel() { 
123
		super(null);
124
		showGeometry = true;
125
	}
126
	
127
	public boolean getShowGeometry() {
128
		return showGeometry;
129
	}
130
	
131
	//
132
	// The TreeModel interface
133
	//
134
	
135
	public int getChildCount(Object node) { 
136
		XMLElement element = (XMLElement)node;			
137
		if (element.getEntityType().getType() == IXMLType.COMPLEX){
138

  
139
			// It's supposed that geometry is on level 1
140
			Vector fields = ((XMLComplexType)element.getEntityType()).getAttributes();
141
			int size = fields.size();
142
			
143
			if (!showGeometry) {
144
				for (int i = 0; i < fields.size(); i++) {
145
					if ((((XMLElement)fields.get(i)).getEntityType() == null) || (((XMLElement)fields.get(i)).getEntityType().getType() == IXMLType.GML_GEOMETRY))
146
						size --;
147
				}
148
			}
149
			
150
			return size;
151
		}else{
152
			return 0;
153
		}
154
	}
155
	
156
	public Object getChild(Object node, int i) { 
157
		XMLElement element = (XMLElement)node;			
158
		if (element.getEntityType().getType() == IXMLType.COMPLEX){
159
			Vector fields = ((XMLComplexType)element.getEntityType()).getAttributes();
160
			XMLElement child = null;
161
			int k = -1;
162
			
163
			if (!showGeometry) {
164
				for (int j = 0; j < fields.size(); j++) {
165
					child = (XMLElement) fields.get(j);
166

  
167
					if ((child.getEntityType() == null) || (child.getEntityType().getType() != IXMLType.GML_GEOMETRY))
168
						k++;					
169
					
170
					if (i == k)
171
						break;
172
				}	
173
			}
174
			else {
175
				child = (XMLElement) fields.get(i);
176
			}
177
			
178
			child.setParentElement(element);
179
			
180
			return child;
181
		}
182
		return null;
183
	}
184
	
185
	// The superclass's implementation would work, but this is more efficient. 
186
	public boolean isLeaf(Object node) { 
187
		if (node == null){
188
			return true;
189
		}
190
		XMLElement element = (XMLElement)node;	
191
		if (element.getEntityType() != null){
192
			if (element.getEntityType().getType() == IXMLType.COMPLEX){
193
				return false;
194
			}
195
		}
196
		return true;
197
	}
198

  
199
	/*
200
	 *  (non-Javadoc)
201
	 * @see org.gvsig.gui.beans.swing.treeTable.TreeTableModel#getColumnCount()
202
	 */
203
	public int getColumnCount() {
204
		return cNames.length;
205
	}
206
	
207
	/*
208
	 *  (non-Javadoc)
209
	 * @see org.gvsig.gui.beans.swing.treeTable.TreeTableModel#getColumnName(int)
210
	 */
211
	public String getColumnName(int column) {
212
		return cNames[column];
213
	}
214
	
215
	/*
216
	 *  (non-Javadoc)
217
	 * @see org.gvsig.gui.beans.swing.treeTable.TreeTableModel#getColumnClass(int)
218
	 */
219
	public Class getColumnClass(int column) {
220
		return cTypes[column];
221
	}
222
	
223
	/*
224
	 *  (non-Javadoc)
225
	 * @see org.gvsig.gui.beans.swing.treeTable.TreeTableModel#getValueAt(java.lang.Object, int)
226
	 */
227
	public Object getValueAt(Object node, int column) {
228
		XMLElement element = (XMLElement)node;	
229
		try {
230
			switch(column) {
231
			case 0:
232
				return element.getName();
233
			case 1:
234
				return PluginServices.getText(this,WFSUtils.getFieldType(element.getEntityType()));
235
			}
236
		}
237
		catch  (SecurityException se) { }
238
		
239
		return null; 
240
	}
241
	
242
	/**
243
	 * Returns leafs from a node branch
244
	 * 
245
	 * @param node A node in this tree model
246
	 * @return A vector with leafs
247
	 */
248
	public Vector<Object> getLeafsFromNodeBranch(Object node) {
249
		Vector<Object> leafs = new Vector<Object>();
250
		Object parent;
251
		
252
		if (this.isLeaf(node))
253
			leafs.add( ((XMLElement)node).getName() );
254
		else {
255
			int childrenCount = this.getChildCount(node);
256
			parent = node;
257
			
258
			for (int i = 0; i < childrenCount; i ++) {
259
				node = this.getChild(parent, i);
260
				
261
				if ( (this.isLeaf(node)) && (! leafs.contains(node)) )
262
					leafs.add(node);
263
				else
264
					leafs.addAll(getLeafsFromNodeBranch(node));
265
			}
266
		}
267
		
268
		return leafs;
269
	}
270
}
0 271

  
trunk/extensions/extWFS2/src/com/iver/cit/gvsig/gui/panels/fieldstree/TreeTableModelWithCheckBoxes.java
1
package com.iver.cit.gvsig.gui.panels.fieldstree;
2

  
3
import org.gvsig.remoteClient.gml.schemas.XMLElement;
4

  
5
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
6
 *
7
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
8
 *
9
 * This program is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU General Public License
11
 * as published by the Free Software Foundation; either version 2
12
 * of the License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program; if not, write to the Free Software
21
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
22
 *
23
 * For more information, contact:
24
 *
25
 *  Generalitat Valenciana
26
 *   Conselleria d'Infraestructures i Transport
27
 *   Av. Blasco Ib??ez, 50
28
 *   46010 VALENCIA
29
 *   SPAIN
30
 *
31
 *      +34 963862235
32
 *   gvsig@gva.es
33
 *      www.gvsig.gva.es
34
 *
35
 *    or
36
 *
37
 *   IVER T.I. S.A
38
 *   Salamanca 50
39
 *   46005 Valencia
40
 *   Spain
41
 *
42
 *   +34 963163400
43
 *   dac@iver.es
44
 */
45
/* CVS MESSAGES:
46
 *
47
 * $Id$
48
 * $Log$
49
 * Revision 1.1  2006-12-26 09:12:48  ppiqueras
50
 * 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).
51
 *
52
 * Revision 1.2  2006/11/01 17:29:07  jorpiell
53
 * Se ha elimiado el nodo virtual de la raiz. Adem?s ya se cargan los valores de un campo complejo en la pesta?a del filtro
54
 *
55
 * Revision 1.1  2006/10/27 11:33:19  jorpiell
56
 * A?adida la treetable con los check box para seleccionar los atributos
57
 *
58
 *
59
 */
60
/**
61
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
62
 */
63
public class TreeTableModelWithCheckBoxes extends FieldsTreeTableModel{
64

  
65
	public TreeTableModelWithCheckBoxes() {
66
		super();
67
	}
68

  
69
	public TreeTableModelWithCheckBoxes(Object root) {
70
		super(generateCheckBoxNodes(root));		
71
	}
72
	
73
	/*
74
	 *  (non-Javadoc)
75
	 * @see javax.swing.tree.TreeModel#isLeaf(java.lang.Object)
76
	 */ 
77
	public boolean isLeaf(Object node) { 
78
		CheckBoxNode leaf = (CheckBoxNode)node;	
79
		return super.isLeaf(leaf.getElement());
80
	}
81
	
82
	/*
83
	 *  (non-Javadoc)
84
	 * @see javax.swing.tree.TreeModel#getChildCount(java.lang.Object)
85
	 */
86
	public int getChildCount(Object node) { 
87
		CheckBoxNode leaf = (CheckBoxNode)node;	
88
		return super.getChildCount(leaf.getElement());
89
	}
90
	
91
	/*
92
	 *  (non-Javadoc)
93
	 * @see javax.swing.tree.TreeModel#getChild(java.lang.Object, int)
94
	 */
95
	public Object getChild(Object node, int i) { 
96
		CheckBoxNode leaf = (CheckBoxNode)node;	
97
		if (leaf.getChildren().size() > 0){
98
			return leaf.getChildren().get(i);
99
		}
100
		return null;
101
	}
102
	
103
	/*
104
	 *  (non-Javadoc)
105
	 * @see org.gvsig.gui.beans.swing.treeTable.TreeTableModel#getValueAt(java.lang.Object, int)
106
	 */
107
	public Object getValueAt(Object node, int column) {
108
		CheckBoxNode leaf = (CheckBoxNode)node;	
109
		return super.getValueAt(leaf.getElement(),column);
110
	}
111
	
112
	public static Object generateCheckBoxNodes(Object root){
113
		Object newRoot = new CheckBoxNode((XMLElement)root,null);
114
		return newRoot;
115
	}	
116
	
117
}
0 118

  
trunk/extensions/extWFS2/src/com/iver/cit/gvsig/gui/panels/fieldstree/TetraStateCheckBox.java
1
package com.iver.cit.gvsig.gui.panels.fieldstree;
2

  
3
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
4
 *
5
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
6
 *
7
 * This program is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU General Public License
9
 * as published by the Free Software Foundation; either version 2
10
 * of the License, or (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 * GNU General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License
18
 * along with this program; if not, write to the Free Software
19
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
20
 *
21
 * For more information, contact:
22
 *
23
 *  Generalitat Valenciana
24
 *   Conselleria d'Infraestructures i Transport
25
 *   Av. Blasco Ib??ez, 50
26
 *   46010 VALENCIA
27
 *   SPAIN
28
 *
29
 *      +34 963862235
30
 *   gvsig@gva.es
31
 *      www.gvsig.gva.es
32
 *
33
 *    or
34
 *
35
 *   IVER T.I. S.A
36
 *   Salamanca 50
37
 *   46005 Valencia
38
 *   Spain
39
 *
40
 *   +34 963163400
41
 *   dac@iver.es
42
 */
43
/* CVS MESSAGES:
44
 *
45
 * $Id$
46
 * $Log$
47
 * Revision 1.1  2006-12-26 09:12:48  ppiqueras
48
 * 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).
49
 *
50
 * Revision 1.1  2006/10/27 11:33:19  jorpiell
51
 * A?adida la treetable con los check box para seleccionar los atributos
52
 *
53
 *
54
 */
55
/**
56
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
57
 */
58
import java.awt.event.ActionListener;
59
import java.awt.event.ItemListener;
60

  
61
import javax.swing.ButtonGroup;
62
import javax.swing.ButtonModel;
63
import javax.swing.Icon;
64
import javax.swing.JCheckBox;
65
import javax.swing.event.ChangeListener;
66

  
67
public class TetraStateCheckBox extends JCheckBox {
68
	public static final int WHITE = 0;
69
	public static final int GREY = 1;
70

  
71
	private final TetraStateDecorator model;
72

  
73
	public TetraStateCheckBox(String text, Icon icon, int color) {
74
		super(text, icon);
75
		model = new TetraStateDecorator(getModel());
76
		setModel(model);
77
	}
78

  
79
	public TetraStateCheckBox(String text){
80
		this(text,null,WHITE);
81
	}
82
	
83
	public TetraStateCheckBox() {
84
		this(null, null, WHITE);
85
	}
86

  
87
	/**
88
	 * Set the new state to either SELECTED, NOT_SELECTED or DONT_CARE. If state ==
89
	 * null, it is treated as DONT_CARE.
90
	 */
91
	public void setColor(int color) {
92
		model.setColor(color, isSelected());
93
	}
94

  
95
	/**
96
	 * Return the current state, which is determined by the selection status of
97
	 * the model.
98
	 */
99
	public int getColor() {
100
		return model.getColor();
101
	}
102

  
103
	/**
104
	 * Exactly which Design Pattern is this? Is it an Adapter, a Proxy or a
105
	 * Decorator? In this case, my vote lies with the Decorator, because we are
106
	 * extending functionality and "decorating" the original model with a more
107
	 * powerful model.
108
	 */
109
	private class TetraStateDecorator implements ButtonModel {
110
		private final ButtonModel other;
111

  
112
		private TetraStateDecorator(ButtonModel other) {
113
			this.other = other;
114
		}
115

  
116
		private void setColor(int color, boolean isSelected) {
117
			if (color == WHITE) {
118
				other.setArmed(false);
119
				setPressed(false);
120
				setSelected(isSelected);
121
			} else {
122
				other.setArmed(true);
123
				setPressed(true);
124
				setSelected(isSelected);
125
			}
126
		}
127

  
128
		/**
129
		 * The current state is embedded in the selection / armed state of the
130
		 * model.
131
		 * 
132
		 * We return the SELECTED state when the checkbox is selected but not
133
		 * armed, DONT_CARE state when the checkbox is selected and armed (grey)
134
		 * and NOT_SELECTED when the checkbox is deselected.
135
		 */
136
		private int getColor() {
137
			if (!isArmed()) {
138
				return GREY;
139
			} else {
140
				return WHITE;
141
			}
142
		}
143

  
144
		/** Filter: No one may change the armed status except us. */
145
		public void setArmed(boolean b) {
146
		}
147

  
148
		/**
149
		 * We disable focusing on the component when it is not enabled.
150
		 */
151
		public void setEnabled(boolean b) {
152
			setFocusable(b);
153
			other.setEnabled(b);
154
		}
155

  
156
		public boolean isArmed() {
157
			return other.isArmed();
158
		}
159

  
160
		public boolean isSelected() {
161
			return other.isSelected();
162
		}
163

  
164
		public boolean isEnabled() {
165
			return other.isEnabled();
166
		}
167

  
168
		public boolean isPressed() {
169
			return other.isPressed();
170
		}
171

  
172
		public boolean isRollover() {
173
			return other.isRollover();
174
		}
175

  
176
		public void setSelected(boolean b) {
177
			other.setSelected(b);
178
		}
179

  
180
		public void setPressed(boolean b) {
181
			other.setPressed(b);
182
		}
183

  
184
		public void setRollover(boolean b) {
185
			other.setRollover(b);
186
		}
187

  
188
		public void setMnemonic(int key) {
189
			other.setMnemonic(key);
190
		}
191

  
192
		public int getMnemonic() {
193
			return other.getMnemonic();
194
		}
195

  
196
		public void setActionCommand(String s) {
197
			other.setActionCommand(s);
198
		}
199

  
200
		public String getActionCommand() {
201
			return other.getActionCommand();
202
		}
203

  
204
		public void setGroup(ButtonGroup group) {
205
			other.setGroup(group);
206
		}
207

  
208
		public void addActionListener(ActionListener l) {
209
			other.addActionListener(l);
210
		}
211

  
212
		public void removeActionListener(ActionListener l) {
213
			other.removeActionListener(l);
214
		}
215

  
216
		public void addItemListener(ItemListener l) {
217
			other.addItemListener(l);
218
		}
219

  
220
		public void removeItemListener(ItemListener l) {
221
			other.removeItemListener(l);
222
		}
223

  
224
		public void addChangeListener(ChangeListener l) {
225
			other.addChangeListener(l);
226
		}
227

  
228
		public void removeChangeListener(ChangeListener l) {
229
			other.removeChangeListener(l);
230
		}
231

  
232
		public Object[] getSelectedObjects() {
233
			return other.getSelectedObjects();
234
		}
235
	}
236
}
0 237

  
trunk/extensions/extWFS2/src/com/iver/cit/gvsig/gui/panels/fieldstree/CheckBoxNode.java
1
package com.iver.cit.gvsig.gui.panels.fieldstree;
2

  
3
import java.awt.Color;
4
import java.util.Vector;
5

  
6
import org.gvsig.remoteClient.gml.schemas.XMLElement;
7
import org.gvsig.remoteClient.gml.types.IXMLType;
8
import org.gvsig.remoteClient.gml.types.XMLComplexType;
9

  
10

  
11

  
12
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
13
 *
14
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
15
 *
16
 * This program is free software; you can redistribute it and/or
17
 * modify it under the terms of the GNU General Public License
18
 * as published by the Free Software Foundation; either version 2
19
 * of the License, or (at your option) any later version.
20
 *
21
 * This program is distributed in the hope that it will be useful,
22
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
 * GNU General Public License for more details.
25
 *
26
 * You should have received a copy of the GNU General Public License
27
 * along with this program; if not, write to the Free Software
28
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
29
 *
30
 * For more information, contact:
31
 *
32
 *  Generalitat Valenciana
33
 *   Conselleria d'Infraestructures i Transport
34
 *   Av. Blasco Ib??ez, 50
35
 *   46010 VALENCIA
36
 *   SPAIN
37
 *
38
 *      +34 963862235
39
 *   gvsig@gva.es
40
 *      www.gvsig.gva.es
41
 *
42
 *    or
43
 *
44
 *   IVER T.I. S.A
45
 *   Salamanca 50
46
 *   46005 Valencia
47
 *   Spain
48
 *
49
 *   +34 963163400
50
 *   dac@iver.es
51
 */
52
/* CVS MESSAGES:
53
 *
54
 * $Id$
55
 * $Log$
56
 * Revision 1.3  2007-09-19 16:14:50  jaume
57
 * removed unnecessary imports
58
 *
59
 * Revision 1.2  2006/12/26 10:25:37  ppiqueras
60
 * Corregidas las dependencias con las nuevas ubicaciones de clases: IXMLType, XMLElement, IXMLComplexType, etc. (en libRemoteServices)
61
 *
62
 * Revision 1.1  2006/12/26 09:12:48  ppiqueras
63
 * 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).
64
 *
65
 * Revision 1.2  2006/10/31 12:24:04  jorpiell
66
 * Comprobado el caso en el que los atributos no tienen tipo
67
 *
68
 * Revision 1.1  2006/10/27 11:33:19  jorpiell
69
 * A?adida la treetable con los check box para seleccionar los atributos
70
 *
71
 *
72
 */
73
/**
74
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
75
 */
76
public class CheckBoxNode extends TetraStateCheckBox{
77
	private XMLElement element = null;	
78
	private CheckBoxNode parent = null;
79
	private Vector children = new Vector();	
80
	
81
	public CheckBoxNode(XMLElement element,CheckBoxNode parent){
82
		super();
83
		this.parent = parent;
84
		initialize(element);
85
	}
86
	
87
	private void initialize(XMLElement element){		
88
		this.setBackground(Color.WHITE);
89
		this.setText(fillNameWithBlancs(element.getName()));
90
		this.element = element;
91
		if (element.getEntityType() != null){
92
			if (element.getEntityType().getType() == IXMLType.COMPLEX){
93
				Vector subElements = ((XMLComplexType)element.getEntityType()).getAttributes();
94
				for (int i=0 ; i<subElements.size() ; i++){
95
					XMLElement child = (XMLElement)subElements.get(i);
96
					children.add(new CheckBoxNode(child,this));					
97
				}
98
			}else if(element.getEntityType().getType() == IXMLType.GML_GEOMETRY){
99
				this.setSelected(true);			
100
			}
101
		}
102
	}
103
	
104
	/**
105
	 * Return the max size for the combo labels
106
	 * @return
107
	 */
108
	public static int getTextLength(){
109
		return 200;
110
	}
111
	
112
	/**
113
	 * Fill the string with blancs
114
	 * @param name
115
	 * @return
116
	 */
117
	public static String fillNameWithBlancs(String name){
118
		String withBlancs = name;
119
		for (int i=name.length() ; i<getTextLength() ; i++){
120
			name = name + " ";
121
		}
122
		return name;
123
	}
124
	
125
	/**
126
	 * @return Returns the element.
127
	 */
128
	public XMLElement getElement() {
129
		return element;
130
	}
131
	
132
	/**
133
	 * @return Returns the children.
134
	 */
135
	public Vector getChildren() {
136
		return children;
137
	}
138
	
139
	public String toString(){
140
		return getElement().getName();
141
	}
142
	
143
	/**
144
	 * @return Returns the parent.
145
	 */
146
	public CheckBoxNode getParentNode() {
147
		return parent;
148
	}
149
}
150
//public class CheckBoxNode extends JPanel{
151
//private XMLElement element = null;	
152
//private CheckBoxNode parent = null;
153
//private Vector children = new Vector();	
154
//private TetraStateCheckBox checkBox = null;
155
//
156
//public CheckBoxNode(XMLElement element,CheckBoxNode parent){
157
//super();
158
//this.parent = parent;
159
//initialize(element);
160
//}
161
//
162
//private void initialize(XMLElement element){	
163
//this.setSize(new Dimension(300,400));
164
//checkBox = new TetraStateCheckBox();
165
//this.add(checkBox);		
166
//this.add(new JLabel(element.getName()));
167
//this.setBackground(Color.BLUE);		
168
//this.element = element;
169
//if (element.getEntityType().getType() == IXMLType.COMPLEX){
170
//Vector subElements = ((XMLComplexType)element.getEntityType()).getAttributes();
171
//for (int i=0 ; i<subElements.size() ; i++){
172
//XMLElement child = (XMLElement)subElements.get(i);
173
//children.add(new CheckBoxNode(child,this));					
174
//}
175
//}
176
//}
177
//
178
//public boolean isSelected(){
179
//return checkBox.isSelected();
180
//}
181
//
182
//public void setSelected(boolean selected){
183
//checkBox.setSelected(selected);
184
//}
185
//
186
//public void setColor(int color){
187
//checkBox.setColor(color);
188
//}
189
//
190
///**
191
//* @return Returns the element.
192
//*/
193
//public XMLElement getElement() {
194
//return element;
195
//}
196
//
197
///**
198
//* @return Returns the children.
199
//*/
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff