Revision 9457

View differences:

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.BorderLayout;
4
import java.awt.Color;
5
import java.awt.Dimension;
6
import java.awt.FlowLayout;
7
import java.util.Vector;
8

  
9
import javax.swing.BoxLayout;
10
import javax.swing.JCheckBox;
11
import javax.swing.JLabel;
12
import javax.swing.JPanel;
13

  
14
import org.gvsig.remoteClient.gml.schemas.IXMLType;
15
import org.gvsig.remoteClient.gml.schemas.XMLComplexType;
16
import org.gvsig.remoteClient.gml.schemas.XMLElement;
17

  
18

  
19

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

  
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.schemas.IXMLType;
15

  
16
import com.iver.utiles.XMLEntity;
17

  
18
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
19
 *
20
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
21
 *
22
 * This program is free software; you can redistribute it and/or
23
 * modify it under the terms of the GNU General Public License
24
 * as published by the Free Software Foundation; either version 2
25
 * of the License, or (at your option) any later version.
26
 *
27
 * This program is distributed in the hope that it will be useful,
28
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
30
 * GNU General Public License for more details.
31
 *
32
 * You should have received a copy of the GNU General Public License
33
 * along with this program; if not, write to the Free Software
34
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
35
 *
36
 * For more information, contact:
37
 *
38
 *  Generalitat Valenciana
39
 *   Conselleria d'Infraestructures i Transport
40
 *   Av. Blasco Ib??ez, 50
41
 *   46010 VALENCIA
42
 *   SPAIN
43
 *
44
 *      +34 963862235
45
 *   gvsig@gva.es
46
 *      www.gvsig.gva.es
47
 *
48
 *    or
49
 *
50
 *   IVER T.I. S.A
51
 *   Salamanca 50
52
 *   46005 Valencia
53
 *   Spain
54
 *
55
 *   +34 963163400
56
 *   dac@iver.es
57
 */
58
/* CVS MESSAGES:
59
 *
60
 * $Id$
61
 * $Log$
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 CheckBoxTreeCellEditor extends AbstractCellEditor implements TreeCellEditor {
77
	CheckBoxTreeCellRenderer renderer = null;
78
	ChangeEvent changeEvent = null;
79
	JTree tree;
80
	FieldsTreeTable treetable;
81
	
82
	public CheckBoxTreeCellEditor(FieldsTreeTable treetable) {
83
		this.treetable = treetable;
84
		this.tree = (JTree)treetable.getTree();
85
		this.renderer = new CheckBoxTreeCellRenderer(treetable);
86
	}	
87
	
88
	/*
89
	 *  (non-Javadoc)
90
	 * @see javax.swing.CellEditor#getCellEditorValue()
91
	 */
92
	public Object getCellEditorValue() {
93
		return null;
94
	}
95
	
96
	/*
97
	 *  (non-Javadoc)
98
	 * @see javax.swing.CellEditor#isCellEditable(java.util.EventObject)
99
	 */
100
	public boolean isCellEditable(EventObject event) {
101
		if (event instanceof MouseEvent) {
102
			MouseEvent mouseEvent = (MouseEvent) event;
103
			TreePath path = tree.getPathForLocation(mouseEvent.getX(),
104
					mouseEvent.getY());
105
			if (path != null) {
106
				Object node = path.getLastPathComponent();
107
				if ((node != null) && (node instanceof CheckBoxNode)) {
108
					CheckBoxNode selectedNode = (CheckBoxNode)node;
109
					if (mouseEvent.getClickCount() == 2){
110
						
111
					}else if(mouseEvent.getClickCount() == 1){
112
						changeAllChildren(selectedNode,!selectedNode.isSelected());
113
						changeParentState(selectedNode,!selectedNode.isSelected());
114
						tree.repaint();
115
					}
116
				}
117
			}
118
		}
119
		return false;
120
	}
121
	
122
	/*
123
	 *  (non-Javadoc)
124
	 * @see javax.swing.tree.TreeCellEditor#getTreeCellEditorComponent(javax.swing.JTree, java.lang.Object, boolean, boolean, boolean, int)
125
	 */
