Revision 34132 branches/v2_0_0_prep/extensions/extWFS2/src/org/gvsig/wfs/gui/panels/WFSFilterPanel.java
WFSFilterPanel.java | ||
---|---|---|
3 | 3 |
import java.awt.Color; |
4 | 4 |
import java.awt.event.MouseAdapter; |
5 | 5 |
import java.awt.event.MouseEvent; |
6 |
import java.io.ByteArrayInputStream; |
|
7 |
import java.io.InputStream; |
|
6 | 8 |
import java.io.UnsupportedEncodingException; |
7 | 9 |
import java.net.URLEncoder; |
8 | 10 |
import java.text.DateFormat; |
... | ... | |
26 | 28 |
import javax.swing.tree.DefaultTreeModel; |
27 | 29 |
import javax.swing.tree.TreePath; |
28 | 30 |
|
31 |
import Zql.ZExp; |
|
32 |
import Zql.ZqlParser; |
|
33 |
|
|
29 | 34 |
import org.slf4j.Logger; |
30 | 35 |
import org.slf4j.LoggerFactory; |
31 | 36 |
|
... | ... | |
102 | 107 |
*/ |
103 | 108 |
public class WFSFilterPanel extends FilterQueryJPanel implements IWFSPanel { |
104 | 109 |
private static final long serialVersionUID = -6041218260822015810L; |
110 |
private static final Logger LOG = LoggerFactory.getLogger(WFSFilterPanel.class); |
|
105 | 111 |
|
106 | 112 |
private static Logger logger = LoggerFactory.getLogger(WFSFilterPanel.class); |
107 | 113 |
private ExpressionDataSource model = null; |
... | ... | |
129 | 135 |
// At beginning, the JList is disabled (and its set a particular color for user could knew it) |
130 | 136 |
super.getValuesJList().setEnabled(false); |
131 | 137 |
//getValuesJList().setBackground(new Color(220, 220, 220)); |
138 |
|
|
139 |
//The validation option is disabled by default |
|
140 |
this.getValidateFilterExpressionJCheckBox().setSelected(false); |
|
132 | 141 |
} |
133 | 142 |
|
134 | 143 |
/* |
... | ... | |
230 | 239 |
|
231 | 240 |
if (e.getClickCount() == 2){ |
232 | 241 |
String valor = valuesListModel.getElementAt(index).toString(); |
233 |
|
|
242 |
|
|
234 | 243 |
// If value is an string -> set it between apostrophes |
235 | 244 |
if (getNodeOfCurrentPath().getDataType().getType() == DataTypes.STRING) { |
236 | 245 |
putSymbol("'" + valor + "'"); |
... | ... | |
423 | 432 |
else { |
424 | 433 |
logger.debug("Codified WFS filter query: " + writtenQuery); |
425 | 434 |
|
435 |
if (writtenQuery.trim().length() == 0){ |
|
436 |
return null; |
|
437 |
} |
|
426 | 438 |
// Codify expression (only if the validation has been successful) |
427 | 439 |
return this.codifyExpression(writtenQuery); // Ignores the spaces at beginning and end of the chain of characters |
428 | 440 |
} |
... | ... | |
506 | 518 |
} |
507 | 519 |
} |
508 | 520 |
|
509 |
return result;
|
|
521 |
return formatResutl(result);
|
|
510 | 522 |
} |
523 |
|
|
524 |
private String formatResutl(String query) { |
|
525 |
if ((query == null) || (query.equals(""))){ |
|
526 |
return null; |
|
527 |
} |
|
528 |
InputStream is = new ByteArrayInputStream(query.getBytes()); |
|
529 |
ZqlParser parser = new ZqlParser(); |
|
530 |
parser.initParser(is); |
|
531 |
ZExp exp; |
|
532 |
try { |
|
533 |
exp = parser.readExpression(); |
|
534 |
return exp.toString(); |
|
535 |
} catch (Zql.ParseException e) { |
|
536 |
LOG.error("Formatting the filter request", e); |
|
537 |
JOptionPane.showMessageDialog(null, PluginServices.getText(null, "filter_with_an_incorrect_format"), PluginServices.getText(null, "error_validating_filter_query"), JOptionPane.ERROR_MESSAGE); |
|
538 |
} |
|
539 |
return query; |
|
540 |
} |
|
511 | 541 |
|
512 | 542 |
/** |
513 | 543 |
* Checks the filter expression if it's correct |
... | ... | |
957 | 987 |
fieldValueSet.add(obj); |
958 | 988 |
} |
959 | 989 |
} |
960 |
|
|
990 |
|
|
961 | 991 |
Iterator it = fieldValueSet.iterator(); |
962 | 992 |
while (it.hasNext()) { |
963 | 993 |
String text = it.next().toString(); |
... | ... | |
966 | 996 |
} |
967 | 997 |
|
968 | 998 |
this.getValuesJList().setEnabled(valuesListModel.getSize() > 0); |
969 |
|
|
970 | 999 |
|
1000 |
|
|
971 | 1001 |
// // Find the selected field and try to obtein values related |
972 | 1002 |
// for (int i = 0; i < model.getFieldCount(); i++) { |
973 | 1003 |
// String name = model.getFieldName(i); |
Also available in: Unified diff