Statistics
| Revision:

root / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / panels / WFSFilterPanel.java @ 8528

History | View | Annotate | Download (20 KB)

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

    
3
import java.awt.event.MouseAdapter;
4
import java.awt.event.MouseEvent;
5
import java.text.NumberFormat;
6
import java.text.ParseException;
7
import java.util.ArrayList;
8
import java.util.Comparator;
9
import java.util.Iterator;
10
import java.util.TreeSet;
11
import java.util.Vector;
12
import java.util.regex.Matcher;
13
import java.util.regex.Pattern;
14

    
15
import javax.swing.DefaultListModel;
16
import javax.swing.event.DocumentEvent;
17
import javax.swing.event.DocumentListener;
18
import javax.swing.tree.DefaultMutableTreeNode;
19
import javax.swing.tree.DefaultTreeModel;
20
import javax.swing.tree.TreePath;
21

    
22
import org.apache.log4j.Logger;
23
import org.gvsig.gui.beans.filterPanel.filterQueryPanel.FilterQueryJPanel;
24
import org.gvsig.remoteClient.gml.schemas.IXMLType;
25
import org.gvsig.remoteClient.gml.schemas.XMLElement;
26

    
27
import com.hardcode.gdbms.engine.data.driver.DriverException;
28
import com.hardcode.gdbms.engine.instruction.IncompatibleTypesException;
29
import com.hardcode.gdbms.engine.values.BooleanValue;
30
import com.hardcode.gdbms.engine.values.ComplexValue;
31
import com.hardcode.gdbms.engine.values.NullValue;
32
import com.hardcode.gdbms.engine.values.Value;
33
import com.iver.andami.messages.NotificationManager;
34
import com.iver.andami.ui.mdiManager.IWindow;
35
import com.iver.andami.ui.mdiManager.IWindowListener;
36
import com.iver.andami.ui.mdiManager.WindowInfo;
37
import com.iver.cit.gvsig.fmap.layers.WFSLayerNode;
38
import com.iver.cit.gvsig.gui.filter.ExpressionDataSource;
39
import com.iver.cit.gvsig.gui.filter.ExpressionListener;
40
import com.iver.cit.gvsig.gui.filter.FilterException;
41
import com.iver.cit.gvsig.gui.panels.attributesTree.AttributesTreeTableModel;
42
import com.iver.cit.gvsig.project.documents.table.gui.Table;
43
import com.iver.utiles.DefaultCharSet;
44
import com.iver.utiles.StringUtilities;
45
import com.iver.utiles.exceptionHandling.ExceptionHandlingSupport;
46
import com.iver.utiles.exceptionHandling.ExceptionListener;
47

    
48
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
49
 *
50
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
51
 *
52
 * This program is free software; you can redistribute it and/or
53
 * modify it under the terms of the GNU General Public License
54
 * as published by the Free Software Foundation; either version 2
55
 * of the License, or (at your option) any later version.
56
 *
57
 * This program is distributed in the hope that it will be useful,
58
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
59
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
60
 * GNU General Public License for more details.
61
 *
62
 * You should have received a copy of the GNU General Public License
63
 * along with this program; if not, write to the Free Software
64
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
65
 *
66
 * For more information, contact:
67
 *
68
 *  Generalitat Valenciana
69
 *   Conselleria d'Infraestructures i Transport
70
 *   Av. Blasco Ib??ez, 50
71
 *   46010 VALENCIA
72
 *   SPAIN
73
 *
74
 *      +34 963862235
75
 *   gvsig@gva.es
76
 *      www.gvsig.gva.es
77
 *
78
 *    or
79
 *
80
 *   IVER T.I. S.A
81
 *   Salamanca 50
82
 *   46005 Valencia
83
 *   Spain
84
 *
85
 *   +34 963163400
86
 *   dac@iver.es
87
 */