126
	public Component getTreeCellEditorComponent(JTree tree, Object value,
127
			boolean selected, boolean expanded, boolean leaf, int row) {
128
		Component editor = renderer.getTreeCellRendererComponent(tree, value,
129
				true, expanded, leaf, row, true);
130
		
131
		if (editor instanceof JCheckBox) {
132
			//((JCheckBox) editor).addItemListener(new CheckBoxListener());
133
		}		
134
		return editor;
135
	}	
136
	
137
	/**
138
	 * It enable or disable the parent node state depending of its children values
139
	 * @param selectedNode
140
	 * Selected node
141
	 * @param isSelected
142
	 * Current node status
143
	 */
144
	private void changeParentState(CheckBoxNode selectedNode,boolean isSelected){
145
		CheckBoxNode parent = selectedNode.getParentNode();
146
		while (parent != null){			
147
			if (isSelected != parent.isSelected()){
148
				parent.setColor(TetraStateCheckBox.GREY);
149
			}else{	
150
				boolean isEnabled = true;
151
				for (int i=0 ; i<parent.getChildren().size() ; i++){
152
					CheckBoxNode child = (CheckBoxNode)parent.getChildren().get(i);
153
					if (child != selectedNode){
154
						if (parent.isSelected() != child.isSelected()){
155
							isEnabled = false;
156
						}
157
					}
158
				}
159
				if (!isEnabled){
160
					parent.setColor(TetraStateCheckBox.GREY);
161
				}else{
162
					parent.setColor(TetraStateCheckBox.WHITE);
163
				}					
164
				
165
			}			
166
			selectedNode = parent;
167
			parent = selectedNode.getParentNode();			
168
		}
169
	}
170
	
171
	
172
	/**
173
	 * It changes all the children status
174
	 * @param selectedNode
175
	 * Root node
176
	 * @param selected
177
	 * New state
178
	 */
179
	private void changeAllChildren(CheckBoxNode selectedNode,boolean selected){
180
		for (int i=0 ; i<selectedNode.getChildren().size() ; i++){
181
			CheckBoxNode child = ((CheckBoxNode)selectedNode.getChildren().get(i));
182
			if ((child.getElement().getEntityType() == null) || 
183
					(child.getElement().getEntityType().getType() != IXMLType.GML_GEOMETRY)){
184
				child.setSelected(selected);	
185
			}
186
			if (child.getChildren().size() > 0){
187
				changeAllChildren(child,selected);
188
			}			
189
		}
190
	}
191
}
0 192

  
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
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$
59
 * $Log$
60
 * Revision 1.1  2006-12-26 09:12:48  ppiqueras
61
 * 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).
62
 *
63
 * Revision 1.3  2006/10/31 12:24:04  jorpiell
64
 * Comprobado el caso en el que los atributos no tienen tipo
65
 *
66
 * Revision 1.2  2006/10/31 09:39:44  jorpiell
67
 * Se devuelve el tipo de la entidad completo, y no sus hijos
68
 *
69
 * Revision 1.1  2006/10/27 11:33:19  jorpiell
70
 * A?adida la treetable con los check box para seleccionar los atributos
71
 *
72
 *
73
 */
74
/**
75
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
76
 */
