svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / gui / filter / FilterDialog.java @ 43521
History | View | Annotate | Download (23.3 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.app.gui.filter; |
25 |
|
26 |
import java.awt.event.MouseAdapter; |
27 |
import java.awt.event.MouseEvent; |
28 |
import java.text.NumberFormat; |
29 |
import java.text.ParseException; |
30 |
import java.util.ArrayList; |
31 |
import java.util.Collection; |
32 |
import java.util.Comparator; |
33 |
import java.util.Date; |
34 |
import java.util.Iterator; |
35 |
import java.util.List; |
36 |
import java.util.TreeSet; |
37 |
import java.util.regex.Matcher; |
38 |
import java.util.regex.Pattern; |
39 |
import javax.swing.JOptionPane; |
40 |
|
41 |
import javax.swing.tree.DefaultMutableTreeNode; |
42 |
import javax.swing.tree.DefaultTreeModel; |
43 |
import org.apache.commons.lang.StringEscapeUtils; |
44 |
import org.apache.commons.lang3.StringUtils; |
45 |
|
46 |
import org.slf4j.Logger; |
47 |
import org.slf4j.LoggerFactory; |
48 |
|
49 |
import org.gvsig.andami.PluginServices; |
50 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
51 |
import org.gvsig.andami.ui.mdiManager.IWindowListener; |
52 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
53 |
import org.gvsig.app.ApplicationLocator; |
54 |
import org.gvsig.app.ApplicationManager; |
55 |
import org.gvsig.fmap.dal.exception.DataException; |
56 |
import org.gvsig.fmap.dal.feature.Feature; |
57 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
58 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
59 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
60 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
61 |
import org.gvsig.gui.beans.filterPanel.tableFilterQueryPanel.TableFilterQueryJPanel; |
62 |
import org.gvsig.tools.ToolsLocator; |
63 |
import org.gvsig.tools.dispose.DisposableIterator; |
64 |
import org.gvsig.tools.dispose.DisposeUtils; |
65 |
import org.gvsig.tools.i18n.I18nManager; |
66 |
import org.gvsig.utils.DefaultCharSet; |
67 |
import org.gvsig.utils.StringUtilities; |
68 |
import org.gvsig.utils.exceptionHandling.ExceptionHandlingSupport; |
69 |
import org.gvsig.utils.exceptionHandling.ExceptionListener; |
70 |
|
71 |
/**
|
72 |
* This class substitutes the old "FilterDialog" class made by
|
73 |
* "Fernando Gonz?lez Cort?s"
|
74 |
* The functionality is the same, but now the class is made from separately (and
|
75 |
* reusable) components
|
76 |
*
|
77 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
|
78 |
*/
|
79 |
public class FilterDialog extends TableFilterQueryJPanel implements IWindow, |
80 |
IWindowListener { |
81 |
|
82 |
/**
|
83 |
*
|
84 |
*/
|
85 |
private static final long serialVersionUID = -149317534873551735L; |
86 |
private static final Logger logger = LoggerFactory.getLogger(FilterDialog.class); |
87 |
|
88 |
private FeatureStore model = null; |
89 |
|
90 |
private final List<ExpressionListener> expressionListeners = new ArrayList<>(); |
91 |
private final ExceptionHandlingSupport exceptionHandlingSupport = new ExceptionHandlingSupport(); |
92 |
private final NumberFormat nf = NumberFormat.getNumberInstance(); |
93 |
|
94 |
private String title; |
95 |
|
96 |
private final int filterDialog_Width = 500; |
97 |
private final int filterDialog_Height = 362; |
98 |
private final int widthIncrementForAndami = 20; // This is necessary because |
99 |
// when the panel is sent to
|
100 |
// Andami, that needs a bit
|
101 |
// more width-space to show
|
102 |
// that panel.
|
103 |
|
104 |
/**
|
105 |
* This is the default constructor
|
106 |
* @param _title
|
107 |
*/
|
108 |
public FilterDialog(String _title) { |
109 |
super();
|
110 |
title = _title; |
111 |
defaultTreeModel = (DefaultTreeModel) fieldsJTree.getModel();
|
112 |
} |
113 |
|
114 |
/**
|
115 |
* This is the default constructor
|
116 |
*/
|
117 |
public FilterDialog() {
|
118 |
super();
|
119 |
defaultTreeModel = (DefaultTreeModel) fieldsJTree.getModel();
|
120 |
} |
121 |
|
122 |
/*
|
123 |
* (non-Javadoc)
|
124 |
*
|
125 |
* @see
|
126 |
* org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#initialize()
|
127 |
*/
|
128 |
@Override
|
129 |
protected void initialize() { |
130 |
super.initialize();
|
131 |
|
132 |
super.resizeHeight(filterDialog_Height);
|
133 |
super.resizeWidth(filterDialog_Width - widthIncrementForAndami);
|
134 |
|
135 |
this.addNewListeners();
|
136 |
} |
137 |
|
138 |
/**
|
139 |
* Adds some listeners
|
140 |
*/
|
141 |
private void addNewListeners() { |
142 |
// Listener for "btnAdd"
|
143 |
// Adds more elements to the current set
|
144 |
getBtnAddToCurrentSet().addActionListener( |
145 |
new java.awt.event.ActionListener() {
|
146 |
|
147 |
@Override
|
148 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
149 |
final String expr = getTxtExpression().getText(); |
150 |
if (!validateQuotes(expr) || !validateLike(expr)) {
|
151 |
return;
|
152 |
} |
153 |
|
154 |
PluginServices.backgroundExecution(new Runnable() { |
155 |
|
156 |
@Override
|
157 |
public void run() { |
158 |
for (ExpressionListener l : expressionListeners) {
|
159 |
try {
|
160 |
l.addToSet(expr); |
161 |
} catch (DataException e) {
|
162 |
logger.warn("Can't add expression '"+expr+"' to set.", e); |
163 |
} |
164 |
} |
165 |
} |
166 |
}); |
167 |
} |
168 |
}); |
169 |
|
170 |
// Listener for "btnNuevo"
|
171 |
// Adds a new set
|
172 |
getBtnNewSet().addActionListener(new java.awt.event.ActionListener() {
|
173 |
|
174 |
@Override
|
175 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
176 |
final String expr = getTxtExpression().getText(); |
177 |
if (!validateQuotes(expr) || !validateLike(expr)) {
|
178 |
return;
|
179 |
} |
180 |
|
181 |
PluginServices.backgroundExecution(new Runnable() { |
182 |
|
183 |
@Override
|
184 |
public void run() { |
185 |
for (ExpressionListener l : expressionListeners) {
|
186 |
try {
|
187 |
l.newSet(expr); |
188 |
} catch (DataException e) {
|
189 |
logger.warn("Can't create set with expression '"+expr+"'.", e); |
190 |
} |
191 |
} |
192 |
} |
193 |
}); |
194 |
} |
195 |
}); |
196 |
|
197 |
// Listener for "btnFromSet"
|
198 |
// Selects elements from the current filtered selection
|
199 |
getBtnFromSet().addActionListener(new java.awt.event.ActionListener() {
|
200 |
|
201 |
@Override
|
202 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
203 |
final String expr = getTxtExpression().getText(); |
204 |
if (!validateQuotes(expr) || !validateLike(expr) ) {
|
205 |
return;
|
206 |
} |
207 |
|
208 |
PluginServices.backgroundExecution(new Runnable() { |
209 |
|
210 |
@Override
|
211 |
public void run() { |
212 |
for (ExpressionListener l : expressionListeners) {
|
213 |
try {
|
214 |
l.fromSet(expr); |
215 |
} catch (DataException e) {
|
216 |
logger.warn("Can't create expression '"+expr+"' from set.", e); |
217 |
} |
218 |
} |
219 |
} |
220 |
}); |
221 |
} |
222 |
}); |
223 |
|
224 |
// Listener for "fieldsJTree"
|
225 |
getFieldsJTree().addMouseListener(new MouseAdapter() { |
226 |
|
227 |
@Override
|
228 |
public void mouseClicked(MouseEvent e) { |
229 |
int row = fieldsJTree.getRowForLocation(e.getX(), e.getY());
|
230 |
if (row > -1) { |
231 |
switch (e.getClickCount()) {
|
232 |
case 1: |
233 |
fillValues(row); |
234 |
break;
|
235 |
case 2: |
236 |
String s = jtreeRoot.getChildAt(row).toString();
|
237 |
if( Character.isDigit(s.charAt(0)) || !StringUtils.isAlphanumeric(s) ) { |
238 |
s = "["+s+"]"; |
239 |
} |
240 |
putSymbol(s); |
241 |
break;
|
242 |
} |
243 |
} |
244 |
} |
245 |
}); |
246 |
|
247 |
// Listener for "valuesJList"
|
248 |
getValuesJList().addMouseListener(new MouseAdapter() { |
249 |
|
250 |
@Override
|
251 |
public void mouseClicked(MouseEvent e) { |
252 |
if (e.getClickCount() == 2) { |
253 |
Object valor = valuesListModel.getElementAt(getValuesJList()
|
254 |
.getSelectedIndex()); |
255 |
if (valor == null) { |
256 |
putSymbol("null");
|
257 |
} else if (valor instanceof Date) { |
258 |
putSymbol("date('" + valor + "')"); |
259 |
} else if (valor instanceof Boolean) { |
260 |
putSymbol(valor.toString()); |
261 |
} else if (valor instanceof String) { |
262 |
putSymbol("'" + StringEscapeUtils.escapeSql((String) valor) + "'"); |
263 |
//putSymbol("'" + ((String)valor).replace('\'', '?') + "'");
|
264 |
} else {
|
265 |
putSymbol(StringEscapeUtils.escapeSql(valor.toString())); |
266 |
} |
267 |
} |
268 |
} |
269 |
}); |
270 |
} |
271 |
|
272 |
private boolean validateQuotes(String expr) { |
273 |
if ((StringUtils.countMatches(expr, "'") % 2) != 0) { |
274 |
ApplicationManager application = ApplicationLocator.getManager(); |
275 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
276 |
String msg = i18n.getTranslation("_The_number_of_quotes_is_doubtful_It_could_be_that_some_of_them_should_escape_Do_you_want_to_continue_the_operation_anyway"); |
277 |
int resp = application.confirmDialog(
|
278 |
msg, |
279 |
i18n.getTranslation("_Caution"),
|
280 |
JOptionPane.YES_NO_OPTION,
|
281 |
JOptionPane.QUESTION_MESSAGE,
|
282 |
"Doubtless number of quotes in the filter dialog"
|
283 |
); |
284 |
if (resp == JOptionPane.NO_OPTION) { |
285 |
return false; |
286 |
} |
287 |
} |
288 |
return true; |
289 |
|
290 |
} |
291 |
|
292 |
private boolean validateLike(String expr) { |
293 |
if( (expr.toLowerCase().contains("?") || |
294 |
expr.toLowerCase().contains("%")) &&
|
295 |
!expr.toLowerCase().contains("like") )
|
296 |
{ |
297 |
ApplicationManager application = ApplicationLocator.getManager(); |
298 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
299 |
String msg = i18n.getTranslation("_It_looks_like_youre_using_percent_o_question_and_the_like_operator_is_not_being_used_I_should_probably_keep_the_equal_operator_by_like_Do_you_want_to_continue_anyway"); |
300 |
int resp = application.confirmDialog(
|
301 |
msg, |
302 |
i18n.getTranslation("_Caution"),
|
303 |
JOptionPane.YES_NO_OPTION,
|
304 |
JOptionPane.QUESTION_MESSAGE,
|
305 |
"You may need the like operator in the filter dialog"
|
306 |
); |
307 |
if (resp == JOptionPane.NO_OPTION) { |
308 |
return false; |
309 |
} |
310 |
} |
311 |
return true; |
312 |
|
313 |
} |
314 |
/**
|
315 |
* Rellena la lista con los valores del campo seleccionado
|
316 |
*/
|
317 |
private void fillValues(int row) { |
318 |
// int index = lstCampos.getSelectedIndex();
|
319 |
|
320 |
// Index es ahora el ?ndice del campo seleccionado
|
321 |
// Se eliminan los duplicados
|
322 |
Collection conjunto = new TreeSet(new Comparator() { |
323 |
|
324 |
public int compare(Object o1, Object o2) { |
325 |
return ((Comparable) o1).compareTo(o2); |
326 |
} |
327 |
}); // Para poder ordenar
|
328 |
|
329 |
valuesListModel.clear(); |
330 |
FeatureSet fs = null;
|
331 |
DisposableIterator iterator = null;
|
332 |
try {
|
333 |
String[] fieldName = |
334 |
new String[] { ((FeatureAttributeDescriptor) model |
335 |
.getDefaultFeatureType().get(row)).getName() }; |
336 |
|
337 |
FeatureQuery query = model.createFeatureQuery(); |
338 |
query.setAttributeNames(fieldName); |
339 |
fs = model.getFeatureSet(query); |
340 |
iterator = fs.fastIterator(); |
341 |
while (iterator.hasNext()) {
|
342 |
Feature feature = (Feature) iterator.next(); |
343 |
Object value = feature.get(fieldName[0]); |
344 |
if (value == null) { |
345 |
continue;
|
346 |
} |
347 |
|
348 |
conjunto.add(value); |
349 |
} |
350 |
|
351 |
Iterator it = conjunto.iterator();
|
352 |
|
353 |
while (it.hasNext()) {
|
354 |
valuesListModel.addElement(it.next()); |
355 |
} |
356 |
} catch (DataException e) {
|
357 |
throwException(e); |
358 |
} finally {
|
359 |
DisposeUtils.dispose(iterator); |
360 |
DisposeUtils.dispose(fs); |
361 |
} |
362 |
} |
363 |
|
364 |
/**
|
365 |
* DOCUMENT ME!
|
366 |
*
|
367 |
* @param t
|
368 |
* DOCUMENT ME!
|
369 |
*/
|
370 |
public void setModel(FeatureStore t) { |
371 |
// try {
|
372 |
model = t; |
373 |
// model.start();
|
374 |
// } catch (ReadException e1) {
|
375 |
// NotificationManager.addError(e1.getMessage(), e1);
|
376 |
// }
|
377 |
|
378 |
jtreeRoot.removeAllChildren(); |
379 |
|
380 |
try {
|
381 |
Iterator attributes = model.getDefaultFeatureType().iterator();
|
382 |
while (attributes.hasNext()) {
|
383 |
FeatureAttributeDescriptor descriptor = |
384 |
(FeatureAttributeDescriptor) attributes.next(); |
385 |
Object field = descriptor.getName();
|
386 |
|
387 |
if (field != null) { |
388 |
jtreeRoot.add(new DefaultMutableTreeNode(field.toString())); |
389 |
} |
390 |
} |
391 |
// for (int i = 0; i < model.getFieldCount(); i++) {
|
392 |
// Object field = model.getFieldName(i);
|
393 |
//
|
394 |
// if (field != null) {
|
395 |
// jtreeRoot.add(new DefaultMutableTreeNode(field.toString()));
|
396 |
// }
|
397 |
// }
|
398 |
|
399 |
defaultTreeModel.setRoot(jtreeRoot); |
400 |
} catch (DataException e) {
|
401 |
throwException(e); |
402 |
} |
403 |
} |
404 |
|
405 |
/**
|
406 |
* DOCUMENT ME!
|
407 |
*
|
408 |
* @return DOCUMENT ME!
|
409 |
*
|
410 |
* @throws ParseException
|
411 |
* DOCUMENT ME!
|
412 |
*/
|
413 |
private String validateExpression() throws ParseException { |
414 |
String expression = txtExpression.getText();
|
415 |
// HashSet variablesIndexes = new HashSet();
|
416 |
//
|
417 |
// StringBuffer traducida = new StringBuffer();
|
418 |
|
419 |
// Se transforman los nombres de los campos en las variables xix que
|
420 |
// analizar?n
|
421 |
// Se quitan los Date(fecha) y se mete la fecha correspondiente
|
422 |
expression = translateDates(expression); |
423 |
expression = translateNumber(expression); |
424 |
expression = translateWord(expression, "true", "1"); |
425 |
expression = translateWord(expression, "false", "0"); |
426 |
|
427 |
String replacement;
|
428 |
Pattern patron = Pattern.compile("[^<>!]="); |
429 |
Matcher m = patron.matcher(expression);
|
430 |
int index = 0; |
431 |
|
432 |
while (m.find(index)) {
|
433 |
index = m.start(); |
434 |
replacement = expression.charAt(index) + "==";
|
435 |
m.replaceFirst(replacement); |
436 |
index++; |
437 |
} |
438 |
|
439 |
expression = expression.replaceAll("[^<>!]=", "=="); |
440 |
|
441 |
logger.debug(expression); |
442 |
|
443 |
return expression;
|
444 |
} |
445 |
|
446 |
/**
|
447 |
* Redefinition of the 'putSymbol' method of AbstractFilterQueryJPanel
|
448 |
* (I've made this redefinition for write the same code as the 'putSymbol'
|
449 |
* code of the original class (FilterDialog) that was in this project
|
450 |
* (appgvSIG) and didn't has path troubles to find 'StringUtilities').
|
451 |
*
|
452 |
* Sets a symbol on the filter expression (JTextArea that stores and shows
|
453 |
* the current filter expression)
|
454 |
*
|
455 |
* @param symbol
|
456 |
* A symbol: character, characters, number, ...
|
457 |
*/
|
458 |
@Override
|
459 |
protected void putSymbol(String symbol) { |
460 |
int position = txtExpression.getCaretPosition();
|
461 |
txtExpression.setText(StringUtilities.insert(txtExpression.getText(), |
462 |
position, symbol)); |
463 |
|
464 |
if (symbol.equals(" () ")) { |
465 |
position = position + 2;
|
466 |
} else {
|
467 |
position = position + symbol.length(); |
468 |
} |
469 |
|
470 |
txtExpression.setCaretPosition(position); |
471 |
} |
472 |
|
473 |
/**
|
474 |
* DOCUMENT ME!
|
475 |
*
|
476 |
* @param expresion
|
477 |
* DOCUMENT ME!
|
478 |
* @param substring
|
479 |
* DOCUMENT ME!
|
480 |
* @param startingPos
|
481 |
* DOCUMENT ME!
|
482 |
*
|
483 |
* @return DOCUMENT ME!
|
484 |
*/
|
485 |
private int getIndex(String expresion, String substring, int startingPos) { |
486 |
int index = startingPos;
|
487 |
|
488 |
do {
|
489 |
index = expresion.indexOf(substring, index); |
490 |
} while ((StringUtilities.isBetweenSymbols(expresion, index, "\"")) |
491 |
&& (index != -1));
|
492 |
|
493 |
return index;
|
494 |
} |
495 |
|
496 |
/**
|
497 |
* DOCUMENT ME!
|
498 |
*
|
499 |
* @param expresion
|
500 |
* DOCUMENT ME!
|
501 |
* @param word
|
502 |
* DOCUMENT ME!
|
503 |
* @param translation
|
504 |
* DOCUMENT ME!
|
505 |
*
|
506 |
* @return DOCUMENT ME!
|
507 |
*
|
508 |
* @throws ParseException
|
509 |
* DOCUMENT ME!
|
510 |
*/
|
511 |
private String translateWord(String expresion, String word, |
512 |
String translation) throws ParseException { |
513 |
int booleanIndex = 0; |
514 |
int endIndex = 0; |
515 |
StringBuffer res = new StringBuffer(); |
516 |
|
517 |
while ((booleanIndex = getIndex(expresion, word, booleanIndex)) != -1) { |
518 |
res.append(expresion.substring(endIndex, booleanIndex)); |
519 |
endIndex = booleanIndex + word.length(); |
520 |
booleanIndex++; |
521 |
res.append(translation); |
522 |
} |
523 |
|
524 |
if (endIndex < expresion.length()) {
|
525 |
res.append(expresion.substring(endIndex)); |
526 |
} |
527 |
|
528 |
return res.toString();
|
529 |
} |
530 |
|
531 |
/**
|
532 |
* DOCUMENT ME!
|
533 |
*
|
534 |
* @param expresion
|
535 |
* DOCUMENT ME!
|
536 |
*
|
537 |
* @return DOCUMENT ME!
|
538 |
*
|
539 |
* @throws ParseException
|
540 |
* DOCUMENT ME!
|
541 |
*/
|
542 |
private String translateDates(String expresion) throws ParseException { |
543 |
// Se obtiene el valor de la fecha
|
544 |
String date =
|
545 |
StringUtilities.substringDelimited(expresion, "Date(", ")", 0); |
546 |
|
547 |
if (date == null) { |
548 |
return expresion;
|
549 |
} |
550 |
|
551 |
// Se comprueba que no est? entre comillas
|
552 |
int startIndex = expresion.indexOf(date);
|
553 |
|
554 |
while (startIndex != -1) { |
555 |
if (!StringUtilities.isBetweenSymbols(expresion, startIndex, "\"")) { |
556 |
// Se sustituye por el valor ordinal de la fecha
|
557 |
expresion = |
558 |
expresion.substring(0, startIndex - 5) |
559 |
+ expresion.substring(startIndex).replaceFirst( |
560 |
date + "\\)",
|
561 |
new Long((filterButtonsJPanel.getDateFormat() |
562 |
.parse(date)).getTime()).toString()); |
563 |
; |
564 |
} else {
|
565 |
startIndex += date.length(); |
566 |
} |
567 |
|
568 |
// Se obtiene el valor de la fecha
|
569 |
|
570 |
/*
|
571 |
* date = StringUtilities.substringDelimited(expresion, "Date(",
|
572 |
* ")",
|
573 |
* startIndex);
|
574 |
*/
|
575 |
if (date == null) { |
576 |
return expresion;
|
577 |
} |
578 |
|
579 |
startIndex = expresion.indexOf(date, startIndex); |
580 |
} |
581 |
|
582 |
return expresion;
|
583 |
} |
584 |
|
585 |
/**
|
586 |
* DOCUMENT ME!
|
587 |
*
|
588 |
* @param expresion
|
589 |
* DOCUMENT ME!
|
590 |
*
|
591 |
* @return DOCUMENT ME!
|
592 |
*
|
593 |
* @throws ParseException
|
594 |
* DOCUMENT ME!
|
595 |
*/
|
596 |
public String translateNumber(String expresion) throws ParseException { |
597 |
DefaultCharSet ss = new DefaultCharSet();
|
598 |
ss.addInterval('0', '9'); |
599 |
ss.addCharacter(',');
|
600 |
ss.addCharacter('.');
|
601 |
|
602 |
String number = StringUtilities.substringWithSymbols(expresion, ss, 0); |
603 |
|
604 |
if (number == null) { |
605 |
return expresion;
|
606 |
} |
607 |
|
608 |
int startIndex = expresion.indexOf(number);
|
609 |
|
610 |
while (startIndex != -1) { |
611 |
Number n = nf.parse(number);
|
612 |
|
613 |
if (!StringUtilities.isBetweenSymbols(expresion, startIndex, "\"")) { |
614 |
// Se sustituye por el valor ordinal de la fecha
|
615 |
expresion = |
616 |
expresion.substring(0, startIndex)
|
617 |
+ expresion.substring(startIndex).replaceFirst(number, |
618 |
n.toString()); |
619 |
} else {
|
620 |
startIndex += n.toString().length(); |
621 |
} |
622 |
|
623 |
number = |
624 |
StringUtilities.substringWithSymbols(expresion, ss, startIndex); |
625 |
|
626 |
if (number == null) { |
627 |
return expresion;
|
628 |
} |
629 |
|
630 |
startIndex = expresion.indexOf(number, startIndex); |
631 |
} |
632 |
|
633 |
return expresion;
|
634 |
} |
635 |
|
636 |
/**
|
637 |
* DOCUMENT ME!
|
638 |
*
|
639 |
* @param arg0
|
640 |
*
|
641 |
* @return
|
642 |
*/
|
643 |
public boolean addExpressionListener(ExpressionListener arg0) { |
644 |
return expressionListeners.add(arg0);
|
645 |
} |
646 |
|
647 |
/**
|
648 |
* DOCUMENT ME!
|
649 |
*
|
650 |
* @param arg0
|
651 |
*
|
652 |
* @return
|
653 |
*/
|
654 |
public boolean removeExpressionListener(ExpressionListener arg0) { |
655 |
return expressionListeners.remove(arg0);
|
656 |
} |
657 |
|
658 |
/**
|
659 |
* @see com.iver.mdiApp.ui.MDIManager.IWindow#getWindowInfo()
|
660 |
*/
|
661 |
public WindowInfo getWindowInfo() {
|
662 |
WindowInfo vi = new WindowInfo(WindowInfo.ICONIFIABLE);
|
663 |
|
664 |
// if (System.getProperty("os.name")co.compareTo(arg0))
|
665 |
vi.setHeight(this.filterDialog_Height);
|
666 |
vi.setWidth(this.filterDialog_Width);
|
667 |
|
668 |
// Old instructions
|
669 |
// vi.setWidth(480);
|
670 |
// vi.setHeight(362);
|
671 |
vi |
672 |
.setTitle(PluginServices.getText(this, "_Selection_by_attributes") + " (" + title |
673 |
+ ")");
|
674 |
return vi;
|
675 |
} |
676 |
|
677 |
/**
|
678 |
* DOCUMENT ME!
|
679 |
*
|
680 |
* @param o
|
681 |
* DOCUMENT ME!
|
682 |
*/
|
683 |
public void addExceptionListener(ExceptionListener o) { |
684 |
exceptionHandlingSupport.addExceptionListener(o); |
685 |
} |
686 |
|
687 |
/**
|
688 |
* DOCUMENT ME!
|
689 |
*
|
690 |
* @param o
|
691 |
* DOCUMENT ME!
|
692 |
*
|
693 |
* @return DOCUMENT ME!
|
694 |
*/
|
695 |
public boolean removeExceptionListener(ExceptionListener o) { |
696 |
return exceptionHandlingSupport.removeExceptionListener(o);
|
697 |
} |
698 |
|
699 |
/**
|
700 |
* DOCUMENT ME!
|
701 |
*
|
702 |
* @param t
|
703 |
* DOCUMENT ME!
|
704 |
*/
|
705 |
private void throwException(Throwable t) { |
706 |
exceptionHandlingSupport.throwException(t); |
707 |
} |
708 |
|
709 |
/*
|
710 |
* (non-Javadoc)
|
711 |
*
|
712 |
* @see com.iver.andami.ui.mdiManager.ViewListener#viewActivated()
|
713 |
*/
|
714 |
public void windowActivated() { |
715 |
} |
716 |
|
717 |
/*
|
718 |
* (non-Javadoc)
|
719 |
*
|
720 |
* @see com.iver.andami.ui.mdiManager.ViewListener#viewClosed()
|
721 |
*/
|
722 |
public void windowClosed() { |
723 |
// try {
|
724 |
// model.stop();
|
725 |
// } catch (ReadDriverException e) {
|
726 |
// NotificationManager.addError(e.getMessage(), e);
|
727 |
// }
|
728 |
} |
729 |
|
730 |
public Object getWindowProfile() { |
731 |
return WindowInfo.TOOL_PROFILE;
|
732 |
} |
733 |
} |