root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / filter / FilterDialog.java @ 24986
History | View | Annotate | Download (16.4 KB)
1 | 1103 | fjp | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
4 | *
|
||
5 | * This program is free software; you can redistribute it and/or
|
||
6 | * modify it under the terms of the GNU General Public License
|
||
7 | * as published by the Free Software Foundation; either version 2
|
||
8 | * of the License, or (at your option) any later version.
|
||
9 | *
|
||
10 | * This program is distributed in the hope that it will be useful,
|
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | * GNU General Public License for more details.
|
||
14 | *
|
||
15 | * You should have received a copy of the GNU General Public License
|
||
16 | * along with this program; if not, write to the Free Software
|
||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
18 | *
|
||
19 | * For more information, contact:
|
||
20 | *
|
||
21 | * Generalitat Valenciana
|
||
22 | * Conselleria d'Infraestructures i Transport
|
||
23 | * Av. Blasco Ib??ez, 50
|
||
24 | * 46010 VALENCIA
|
||
25 | * SPAIN
|
||
26 | *
|
||
27 | * +34 963862235
|
||
28 | * gvsig@gva.es
|
||
29 | * www.gvsig.gva.es
|
||
30 | *
|
||
31 | * or
|
||
32 | *
|
||
33 | * IVER T.I. S.A
|
||
34 | * Salamanca 50
|
||
35 | * 46005 Valencia
|
||
36 | * Spain
|
||
37 | *
|
||
38 | * +34 963163400
|
||
39 | * dac@iver.es
|
||
40 | */
|
||
41 | 856 | fernando | package com.iver.cit.gvsig.gui.filter; |
42 | |||
43 | 9488 | ppiqueras | import java.awt.event.MouseAdapter; |
44 | import java.awt.event.MouseEvent; |
||
45 | 1830 | fernando | import java.text.NumberFormat; |
46 | import java.text.ParseException; |
||
47 | import java.util.ArrayList; |
||
48 | import java.util.Comparator; |
||
49 | import java.util.Iterator; |
||
50 | import java.util.TreeSet; |
||
51 | import java.util.regex.Matcher; |
||
52 | import java.util.regex.Pattern; |
||
53 | |||
54 | 9488 | ppiqueras | import javax.swing.tree.DefaultMutableTreeNode; |
55 | import javax.swing.tree.DefaultTreeModel; |
||
56 | 1830 | fernando | |
57 | import org.apache.log4j.Logger; |
||
58 | 9488 | ppiqueras | import org.gvsig.gui.beans.filterPanel.tableFilterQueryPanel.TableFilterQueryJPanel; |
59 | 1830 | fernando | |
60 | 10626 | caballero | import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
61 | 1146 | fernando | import com.hardcode.gdbms.engine.instruction.IncompatibleTypesException; |
62 | import com.hardcode.gdbms.engine.values.BooleanValue; |
||
63 | import com.hardcode.gdbms.engine.values.DateValue; |
||
64 | 2496 | fernando | import com.hardcode.gdbms.engine.values.NullValue; |
65 | 1146 | fernando | import com.hardcode.gdbms.engine.values.StringValue; |
66 | import com.hardcode.gdbms.engine.values.Value; |
||
67 | import com.iver.andami.PluginServices; |
||
68 | 1365 | fjp | import com.iver.andami.messages.NotificationManager; |
69 | 6877 | cesar | import com.iver.andami.ui.mdiManager.IWindow; |
70 | 7738 | jaume | import com.iver.andami.ui.mdiManager.IWindowListener; |
71 | 6880 | cesar | import com.iver.andami.ui.mdiManager.WindowInfo; |
72 | 7304 | caballero | import com.iver.cit.gvsig.project.documents.table.gui.Table; |
73 | 1146 | fernando | import com.iver.utiles.DefaultCharSet; |
74 | import com.iver.utiles.StringUtilities; |
||
75 | import com.iver.utiles.exceptionHandling.ExceptionHandlingSupport; |
||
76 | import com.iver.utiles.exceptionHandling.ExceptionListener; |
||
77 | |||
78 | 856 | fernando | /**
|
79 | 9488 | ppiqueras | * This class substitutes the old "FilterDialog" class made by "Fernando Gonz?lez Cort?s"
|
80 | * The functionality is the same, but now the class is made from separately (and reusable) components
|
||
81 | 10626 | caballero | *
|
82 | 9488 | ppiqueras | * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
|
83 | 856 | fernando | */
|
84 | 9488 | ppiqueras | public class FilterDialog extends TableFilterQueryJPanel implements IWindow, IWindowListener { |
85 | 856 | fernando | private static Logger logger = Logger.getLogger(Table.class.getName()); |
86 | 1146 | fernando | private ExpressionDataSource model = null; |
87 | 9488 | ppiqueras | private ArrayList expressionListeners = new ArrayList(); |
88 | 1146 | fernando | private ExceptionHandlingSupport exceptionHandlingSupport = new ExceptionHandlingSupport(); |
89 | 9488 | ppiqueras | private NumberFormat nf = NumberFormat.getNumberInstance(); |
90 | 10626 | caballero | |
91 | 7028 | ldiaz | private String title; |
92 | 10626 | caballero | |
93 | 9493 | ppiqueras | private final int filterDialog_Width = 500; |
94 | 9488 | ppiqueras | private final int filterDialog_Height = 362; |
95 | 9493 | ppiqueras | private final int widthIncrementForAndami = 20; // This is necessary because when the panel is sent to Andami, that needs a bit more width-space to show that panel. |
96 | 856 | fernando | |
97 | 9488 | ppiqueras | |
98 | 1146 | fernando | /**
|
99 | * This is the default constructor
|
||
100 | */
|
||
101 | 10626 | caballero | public FilterDialog(String _title) { |
102 | 1146 | fernando | super();
|
103 | 7028 | ldiaz | title = _title; |
104 | 9488 | ppiqueras | defaultTreeModel = (DefaultTreeModel)fieldsJTree.getModel();
|
105 | 1146 | fernando | } |
106 | 7028 | ldiaz | /**
|
107 | * This is the default constructor
|
||
108 | */
|
||
109 | 10626 | caballero | public FilterDialog() {
|
110 | 7028 | ldiaz | super();
|
111 | 9488 | ppiqueras | defaultTreeModel = (DefaultTreeModel)fieldsJTree.getModel();
|
112 | 7028 | ldiaz | } |
113 | 10626 | caballero | |
114 | 9488 | ppiqueras | /*
|
115 | * (non-Javadoc)
|
||
116 | * @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#initialize()
|
||
117 | */
|
||
118 | protected void initialize() { |
||
119 | super.initialize();
|
||
120 | 10626 | caballero | |
121 | 9493 | ppiqueras | super.resizeHeight(filterDialog_Height);
|
122 | super.resizeWidth(filterDialog_Width - widthIncrementForAndami);
|
||
123 | 10626 | caballero | |
124 | 9488 | ppiqueras | this.addNewListeners();
|
125 | } |
||
126 | 10626 | caballero | |
127 | 1146 | fernando | /**
|
128 | 9488 | ppiqueras | * Adds some listeners
|
129 | 1146 | fernando | */
|
130 | 9488 | ppiqueras | private void addNewListeners() { |
131 | // Listener for "btnAdd"
|
||
132 | 9493 | ppiqueras | // Adds more elements to the current set
|
133 | getBtnAddToCurrentSet().addActionListener(new java.awt.event.ActionListener() {
|
||
134 | 9488 | ppiqueras | /*
|
135 | * (non-Javadoc)
|
||
136 | * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
||
137 | */
|
||
138 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
139 | final String expr = "select * from '" + |
||
140 | model.getDataSourceName() + "' where " +
|
||
141 | getTxtExpression().getText() + ";";
|
||
142 | 1146 | fernando | |
143 | 9488 | ppiqueras | logger.debug(expr); |
144 | |||
145 | PluginServices.backgroundExecution(new Runnable() { |
||
146 | public void run() { |
||
147 | for (int i = 0; |
||
148 | i < expressionListeners.size(); |
||
149 | i++) { |
||
150 | ExpressionListener l = (ExpressionListener) expressionListeners.get(i); |
||
151 | l.addToSet(expr); |
||
152 | } |
||
153 | } |
||
154 | }); |
||
155 | 856 | fernando | } |
156 | 9488 | ppiqueras | }); |
157 | 856 | fernando | |
158 | 9488 | ppiqueras | // Listener for "btnNuevo"
|
159 | 9493 | ppiqueras | // Adds a new set
|
160 | getBtnNewSet().addActionListener(new java.awt.event.ActionListener() {
|
||
161 | 9488 | ppiqueras | public void actionPerformed(java.awt.event.ActionEvent e) { |
162 | final String expr = "select * from '" + |
||
163 | model.getDataSourceName() + "' where " +
|
||
164 | getTxtExpression().getText() + ";";
|
||
165 | |||
166 | logger.debug(expr); |
||
167 | |||
168 | PluginServices.backgroundExecution(new Runnable() { |
||
169 | public void run() { |
||
170 | for (int i = 0; i < expressionListeners.size(); i++) { |
||
171 | ExpressionListener l = (ExpressionListener) expressionListeners.get(i); |
||
172 | l.newSet(expr); |
||
173 | } |
||
174 | } |
||
175 | }); |
||
176 | } |
||
177 | }); |
||
178 | 10626 | caballero | |
179 | 9488 | ppiqueras | // Listener for "btnFromSet"
|
180 | 9493 | ppiqueras | // Selects elements in the table that are according the current filter condition
|
181 | 9488 | ppiqueras | getBtnFromSet().addActionListener(new java.awt.event.ActionListener() {
|
182 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
183 | final String expr = "select * from '" + |
||
184 | model.getDataSourceName() + "' where " +
|
||
185 | getTxtExpression().getText() + ";";
|
||
186 | |||
187 | logger.debug(expr); |
||
188 | |||
189 | PluginServices.backgroundExecution(new Runnable() { |
||
190 | public void run() { |
||
191 | for (int i = 0; i < expressionListeners.size(); i++) { |
||
192 | ExpressionListener l = (ExpressionListener) expressionListeners.get(i); |
||
193 | l.fromSet(expr); |
||
194 | } |
||
195 | } |
||
196 | }); |
||
197 | } |
||
198 | }); |
||
199 | 10626 | caballero | |
200 | // Listener for "fieldsJTree"
|
||
201 | 9488 | ppiqueras | getFieldsJTree().addMouseListener(new MouseAdapter() { |
202 | /*
|
||
203 | * (non-Javadoc)
|
||
204 | * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
||
205 | */
|
||
206 | public void mouseClicked(MouseEvent e) { |
||
207 | int row = fieldsJTree.getRowForLocation(e.getX(), e.getY());
|
||
208 | 10626 | caballero | |
209 | 9488 | ppiqueras | if (row > -1) { |
210 | switch (e.getClickCount()) {
|
||
211 | case 1: |
||
212 | fillValues(row); |
||
213 | break;
|
||
214 | 10626 | caballero | case 2: |
215 | 9488 | ppiqueras | putSymbol(jtreeRoot.getChildAt(row).toString()); |
216 | break;
|
||
217 | } |
||
218 | } |
||
219 | } |
||
220 | }); |
||
221 | 10626 | caballero | |
222 | 9488 | ppiqueras | // Listener for "valuesJList"
|
223 | getValuesJList().addMouseListener(new MouseAdapter() { |
||
224 | /*
|
||
225 | * (non-Javadoc)
|
||
226 | * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
||
227 | */
|
||
228 | public void mouseClicked(MouseEvent e) { |
||
229 | if (e.getClickCount() == 2) { |
||
230 | Value valor = (Value) valuesListModel.getElementAt(getValuesJList().getSelectedIndex()); |
||
231 | |||
232 | if (valor instanceof DateValue) { |
||
233 | putSymbol("date('" + valor + "')"); |
||
234 | } else if (valor instanceof BooleanValue) { |
||
235 | putSymbol("boolean('" + valor.toString() + "')"); |
||
236 | } else if (valor instanceof StringValue) { |
||
237 | putSymbol("'" + valor + "'"); |
||
238 | } else {
|
||
239 | putSymbol(valor.toString()); |
||
240 | 10626 | caballero | } |
241 | 9488 | ppiqueras | } |
242 | } |
||
243 | }); |
||
244 | 10626 | caballero | } |
245 | |||
246 | 1146 | fernando | /**
|
247 | * Rellena la lista con los valores del campo seleccionado
|
||
248 | */
|
||
249 | 9488 | ppiqueras | private void fillValues(int row) { |
250 | //int index = lstCampos.getSelectedIndex();
|
||
251 | 856 | fernando | |
252 | 1146 | fernando | //Index es ahora el ?ndice del campo seleccionado
|
253 | //Se eliminan los duplicados
|
||
254 | TreeSet conjunto = new TreeSet(new Comparator() { |
||
255 | 5591 | jaume | public int compare(Object o1, Object o2) { |
256 | if ((o1 != null) && (o2 != null)) { |
||
257 | Value v2 = (Value) o2; |
||
258 | Value v1 = (Value) o1; |
||
259 | BooleanValue boolVal; |
||
260 | 10626 | caballero | |
261 | 5591 | jaume | try {
|
262 | boolVal = (BooleanValue) (v1.greater(v2)); |
||
263 | 10626 | caballero | |
264 | 5591 | jaume | if (boolVal.getValue()) {
|
265 | return 1; |
||
266 | 1077 | fjp | } |
267 | 10626 | caballero | |
268 | 5591 | jaume | boolVal = (BooleanValue) (v1.less(v2)); |
269 | 10626 | caballero | |
270 | 5591 | jaume | if (boolVal.getValue()) {
|
271 | return -1; |
||
272 | } |
||
273 | } catch (IncompatibleTypesException e) {
|
||
274 | throw new RuntimeException(e); |
||
275 | 1077 | fjp | } |
276 | 5591 | jaume | } |
277 | 10626 | caballero | |
278 | 5591 | jaume | return 0; |
279 | } |
||
280 | }); // Para poder ordenar
|
||
281 | 10626 | caballero | |
282 | |||
283 | 1146 | fernando | valuesListModel.clear(); |
284 | try {
|
||
285 | for (int i = 0; i < model.getRowCount(); i++) { |
||
286 | 9488 | ppiqueras | Value value = model.getFieldValue(i, row); |
287 | 1146 | fernando | |
288 | 2496 | fernando | if (value instanceof NullValue) |
289 | continue;
|
||
290 | 10626 | caballero | |
291 | 1146 | fernando | if (!conjunto.contains(value)) {
|
292 | 2496 | fernando | conjunto.add(value); |
293 | 1077 | fjp | } |
294 | } |
||
295 | |||
296 | 1146 | fernando | Iterator it = conjunto.iterator();
|
297 | 856 | fernando | |
298 | 1146 | fernando | while (it.hasNext())
|
299 | 1077 | fjp | valuesListModel.addElement(it.next()); |
300 | 856 | fernando | } catch (FilterException e) {
|
301 | throwException(e); |
||
302 | } |
||
303 | 1146 | fernando | } |
304 | 10626 | caballero | |
305 | 9488 | ppiqueras | /**
|
306 | * DOCUMENT ME!
|
||
307 | *
|
||
308 | * @param t DOCUMENT ME!
|
||
309 | */
|
||
310 | public void setModel(ExpressionDataSource t) { |
||
311 | try {
|
||
312 | model = t; |
||
313 | model.start(); |
||
314 | 10626 | caballero | } catch (ReadDriverException e1) {
|
315 | 9488 | ppiqueras | NotificationManager.addError(e1.getMessage(), e1); |
316 | } |
||
317 | 10626 | caballero | |
318 | 9488 | ppiqueras | jtreeRoot.removeAllChildren(); |
319 | 10626 | caballero | |
320 | 9488 | ppiqueras | try {
|
321 | for (int i = 0; i < model.getFieldCount(); i++) { |
||
322 | Object field = model.getFieldName(i);
|
||
323 | 10626 | caballero | |
324 | 9488 | ppiqueras | if (field != null) { |
325 | jtreeRoot.add(new DefaultMutableTreeNode(field.toString())); |
||
326 | } |
||
327 | } |
||
328 | 856 | fernando | |
329 | 9488 | ppiqueras | defaultTreeModel.setRoot(jtreeRoot); |
330 | } catch (FilterException e) {
|
||
331 | throwException(e); |
||
332 | } |
||
333 | } |
||
334 | 10626 | caballero | |
335 | 9488 | ppiqueras | /**
|
336 | * DOCUMENT ME!
|
||
337 | *
|
||
338 | * @return DOCUMENT ME!
|
||
339 | *
|
||
340 | * @throws ParseException DOCUMENT ME!
|
||
341 | */
|
||
342 | private String validateExpression() throws ParseException { |
||
343 | String expression = txtExpression.getText();
|
||
344 | // HashSet variablesIndexes = new HashSet();
|
||
345 | //
|
||
346 | // StringBuffer traducida = new StringBuffer();
|
||
347 | 10626 | caballero | |
348 | 9488 | ppiqueras | //Se transforman los nombres de los campos en las variables xix que analizar?n
|
349 | //Se quitan los Date(fecha) y se mete la fecha correspondiente
|
||
350 | expression = translateDates(expression); |
||
351 | expression = translateNumber(expression); |
||
352 | expression = translateWord(expression, "true", "1"); |
||
353 | expression = translateWord(expression, "false", "0"); |
||
354 | 10626 | caballero | |
355 | 9488 | ppiqueras | String replacement;
|
356 | Pattern patron = Pattern.compile("[^<>!]="); |
||
357 | Matcher m = patron.matcher(expression);
|
||
358 | int index = 0; |
||
359 | 10626 | caballero | |
360 | 9488 | ppiqueras | while (m.find(index)) {
|
361 | index = m.start(); |
||
362 | replacement = expression.charAt(index) + "==";
|
||
363 | m.replaceFirst(replacement); |
||
364 | index++; |
||
365 | } |
||
366 | 10626 | caballero | |
367 | 9488 | ppiqueras | expression = expression.replaceAll("[^<>!]=", "=="); |
368 | 10626 | caballero | |
369 | 9488 | ppiqueras | logger.debug(expression); |
370 | 10626 | caballero | |
371 | 9488 | ppiqueras | return expression;
|
372 | } |
||
373 | 1146 | fernando | /**
|
374 | 9488 | ppiqueras | * Redefinition of the 'putSymbol' method of AbstractFilterQueryJPanel
|
375 | * (I've made this redefinition for write the same code as the 'putSymbol'
|
||
376 | * code of the original class (FilterDialog) that was in this project
|
||
377 | * (appgvSIG) and didn't has path troubles to find 'StringUtilities').
|
||
378 | 10626 | caballero | *
|
379 | 9488 | ppiqueras | * Sets a symbol on the filter expression (JTextArea that stores and shows
|
380 | * the current filter expression)
|
||
381 | *
|
||
382 | * @param symbol A symbol: character, characters, number, ...
|
||
383 | */
|
||
384 | protected void putSymbol(String symbol) { |
||
385 | int position = txtExpression.getCaretPosition();
|
||
386 | txtExpression.setText(StringUtilities.insert(txtExpression.getText(), |
||
387 | position, symbol)); |
||
388 | |||
389 | if (symbol.equals(" () ")) { |
||
390 | position = position + 2;
|
||
391 | } else {
|
||
392 | position = position + symbol.length(); |
||
393 | } |
||
394 | |||
395 | txtExpression.setCaretPosition(position); |
||
396 | } |
||
397 | 10626 | caballero | |
398 | 9488 | ppiqueras | /**
|
399 | 1146 | fernando | * DOCUMENT ME!
|
400 | *
|
||
401 | * @param expresion DOCUMENT ME!
|
||
402 | * @param substring DOCUMENT ME!
|
||
403 | * @param startingPos DOCUMENT ME!
|
||
404 | *
|
||
405 | * @return DOCUMENT ME!
|
||
406 | */
|
||
407 | private int getIndex(String expresion, String substring, int startingPos) { |
||
408 | int index = startingPos;
|
||
409 | 856 | fernando | |
410 | 1146 | fernando | do {
|
411 | index = expresion.indexOf(substring, index); |
||
412 | } while ((StringUtilities.isBetweenSymbols(expresion, index, "\"")) && |
||
413 | (index != -1));
|
||
414 | 856 | fernando | |
415 | 1146 | fernando | return index;
|
416 | } |
||
417 | 10626 | caballero | |
418 | 1146 | fernando | /**
|
419 | * DOCUMENT ME!
|
||
420 | *
|
||
421 | * @param expresion DOCUMENT ME!
|
||
422 | * @param word DOCUMENT ME!
|
||
423 | * @param translation DOCUMENT ME!
|
||
424 | *
|
||
425 | * @return DOCUMENT ME!
|
||
426 | *
|
||
427 | * @throws ParseException DOCUMENT ME!
|
||
428 | */
|
||
429 | private String translateWord(String expresion, String word, |
||
430 | String translation) throws ParseException { |
||
431 | int booleanIndex = 0; |
||
432 | int endIndex = 0; |
||
433 | StringBuffer res = new StringBuffer(); |
||
434 | 856 | fernando | |
435 | 1146 | fernando | while ((booleanIndex = getIndex(expresion, word, booleanIndex)) != -1) { |
436 | res.append(expresion.substring(endIndex, booleanIndex)); |
||
437 | endIndex = booleanIndex + word.length(); |
||
438 | booleanIndex++; |
||
439 | res.append(translation); |
||
440 | } |
||
441 | 856 | fernando | |
442 | 1146 | fernando | if (endIndex < expresion.length()) {
|
443 | res.append(expresion.substring(endIndex)); |
||
444 | } |
||
445 | 856 | fernando | |
446 | 1146 | fernando | return res.toString();
|
447 | } |
||
448 | 856 | fernando | |
449 | 1146 | fernando | /**
|
450 | * DOCUMENT ME!
|
||
451 | *
|
||
452 | * @param expresion DOCUMENT ME!
|
||
453 | *
|
||
454 | * @return DOCUMENT ME!
|
||
455 | *
|
||
456 | * @throws ParseException DOCUMENT ME!
|
||
457 | */
|
||
458 | private String translateDates(String expresion) throws ParseException { |
||
459 | //Se obtiene el valor de la fecha
|
||
460 | String date = StringUtilities.substringDelimited(expresion, "Date(", |
||
461 | ")", 0); |
||
462 | 856 | fernando | |
463 | 1146 | fernando | if (date == null) { |
464 | return expresion;
|
||
465 | } |
||
466 | 856 | fernando | |
467 | 10626 | caballero | //Se comprueba que no est? entre comillas
|
468 | 1146 | fernando | int startIndex = expresion.indexOf(date);
|
469 | 856 | fernando | |
470 | 1146 | fernando | while (startIndex != -1) { |
471 | if (!StringUtilities.isBetweenSymbols(expresion, startIndex, "\"")) { |
||
472 | //Se sustituye por el valor ordinal de la fecha
|
||
473 | expresion = expresion.substring(0, startIndex - 5) + |
||
474 | expresion.substring(startIndex).replaceFirst(date + "\\)",
|
||
475 | 9488 | ppiqueras | new Long((filterButtonsJPanel.getDateFormat().parse(date)).getTime()).toString()); |
476 | 1146 | fernando | ; |
477 | } else {
|
||
478 | startIndex += date.length(); |
||
479 | } |
||
480 | 856 | fernando | |
481 | 1146 | fernando | //Se obtiene el valor de la fecha
|
482 | 856 | fernando | |
483 | 1146 | fernando | /* date = StringUtilities.substringDelimited(expresion, "Date(", ")",
|
484 | startIndex);
|
||
485 | */
|
||
486 | if (date == null) { |
||
487 | return expresion;
|
||
488 | } |
||
489 | 856 | fernando | |
490 | 1146 | fernando | startIndex = expresion.indexOf(date, startIndex); |
491 | } |
||
492 | 856 | fernando | |
493 | 1146 | fernando | return expresion;
|
494 | } |
||
495 | 856 | fernando | |
496 | 1146 | fernando | /**
|
497 | * DOCUMENT ME!
|
||
498 | *
|
||
499 | * @param expresion DOCUMENT ME!
|
||
500 | *
|
||
501 | * @return DOCUMENT ME!
|
||
502 | *
|
||
503 | * @throws ParseException DOCUMENT ME!
|
||
504 | */
|
||
505 | public String translateNumber(String expresion) throws ParseException { |
||
506 | DefaultCharSet ss = new DefaultCharSet();
|
||
507 | ss.addInterval('0', '9'); |
||
508 | ss.addCharacter(',');
|
||
509 | ss.addCharacter('.');
|
||
510 | 856 | fernando | |
511 | 1146 | fernando | String number = StringUtilities.substringWithSymbols(expresion, ss, 0); |
512 | 856 | fernando | |
513 | 1146 | fernando | if (number == null) { |
514 | return expresion;
|
||
515 | } |
||
516 | 856 | fernando | |
517 | 1146 | fernando | int startIndex = expresion.indexOf(number);
|
518 | 856 | fernando | |
519 | 1146 | fernando | while (startIndex != -1) { |
520 | Number n = nf.parse(number);
|
||
521 | 856 | fernando | |
522 | 1146 | fernando | if (!StringUtilities.isBetweenSymbols(expresion, startIndex, "\"")) { |
523 | //Se sustituye por el valor ordinal de la fecha
|
||
524 | expresion = expresion.substring(0, startIndex) +
|
||
525 | expresion.substring(startIndex).replaceFirst(number, |
||
526 | n.toString()); |
||
527 | } else {
|
||
528 | startIndex += n.toString().length(); |
||
529 | } |
||
530 | 856 | fernando | |
531 | 1146 | fernando | number = StringUtilities.substringWithSymbols(expresion, ss, |
532 | startIndex); |
||
533 | 856 | fernando | |
534 | 1146 | fernando | if (number == null) { |
535 | return expresion;
|
||
536 | } |
||
537 | 856 | fernando | |
538 | 1146 | fernando | startIndex = expresion.indexOf(number, startIndex); |
539 | } |
||
540 | 856 | fernando | |
541 | 1146 | fernando | return expresion;
|
542 | } |
||
543 | 10626 | caballero | |
544 | 1146 | fernando | /**
|
545 | * DOCUMENT ME!
|
||
546 | *
|
||
547 | * @param arg0
|
||
548 | *
|
||
549 | * @return
|
||
550 | */
|
||
551 | public boolean addExpressionListener(ExpressionListener arg0) { |
||
552 | return expressionListeners.add(arg0);
|
||
553 | } |
||
554 | 856 | fernando | |
555 | 1146 | fernando | /**
|
556 | * DOCUMENT ME!
|
||
557 | *
|
||
558 | * @param arg0
|
||
559 | *
|
||
560 | * @return
|
||
561 | */
|
||
562 | public boolean removeExpressionListener(ExpressionListener arg0) { |
||
563 | return expressionListeners.remove(arg0);
|
||
564 | } |
||
565 | 10626 | caballero | |
566 | 856 | fernando | /**
|
567 | 6880 | cesar | * @see com.iver.mdiApp.ui.MDIManager.IWindow#getWindowInfo()
|
568 | 856 | fernando | */
|
569 | 6880 | cesar | public WindowInfo getWindowInfo() {
|
570 | WindowInfo vi = new WindowInfo(WindowInfo.ICONIFIABLE);
|
||
571 | 9493 | ppiqueras | |
572 | //if (System.getProperty("os.name")co.compareTo(arg0))
|
||
573 | vi.setHeight(this.filterDialog_Height);
|
||
574 | vi.setWidth(this.filterDialog_Width);
|
||
575 | |||
576 | // Old instructions
|
||
577 | 9488 | ppiqueras | // vi.setWidth(480);
|
578 | // vi.setHeight(362);
|
||
579 | 7028 | ldiaz | vi.setTitle(PluginServices.getText( this, "filtro") + " (" + title + ")"); |
580 | 954 | fernando | return vi;
|
581 | 856 | fernando | } |
582 | 10626 | caballero | |
583 | 1146 | fernando | /**
|
584 | * DOCUMENT ME!
|
||
585 | *
|
||
586 | * @param o DOCUMENT ME!
|
||
587 | */
|
||
588 | 856 | fernando | public void addExceptionListener(ExceptionListener o) { |
589 | exceptionHandlingSupport.addExceptionListener(o); |
||
590 | } |
||
591 | 1146 | fernando | |
592 | /**
|
||
593 | * DOCUMENT ME!
|
||
594 | *
|
||
595 | * @param o DOCUMENT ME!
|
||
596 | *
|
||
597 | * @return DOCUMENT ME!
|
||
598 | */
|
||
599 | 856 | fernando | public boolean removeExceptionListener(ExceptionListener o) { |
600 | return exceptionHandlingSupport.removeExceptionListener(o);
|
||
601 | } |
||
602 | 10626 | caballero | |
603 | 1146 | fernando | /**
|
604 | * DOCUMENT ME!
|
||
605 | *
|
||
606 | * @param t DOCUMENT ME!
|
||
607 | */
|
||
608 | 856 | fernando | private void throwException(Throwable t) { |
609 | exceptionHandlingSupport.throwException(t); |
||
610 | } |
||
611 | 1365 | fjp | |
612 | /* (non-Javadoc)
|
||
613 | * @see com.iver.andami.ui.mdiManager.ViewListener#viewActivated()
|
||
614 | */
|
||
615 | 6880 | cesar | public void windowActivated() { |
616 | 1365 | fjp | } |
617 | |||
618 | /* (non-Javadoc)
|
||
619 | * @see com.iver.andami.ui.mdiManager.ViewListener#viewClosed()
|
||
620 | */
|
||
621 | 6880 | cesar | public void windowClosed() { |
622 | 1365 | fjp | try {
|
623 | model.stop(); |
||
624 | 10626 | caballero | } catch (ReadDriverException e) {
|
625 | 1365 | fjp | NotificationManager.addError(e.getMessage(), e); |
626 | 10626 | caballero | } |
627 | 1365 | fjp | } |
628 | 24986 | jcampos | public Object getWindowProfile() { |
629 | return WindowInfo.TOOL_PROFILE;
|
||
630 | } |
||
631 | 9488 | ppiqueras | } |