77
public class CheckBoxTreeCellRenderer extends DefaultTreeCellRenderer{ 
78
	private JTree tree;
79
	private FieldsTreeTable treetable;
80
	
81
	public CheckBoxTreeCellRenderer(FieldsTreeTable treetable) {
82
		this.treetable = treetable;
83
		this.tree = (JTree)treetable.getTree();
84
	}
85
	
86
	/*
87
	 *  (non-Javadoc)
88
	 * @see javax.swing.tree.TreeCellRenderer#getTreeCellRendererComponent(javax.swing.JTree, java.lang.Object, boolean, boolean, boolean, int, boolean)
89
	 */
90
	public Component getTreeCellRendererComponent(JTree tree, Object value,
91
			boolean selected, boolean expanded, boolean leaf, int row,
92
			boolean hasFocus) {
93
			int[] rows = tree.getSelectionRows();
94
			TreePath path = tree.getPathForRow(row);
95
			if (path != null){
96
				Object node = path.getLastPathComponent();
97
				if ((node != null) && (node instanceof CheckBoxNode)){
98
					CheckBoxNode selectedNode = (CheckBoxNode)node;
99
					if (selectedNode.getParent() == null){
100
						tree.expandRow(0);
101
					}
102
					if (selected){
103
						selectedNode.setBackground(UIManager.getColor("Tree.selectionBackground"));
104
						if (hasFocus){
105
							if ((selectedNode.getElement().getEntityType() == null) || 
106
								!(selectedNode.getElement().getEntityType().getType() == IXMLType.GML_GEOMETRY)){
107
								treetable.setUpdated(true);
108
								selectedNode.setSelected(!selectedNode.isSelected());
109
								selectedNode.setColor(TetraStateCheckBox.WHITE);
110
							}
111
						}
112
					}else{
113
						selectedNode.setBackground(UIManager.getColor("Tree.textBackground"));
114
					}					
115
					return selectedNode;
116
				}
117
			}	
118
			JLabel label = new JLabel(CheckBoxNode.fillNameWithBlancs("Feature"));
119
		return label;
120
	}	
121

  
122
	
123
}
0 124

  
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.JTree;
7
import javax.swing.tree.TreePath;
8

  
9
import org.gvsig.gui.beans.swing.treeTable.TreeTableModelAdapter;
10
import org.gvsig.remoteClient.gml.schemas.XMLElement;
11

  
12
import com.iver.cit.gvsig.gui.panels.WFSSelectFieldsPanel;
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.1  2006-12-26 09:12:48  ppiqueras
59
 * 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).
60
 *
61
 * Revision 1.5  2006/11/15 17:37:39  jorpiell
62
 * Se copia el padre
63
 *
64
 * Revision 1.4  2006/11/10 13:14:47  ppiqueras
65
 * Corregido un bug: caos que haya campos de una feature de una capa WFS, que no tengan tipo (tipo == null).
66
 *
67
 * Revision 1.3  2006/11/01 17:29:07  jorpiell
68
 * 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
69
 *
70
 * Revision 1.2  2006/10/31 09:39:44  jorpiell
71
 * Se devuelve el tipo de la entidad completo, y no sus hijos
72
 *
73
 * Revision 1.1  2006/10/27 11:33:19  jorpiell
74
 * A?adida la treetable con los check box para seleccionar los atributos
75
 *
76
 * Revision 1.3  2006/10/24 10:13:19  jorpiell
77
 * Se ha eliminado la pesta?a de filter
78
 *
79
 * Revision 1.2  2006/10/24 07:58:14  jorpiell
80
 * Eliminado el parametro booleano que hac?a que apareciesen mas de una columna en el tree table
81
 *
82
 * Revision 1.1  2006/10/24 07:27:56  jorpiell
83
 * Algunos cambios en el modelo que usa la tabla
84
 *
85
 *
86
 */
87
/**
88
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
89
 */