88

    
89
/**
90
 * This will be the tab for add a filter to a WFS query.
91
 * This class gets the graphical interface from FilterQueryJPanel and add logic.
92
 * 
93
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
94
 */
95
public class WFSFilterPanel extends FilterQueryJPanel implements IWindow, IWindowListener {
96
        private static Logger logger = Logger.getLogger(Table.class.getName());
97
        private WFSParamsPanel parent = null;
98
        private ArrayList expressionListeners = new ArrayList();
99
        private ExpressionDataSource model = null;
100
        private NumberFormat nf = NumberFormat.getNumberInstance();
101
        private ExceptionHandlingSupport exceptionHandlingSupport = new ExceptionHandlingSupport();
102
        private AttributesTreeTableModel attributesTreeTableModel;
103
        private boolean panelAsATabForWFSLayersLoad;
104
        
105
        /**
106
         * This method initializes
107
         *
108
         */
109
        public WFSFilterPanel(WFSParamsPanel parent) {
110
                super();
111
                this.parent = parent;
112
        }
113
        
114
        /*
115
         *  (non-Javadoc)
116
         * @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#initialize()
117
         */
118
        protected void initialize() {
119
                super.initialize();
120
                this.resizeHeight(380);
121

    
122
                defaultTreeModel = (DefaultTreeModel)fieldsJTree.getModel();
123
                
124
                this.addNewListeners();
125
                panelAsATabForWFSLayersLoad = true;
126
        }
127
        
128
        /**
129
         * Adds some more listener to the components of the panel
130
         */
131
        private void addNewListeners() {
132
                txtExpression.getDocument().addDocumentListener(new DocumentListener() {
133
                        /*
134
                         *  (non-Javadoc)
135
                         * @see javax.swing.event.DocumentListener#changedUpdate(javax.swing.event.DocumentEvent)
136
                         */
137
                        public void changedUpdate(DocumentEvent e) {
138
                        }
139

    
140
                        /*
141
                         *  (non-Javadoc)
142
                         * @see javax.swing.event.DocumentListener#insertUpdate(javax.swing.event.DocumentEvent)
143
                         */
144
                        public void insertUpdate(DocumentEvent e) {
145
                                if (!panelAsATabForWFSLayersLoad)
146
                                        parent.isApplicable(true);
147
                        }
148

    
149
                        /*
150
                         *  (non-Javadoc)
151
                         * @see javax.swing.event.DocumentListener#removeUpdate(javax.swing.event.DocumentEvent)
152
                         */
153
                        public void removeUpdate(DocumentEvent e) {
154
                                if (!panelAsATabForWFSLayersLoad)
155
                                        parent.isApplicable(true);
156
                        }
157
                        
158
                });
159
                
160
                // Listener for "fieldsJTree" 
161
                getFieldsJTree().addMouseListener(new MouseAdapter() {
162
                        /*
163
                         *  (non-Javadoc)
164
                         * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
165
                         */
166
                        public void mouseClicked(MouseEvent e) {
167
                                int row = fieldsJTree.getRowForLocation(e.getX(), e.getY());
168
                                TreePath treePath = fieldsJTree.getPathForLocation(e.getX(), e.getY());
169

    
170
                                if (row > -1) {
171
                                        switch (e.getClickCount()) {
172
                                                case 1:
173
                                                        if (!panelAsATabForWFSLayersLoad) {
174
                                                                DataReturnedOfDataLoadingFromActiveView data = DataLoadingFromActiveView.getDefaultExpressionDataSource();
175
                                        
176
                                                                if ((data != null) && (data.getData() != null)) {
177
                                                                        setModel(data.getData());
178
                                                                        fillValuesByPath(treePath);                                                                        
179
                                                                }
180
                                                        }
181
                                                        break;
182
                                                case 2:                                                
183
                                                        putSymbolOfSelectedByMouseBranch(treePath);
184
                                                        break;
185
                                        }
186
                                }
187
                        }
188
                });
189
                
190
                // Listener for "valuesJList"
191
                getValuesJList().addMouseListener(new MouseAdapter() {
192
                        /*
193
                         *  (non-Javadoc)
194
                         * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
195
                         */
196
                        public void mouseClicked(MouseEvent e) {
197
                                if (e.getClickCount() == 2) {
198
                                        Value valor = (Value) valuesListModel.getElementAt(getValuesJList().getSelectedIndex());
199

    
200
                                        putSymbol(valor.toString());        
201
                                }
202
                        }
203
                });
204
        }
205
        
206
        /**
207
         * Sets the value of the inner attribute: 'panelAsATabForWFSLayersLoad'
208
         * 
209
         * @param b A boolean value
210
         */
211
        public void setWFSFilterPanelIsAsTabForWFSLayersLoad (boolean b) {
212
                this.panelAsATabForWFSLayersLoad = b;
213
        }
214
        
215
        /**
216
         * Rellena la lista con los valores del campo seleccionado
217
         */
218
        private void fillValuesByPath(TreePath treePath) {
219
                // Duplicates are removed
220
                TreeSet conjunto = new TreeSet(new Comparator() {
221
                        public int compare(Object o1, Object o2) {
222
                                if ((o1 != null) && (o2 != null)) {
223
                                        Value v2 = (Value) o2;
224
                                        Value v1 = (Value) o1;
225
                                        BooleanValue boolVal;
226
                                        
227
                                        try {
228
                                                boolVal = (BooleanValue) (v1.greater(v2));
229
                                                
230
                                                if (boolVal.getValue()) {
231
                                                        return 1;
232
                                                }
233
                                                
234
                                                boolVal = (BooleanValue) (v1.less(v2));
235
                                                
236
                                                if (boolVal.getValue()) {
237
                                                        return -1;
238
                                                }
239
                                        } catch (IncompatibleTypesException e) {
240
                                                throw new RuntimeException(e);
241
                                        }
242
                                }
243
                                
244
                                return 0;
245
                        }
246
                }); // For ordernation
247
                
248
                // Remove the previous items
249
                valuesListModel.clear();
250
                
251
                try {
252
                        //Object root = treePath.getPath()[0];
253
                        XMLElement element = ((XMLElement)treePath.getLastPathComponent());
254
                        
255
                        // Gets the values associated to the selected branch 
256
                        switch (element.getEntityType().getType()) {
257
                                case IXMLType.SIMPLE:
258
                                        
259
                                        if(element.getParentElement().getParentElement() == null){
260
                                        
261
                                                // Find the selected field and try to obtein values related
262
                                                for (int i = 0; i < model.getFieldCount(); i++) {                                        
263
                                                        String name = model.getFieldName(i);
264
                                                        
265
                                                        // If we find the field (this means that are loaded its values and we can obtein them)
266
                                                        if (name.equals(element.getName())) {                                                
267
                                                                for (int j = 0; j < model.getRowCount(); j++) {                                        
268
                                                                        Value value = model.getFieldValue(j, i);
269
                                                
270
                                                                        if (value instanceof NullValue)
271
                                                                            continue;
272
                                                                        
273
                                                                        if (!conjunto.contains(value)) {
274
                                                                                conjunto.add(value);
275
                                                                        }
276
                                                                }
277
                                                                
278
                                                                break;
279
                                                        }
280
                                                }
281
                                        }else{
282
                                                //create a vector with the parent names from the leaf until the root
283
                                                XMLElement parent = element.getParentElement();
284
                                                Vector parentNames = new Vector();
285
                                                parentNames.add(element.getName());
286
                                                while (parent != null){
287
                                                        parentNames.add(parent.getName());
288
                                                        parent = parent.getParentElement();                                                        
289
                                                }
290
                                                
291
                                                //The field name (in the gvSIG table) is the second field name
292
                                                String fieldName = (String)parentNames.get(parentNames.size()-2);
293
                                                
294
                                                for (int i = 0; i < model.getFieldCount(); i++) {                                        
295
                                                        String name = model.getFieldName(i);
296
                                                        
297
                                                        // If we find the field (this means that are loaded its values and we can obtein them)
298
                                                        if (name.equals(fieldName)) {                                                
299
                                                                for (int j = 0; j < model.getRowCount(); j++) {                                        
300
                                                                        Value value = model.getFieldValue(j, i);
301
                                                                                                                        
302
                                                                        if (value instanceof NullValue)
303
                                                                            continue;
304
                                                                        
305
                                                                        if (value instanceof ComplexValue){
306
                                                                                for (int k=parentNames.size()-3 ; k>=0 ; k--){
307
                                                                                        ComplexValue complex = (ComplexValue)value;
308
                                                                                        Value childValue = (Value)complex.get(parentNames.get(k));
309
                                                                                        if (k==0){
310
                                                                                                if (!conjunto.contains(childValue)) {
311
                                                                                                        conjunto.add(childValue);
312
                                                                                                }
313
                                                                                        }else{
314
                                                                                                value = childValue;
315
                                                                                        }
316
                                                                                }
317
                                                                        }
318
                                                                }
319
                                                                
320
                                                                break;
321
                                                        }
322
                                                }
323
                                        }
324
                                        break;
325
                                case IXMLType.COMPLEX:
326
                                        break;
327
                                default:
328
                                        // Do Nothing
329
                        }
330
                        
331
                        // Add the values to the model of the graphic list
332
                        Iterator it = conjunto.iterator();
333

    
334
                        while (it.hasNext())
335
                                valuesListModel.addElement(it.next());
336
                } catch (Exception e) {
337
                        throwException(e);
338
                }
339
        }
340
        
341
        /**
342
         * Puts the symbol of selected brach
343
         * 
344
         * @param mouseEvent A MouseEvent with information  of the selected branch
345
         */
346
        public void putSymbolOfSelectedByMouseBranch(TreePath treePath) {
347
                // Sets the node selected
348
                if (treePath != null) {
349
                        Object node = treePath.getLastPathComponent();
350
                        if ((node != null) && (node instanceof XMLElement)) {
351
                                XMLElement element = (XMLElement) node;
352
                                XMLElement parent = element.getParentElement();
353
                                String path = element.getName();
354
                                while (parent.getParentElement() != null){
355
                                        path = parent.getName() + "/" + path;
356
                                        parent = parent.getParentElement();
357
                                }
358
                                putSymbol("\"" + path + "\"");
359
                        }
360
                }
361
        }
362
        
363
        /**
364
         * Gets the query that will be send to the server
365
         * @return
366
         * SQL query (just the where part)
367
         */
368
        public String getQuery(){
369
                try {
370
                        return this.validateExpression();
371
                } catch (ParseException e) {                        
372
                        e.printStackTrace();
373
                        return null;
374
                }                
375
        }
376
        
377
        /**
378
         * Writes the query in the user interface
379
         * @param query
380
         * SQL query (just the where part)
381
         */
382
        public void setQuery(String query){
383
                this.txtExpression.setText(query);
384
        }
385
        
386
        /**
387
         * DOCUMENT ME!
388
         *
389
         * @param arg0
390
         *
391
         * @return
392
         */
393
        public boolean addExpressionListener(ExpressionListener arg0) {
394
                return expressionListeners.add(arg0);
395
        }
396

    
397
        /**
398
         * DOCUMENT ME!
399
         *
400
         * @param arg0
401
         *
402
         * @return
403
         */
404
        public boolean removeExpressionListener(ExpressionListener arg0) {
405
                return expressionListeners.remove(arg0);
406
        }
407
        /**
408
         * DOCUMENT ME!
409
         *
410
         * @param o DOCUMENT ME!
411
         *
412
         * @return DOCUMENT ME!
413
         */
414
        public boolean removeExceptionListener(ExceptionListener o) {
415
                return exceptionHandlingSupport.removeExceptionListener(o);
416
        }
417

    
418
        /**
419
         * DOCUMENT ME!
420
         *
421
         * @param t DOCUMENT ME!
422
         */
423
        private void throwException(Throwable t) {
424
                exceptionHandlingSupport.throwException(t);
425
        }
426

    
427
        /**
428
         * DOCUMENT ME!
429
         *
430
         * @param t DOCUMENT ME!
431
         */
432
        public void setModel(ExpressionDataSource t) {
433
                try {
434
                        model = t;
435
            model.start();
436
        } catch (DriverException e1) {
437
            NotificationManager.addError(e1.getMessage(), e1);
438
        }
439
                
440
        try {
441
                int numberOfFields = model.getFieldCount();
442
                
443
                if (numberOfFields > 0) {
444
                        Vector fields = new Vector(0, 1);
445
                        int j = 0;
446
                
447
                                for (int i = 0; i < numberOfFields; i++) {
448
                                        Object field = model.getFieldName(i);
449
                                        
450
                                        if (field != null) {
451
                                                fields.add(field);
452
                                                j++;
453
                                        }
454
                                }
455
                        
456
                                attributesTreeTableModel = new AttributesTreeTableModel(fields.toArray());                        
457
                }
458
                } catch (FilterException e) {
459
                        throwException(e);
460
                }
461
        }
462

    
463
        /**
464
         * DOCUMENT ME!
465
         *
466
         * @param expresion DOCUMENT ME!
467
         * @param substring DOCUMENT ME!
468
         * @param startingPos DOCUMENT ME!
469
         *
470
         * @return DOCUMENT ME!
471
         */
472
        private int getIndex(String expresion, String substring, int startingPos) {
473
                int index = startingPos;
474

    
475
                do {
476
                        index = expresion.indexOf(substring, index);
477
                } while ((StringUtilities.isBetweenSymbols(expresion, index, "\"")) &&
478
                                (index != -1));
479

    
480
                return index;
481
        }
482

    
483
        /**
484
         * DOCUMENT ME!
485
         *
486
         * @param expresion DOCUMENT ME!
487
         * @param word DOCUMENT ME!
488
         * @param translation DOCUMENT ME!
489
         *
490
         * @return DOCUMENT ME!
491
         *
492
         * @throws ParseException DOCUMENT ME!
493
         */
494
        private String translateWord(String expresion, String word,
495
                String translation) throws ParseException {
496
                int booleanIndex = 0;
497
                int endIndex = 0;
498
                StringBuffer res = new StringBuffer();
499

    
500
                while ((booleanIndex = getIndex(expresion, word, booleanIndex)) != -1) {
501
                        res.append(expresion.substring(endIndex, booleanIndex));
502
                        endIndex = booleanIndex + word.length();
503
                        booleanIndex++;
504
                        res.append(translation);
505
                }
506

    
507
                if (endIndex < expresion.length()) {
508
                        res.append(expresion.substring(endIndex));
509
                }
510

    
511
                return res.toString();
512
        }
513

    
514
        /**
515
         * DOCUMENT ME!
516
         *
517
         * @param expresion DOCUMENT ME!
518
         *
519
         * @return DOCUMENT ME!
520
         *
521
         * @throws ParseException DOCUMENT ME!
522
         */
523
        private String translateDates(String expresion) throws ParseException {
524
                //Se obtiene el valor de la fecha
525
                String date = StringUtilities.substringDelimited(expresion, "Date(",
526
                                ")", 0);
527

    
528
                if (date == null) {
529
                        return expresion;
530
                }
531

    
532
                //Se comprueba que no est? entre comillas 
533
                int startIndex = expresion.indexOf(date);
534

    
535
                while (startIndex != -1) {
536
                        if (!StringUtilities.isBetweenSymbols(expresion, startIndex, "\"")) {
537
                                
538
                                //Se sustituye por el valor ordinal de la fecha
539
                                expresion = expresion.substring(0, startIndex - 5) +
540
                                        expresion.substring(startIndex).replaceFirst(date + "\\)",
541
                                                new Long((filterButtonsJPanel.getDateFormat().parse(date)).getTime()).toString());
542
                                ;
543
                        } else {
544
                                startIndex += date.length();
545
                        }
546
                        
547
                        if (date == null) {
548
                                return expresion;
549
                        }
550

    
551
                        startIndex = expresion.indexOf(date, startIndex);
552
                }
553

    
554
                return expresion;
555
        }
556

    
557
        /**
558
         * DOCUMENT ME!
559
         *
560
         * @param expresion DOCUMENT ME!
561
         *
562
         * @return DOCUMENT ME!
563
         *
564
         * @throws ParseException DOCUMENT ME!
565
         */
566
        public String translateNumber(String expresion) throws ParseException {
567
                DefaultCharSet ss = new DefaultCharSet();
568
                ss.addInterval('0', '9');
569
                ss.addCharacter(',');
570
                ss.addCharacter('.');
571

    
572
                String number = StringUtilities.substringWithSymbols(expresion, ss, 0);
573

    
574
                if (number == null) {
575
                        return expresion;
576
                }
577

    
578
                int startIndex = expresion.indexOf(number);
579

    
580
                while (startIndex != -1) {
581
                        Number n = nf.parse(number);
582

    
583
                        if (!StringUtilities.isBetweenSymbols(expresion, startIndex, "\"")) {
584
                                
585
                                //Se sustituye por el valor ordinal de la fecha
586
                                expresion = expresion.substring(0, startIndex) +
587
                                        expresion.substring(startIndex).replaceFirst(number,
588
                                                n.toString());
589
                        } else {
590
                                startIndex += n.toString().length();
591
                        }
592

    
593
                        number = StringUtilities.substringWithSymbols(expresion, ss,
594
                                        startIndex);
595

    
596
                        if (number == null) {
597
                                return expresion;
598
                        }
599

    
600
                        startIndex = expresion.indexOf(number, startIndex);
601
                }
602

    
603
                return expresion;
604
        }
605
        
606
        /**
607
         * DOCUMENT ME!
608
         *
609
         * @return DOCUMENT ME!
610
         *
611
         * @throws ParseException DOCUMENT ME!
612
         */
613
        private String validateExpression() throws ParseException {
614
                String expression = txtExpression.getText();
615
//                HashSet variablesIndexes = new HashSet();
616
//
617
//                StringBuffer traducida = new StringBuffer();
618

    
619
                //Se transforman los nombres de los campos en las variables xix que analizar?n
620
                //Se quitan los Date(fecha) y se mete la fecha correspondiente
621
                expression = translateDates(expression);
622
                expression = translateNumber(expression);
623
                expression = translateWord(expression, "true", "1");
624
                expression = translateWord(expression, "false", "0");
625

    
626
//                String replacement;
627
//                Pattern patron = Pattern.compile("[^<>!]=");
628
//                Matcher m = patron.matcher(expression);
629
//                int index = 0;
630
//
631
//                while (m.find(index)) {
632
//                        index = m.start();
633
//                        replacement = expression.charAt(index) + "==";
634
//                        m.replaceFirst(replacement);
635
//                        index++;
636
//                }
637
//
638
//                expression = expression.replaceAll("[^<>!]=", "==");
639

    
640
                logger.debug(expression);
641

    
642
                return expression;
643
        }
644

    
645
        /**
646
         * DOCUMENT ME!
647
         *
648
         * @return DOCUMENT ME!
649
         *
650
         * @throws ParseException DOCUMENT ME!
651
         */
652
        private String oldValidateExpressionMethod() throws ParseException {
653
                String expression = txtExpression.getText();
654
//                HashSet variablesIndexes = new HashSet();
655
//
656
//                StringBuffer traducida = new StringBuffer();
657

    
658
                //Se transforman los nombres de los campos en las variables xix que analizar?n
659
                //Se quitan los Date(fecha) y se mete la fecha correspondiente
660
                expression = translateDates(expression);
661
                expression = translateNumber(expression);
662
                expression = translateWord(expression, "true", "1");
663
                expression = translateWord(expression, "false", "0");
664

    
665
                String replacement;
666
                Pattern patron = Pattern.compile("[^<>!]=");
667
                Matcher m = patron.matcher(expression);
668
                int index = 0;
669

    
670
                while (m.find(index)) {
671
                        index = m.start();
672
                        replacement = expression.charAt(index) + "==";
673
                        m.replaceFirst(replacement);
674
                        index++;
675
                }
676

    
677
                expression = expression.replaceAll("[^<>!]=", "==");
678

    
679
                logger.debug(expression);
680

    
681
                return expression;
682
        }
683

    
684
    /* (non-Javadoc)
685
     * @see com.iver.andami.ui.mdiManager.ViewListener#viewActivated()
686
     */
687
    public void windowActivated() {
688
    }
689

    
690
    /* (non-Javadoc)
691
     * @see com.iver.andami.ui.mdiManager.ViewListener#viewClosed()
692
     */
693
    public void windowClosed() {
694
        try {
695
            model.stop();
696
        } catch (DriverException e) {
697
            NotificationManager.addError(e.getMessage(), e);
698
        }        
699
    }
700

    
701
        public WindowInfo getWindowInfo() {
702
                // TODO Auto-generated method stub
703
                return null;
704
        }
705

    
706
        public void refresh(WFSLayerNode feature) {
707
                setFields(feature);
708
        }
709
        
710
        /**
711
         * Sets Fields
712
         *
713
         * @param feature
714
         */
715
        private void setFields(WFSLayerNode feature) {
716
                Vector fields = feature.getFields();
717
                                
718
                this.resetFieldsAndValuesData();
719
                
720
                int numberOfFields = fields.size();
721
                
722
                if (numberOfFields > 0) {
723
                        int j = 0;
724
                        Vector fieldBranches = new Vector(0, 1);
725
                        
726
                        for (int i=0 ; i<fields.size() ;i++) {
727
                                XMLElement field = (XMLElement)fields.get(i);                                
728

    
729
                                IXMLType type = field.getEntityType();
730
                                
731
                                if (type != null) {
732
                                        switch (type.getType()) {
733
                                                case IXMLType.GML_GEOMETRY:
734
                                                        break;
735
                                                case IXMLType.COMPLEX:
736
                                                        fieldBranches.add(field);
737
                                                        j++;
738
                                                        break;
739
                                                case IXMLType.SIMPLE:
740
                                                        fieldBranches.add(field);
741
                                                        j++;
742
                                                        break;
743
                                        }
744
                                }
745
                        }
746
                        
747
                        attributesTreeTableModel = new AttributesTreeTableModel(fieldBranches.get(0));
748
                        fieldsJTree.setModel(attributesTreeTableModel);
749
                }
750
        }
751

    
752
        /**
753
         * Resets the data of fields and their values of the current layer feature, and removes the branches of JTree
754
         */
755
        private void resetFieldsAndValuesData() {
756
                fieldsJTree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode()));
757
                txtExpression.setText("");
758
                ((DefaultListModel)valuesJList.getModel()).removeAllElements();
759
        }
760
        
761
        
762
        /**
763
         * @see WFSParamsPanel#isApplicable(boolean)
764
         * 
765
         * @param b A boolean value
766
         */
767
        private void setApplicate(boolean b) {
768
                parent.isApplicable(b);
769
        }
770
}