Revision 8705 trunk/extensions/extWFS2/src/com/iver/cit/gvsig/gui/panels/WFSFilterPanel.java

View differences:

WFSFilterPanel.java
5 5
import java.awt.event.KeyListener;
6 6
import java.awt.event.MouseAdapter;
7 7
import java.awt.event.MouseEvent;
8
import java.net.MalformedURLException;
9
import java.net.URL;
8 10
import java.text.NumberFormat;
9 11
import java.text.ParseException;
10 12
import java.util.ArrayList;
......
37 39
import com.hardcode.gdbms.engine.values.BooleanValue;
38 40
import com.hardcode.gdbms.engine.values.ComplexValue;
39 41
import com.hardcode.gdbms.engine.values.NullValue;
42
import com.hardcode.gdbms.engine.values.StringValue;
40 43
import com.hardcode.gdbms.engine.values.Value;
41 44
import com.iver.andami.messages.NotificationManager;
42 45
import com.iver.andami.ui.mdiManager.IWindow;
......
109 112
	private ExceptionHandlingSupport exceptionHandlingSupport = new ExceptionHandlingSupport();
110 113
	private AttributesTreeTableModel attributesTreeTableModel;
111 114
	private boolean panelAsATabForWFSLayersLoad;
115
	private TreePath currentPath;
112 116
	
113 117
	/**
114 118
	 * This method initializes
......
117 121
	public WFSFilterPanel(WFSParamsPanel parent) {
118 122
		super();
119 123
		this.parent = parent;
124
		currentPath = null;
120 125

  
121 126
		// At beginning, the JList is disabled (and its set a particular color for user could knew it)
122 127
		super.getValuesJList().setEnabled(false);
......
180 185

  
181 186
				if (row > -1) {
182 187
					switch (e.getClickCount()) {
183
						case 2:						
188
						case 2:							
184 189
							putSymbolOfSelectedByMouseBranch(treePath);
185 190
							break;
186 191
					}
......
197 202
			public void mouseClicked(MouseEvent e) {
198 203
				if (e.getClickCount() == 2) {
199 204
					Value valor = (Value) valuesListModel.getElementAt(getValuesJList().getSelectedIndex());
200

  
201
					putSymbol(valor.toString());	
205
					
206
					if (getNodeOfCurrentPath().getEntityType().getName().compareTo("xs:string") == 0) {
207
						putSymbol("'" + getFormattedString(valor.toString()) + "'");
208
					}
209
					else
210
						putSymbol(valor.toString());
211
					
202 212
				}
203 213
			}
204 214
		});
......
213 223
		
214 224
					if ((data != null) && (data.getData() != null)) {
215 225
						setModel(data.getData());
216
						fillValuesByPath(e.getPath());
226
						currentPath = e.getPath();
227
						fillValuesByPath(currentPath);
217 228
					}
218 229
				}
219 230
			}
220 231
			
221 232
		});
222 233
	}
234

  
235
	/**
236
	 * Formats an string for be used for the URL parser and SQL parser.
237
	 * (In this moments here are only added needed replacements, it's probably that there would be need more in the future)
238
	 * 
239
	 * @param text An string
240
	 * @return An string
241
	 */
242
	private String getFormattedString(String text) {
243
		// Replace all ' for ''
244
		text = text.replaceAll("\\'", "\\'\\'");
245
		
246
		// Replace all $ for $$
247
		//text = text.replaceAll("\\$'", "\\$\\$");
248
		
249
		// Replace all (white espace) for %20
250
		text = text.replaceAll(" ", "%20");				
251
		
252
		return text;
253
	}
223 254
	
224 255
	/**
225 256
	 * Sets the value of the inner attribute: 'panelAsATabForWFSLayersLoad'
......
389 420
	}
390 421
	
391 422
	/**
423
	 * Gets the element that the 'currentPath' attribute aims
424
	 * 
425
	 * @return An XMLElement
426
	 */
427
	private XMLElement getNodeOfCurrentPath() {
428
		
429
		if (currentPath != null) {
430
			Object node = currentPath.getLastPathComponent();
431
			
432
			if ((node != null) && (node instanceof XMLElement)) {
433
//				XMLElement element = (XMLElement) node;
434
				return (XMLElement) node;
435
			}
436
		}
437
		
438
		return null;
439
	}
440
	
441
	/**
392 442
	 * Gets the query that will be send to the server
393 443
	 * @return
394 444
	 * SQL query (just the where part)
......
742 792
	 */
743 793
	private void setFields(WFSLayerNode feature) {
744 794
		Vector fields = feature.getFields();
745
//		Vector fieldsWithoutGeometry = new Vector(0, 1);
746 795
				
747 796
		this.resetFieldsAndValuesData();
748 797
		
749 798
		int numberOfFields = fields.size();
750 799
		
751 800
		if (numberOfFields > 0) {
752
//			int j = 0;
753 801
			Vector fieldBranches = new Vector(0, 1);
754
//			Vector fieldsClone = (Vector)fields.clone();
755 802
			
756 803
			for (int i=0; i<fields.size(); i++) {
757 804
				XMLElement field = (XMLElement)fields.get(i);
758
				
759
//				XMLElement aaa = (XMLElement)new Object();
760
//				aaa.
761
//								
805

  
762 806
				IXMLType type = field.getEntityType();
763 807
				
764 808
				if (type != null) {					
765 809
					
766 810
					switch (type.getType()) {
767 811
						case IXMLType.GML_GEOMETRY:
768
						//	fields.remove(i);
769 812
							break;
770
						case IXMLType.COMPLEX: // Now it's implemented that the first level is always COMPLEX
771
//							Object field_clone = new Object();
772
//							field_clone = field;
773
							
774
//							// If the complex element has a geometry, don't load this field in the tree
775
//							Object field_copy = new Object();
776
//							field_copy = field;
777
//							
778
//							Map c_fields_map = ((XMLComplexType)((XMLElement)field_copy).getEntityType()).getSubtypes();
779
//							
780
//							Collection c_fields = c_fields_map.values();
781
//							
782
//							Iterator iterator = c_fields.iterator();
783
//							XMLElement element = null;
784
//							
785
//							while(iterator.hasNext()) {
786
//								element = (XMLElement)iterator.next();
787
//								
788
//								if (element.getEntityType().getType() == IXMLType.GML_GEOMETRY) {
789
//									iterator.remove();
790
//								}
791
//							}
792
//							
793
//							fieldBranches.add(field_copy);
794
//							fieldsWithoutGeometry.add(field_clone);
813
						case IXMLType.COMPLEX: case IXMLType.SIMPLE:
795 814
							fieldBranches.add(field);
796
//							j++;
797 815
							break;
798
						case IXMLType.SIMPLE:
799
							fieldBranches.add(field);
800
//							fieldsWithoutGeometry.add(field);
801
//							j++;
802
							break;
803 816
					}
804 817
				}
805 818
			}

Also available in: Unified diff