90
public class FieldsTreeTable extends org.gvsig.gui.beans.swing.treeTable.TreeTable{
91
	Object[] fields = null;
92
	WFSSelectFieldsPanel parent = null;
93
	
94
	public FieldsTreeTable(FieldsTreeTableModel treeTableModel) {
95
		super(treeTableModel);
96
		JTree tree = (JTree)getTree();
97
		tree.setCellRenderer(new CheckBoxTreeCellRenderer(this));
98
		tree.setCellEditor(new CheckBoxTreeCellEditor(this));
99
		tree.setEditable(true);		
100
	}
101
	
102
	public FieldsTreeTable(FieldsTreeTableModel treeTableModel,WFSSelectFieldsPanel parent) {
103
		super(treeTableModel);
104
		this.parent = parent;
105
		JTree tree = (JTree)getTree();
106
		tree.setCellRenderer(new CheckBoxTreeCellRenderer(this));
107
		tree.setCellEditor(new CheckBoxTreeCellEditor(this));
108
		tree.setEditable(true);
109
	}
110
	
111
	/**
112
	 * Sets the fields
113
	 * @param fields
114
	 */
115
	public void setFields(Vector vFields){
116
		fields = new Object[vFields.size()];
117
		for (int i=0 ; i<vFields.size() ; i++){
118
			fields[i] = vFields.get(i);
119
		}
120
		setModel(new FieldsTreeTableModel(fields));
121
		deleteIcons();
122
		setRootVisible(false);
123
	}
124
	
125
	/**
126
	 * Gets the selected layer
127
	 * @return
128
	 */
129
	public Object[] getSelectedValues(){
130
		int[] selectedRows = getSelectedRows();
131
		TreeTableModelAdapter obj = (TreeTableModelAdapter)getModel();
132
		Object[] objects = new Object[selectedRows.length];
133
		for (int i=0 ; i<selectedRows.length ; i++){
134
			objects[i] = obj.nodeForRow(selectedRows[i]);
135
		}
136
		return objects;
137
	}
138
	
139
	/**
140
	 * return the selected elements
141
	 * @return
142
	 */
143
	public XMLElement[] getSelectedElements(){
144
		TreeTableModelAdapter obj = (TreeTableModelAdapter)getModel();
145
		ArrayList elements = new ArrayList();
146
		for (int i=0 ; i< obj.getRowCount() ; i++){
147
			if (obj.nodeForRow(i) instanceof CheckBoxNode){
148
				CheckBoxNode node = (CheckBoxNode)obj.nodeForRow(i);
149
				if (node.isSelected()){
150
					XMLElement element = node.getElement();
151
					CheckBoxNode parentNode = node.getParentNode();
152
					if (parentNode != null){
153
						element.setParentElement(parentNode.getElement());
154
					}
155
					elements.add(element);
156
				}					
157
			}
158
		}
159
	
160
	XMLElement[] selected = new XMLElement[elements.size()];
161
	for (int i=0 ; i<elements.size() ; i++){
162
		selected[i] = (XMLElement)elements.get(i);
163
	}
164
	return selected;
165
}
166

  
167
/**
168
 * Return all the fields
169
 * @return
170
 */
171
public Object[] getAllValues() {
172
	return fields;
173
}
174

  
175
/**
176
 * Return true if the node is queryable
177
 * @param node
178
 * @return
179
 */
180
public boolean isQueryable(Object node){
181
	for (int i=0 ; i<fields.length ; i++){
182
		if (node.equals(fields[i])){
183
			return true;
184
		}
185
	}
186
	return false;
187
}
188

  
189
public void setModel(FieldsTreeTableModel treeTableModel){
190
	super.setModel(treeTableModel);
191
	JTree tree = (JTree)getTree();
192
	tree.setCellRenderer(new CheckBoxTreeCellRenderer(this));
193
	tree.setCellEditor(new CheckBoxTreeCellEditor(this));
194
	tree.setEditable(true);		
195
}
196

  
197
/**
198
 * Set the selected fields
199
 * @param selectedFields
200
 */
201
public void setSelectedFields(Vector selectedFields) {
202
	TreeTableModelAdapter obj = (TreeTableModelAdapter)getModel();
203
	JTree tree = (JTree)getTree();
204
	for (int i = 0; i < tree.getRowCount(); i++) {
205
		tree.expandRow(i);
206
	}	
207
	for (int i=0 ; i<obj.getRowCount() ; i++){
208
		if (obj.nodeForRow(i) instanceof CheckBoxNode){
209
			XMLElement element = ((CheckBoxNode)obj.nodeForRow(i)).getElement();
210
			for (int j=0 ; j<selectedFields.size() ; j++){
211
				//If the name is equals
212
				if (((XMLElement)selectedFields.get(j)).getName().equals(element.getName())){
213
					//If the type is equals					
214
					if ( (element.getEntityType() != null) && (((XMLElement)selectedFields.get(j)).getEntityType() != null) && (((XMLElement)selectedFields.get(j)).getEntityType().getName().equals(element.getEntityType().getName())) ){
215
						((CheckBoxNode)obj.nodeForRow(i)).setSelected(true);
216
					}
217
				}
218
			}
219
		}			
220
	}
221
	
222
}
223

  
224
/**
225
 * @param updated The updated to set.
226
 */
227
public void setUpdated(boolean updated) {
228
	if (parent != null){
229
		parent.setUpdated(updated);
230
	}
231
}
232

  
233

  
234
}
0 235

  
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.GMLGeometryType;
8
import org.gvsig.remoteClient.gml.schemas.IXMLType;
9
import org.gvsig.remoteClient.gml.schemas.XMLComplexType;
10
import org.gvsig.remoteClient.gml.schemas.XMLElement;
11

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

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

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

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

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

  
266

  
0 267

  
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

  

Also available in: Unified diff