Revision 21743 branches/v2_0_0_prep/applications/appgvSIG/src/com/iver/cit/gvsig/gui/filter/FilterDialog.java
FilterDialog.java | ||
---|---|---|
46 | 46 |
import java.text.ParseException; |
47 | 47 |
import java.util.ArrayList; |
48 | 48 |
import java.util.Comparator; |
49 |
import java.util.Date; |
|
49 | 50 |
import java.util.Iterator; |
50 | 51 |
import java.util.TreeSet; |
51 | 52 |
import java.util.regex.Matcher; |
... | ... | |
55 | 56 |
import javax.swing.tree.DefaultTreeModel; |
56 | 57 |
|
57 | 58 |
import org.apache.log4j.Logger; |
59 |
import org.gvsig.fmap.mapcontext.rendering.legend.NullValue; |
|
58 | 60 |
import org.gvsig.gui.beans.filterPanel.tableFilterQueryPanel.TableFilterQueryJPanel; |
59 | 61 |
|
60 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
61 |
import com.hardcode.gdbms.engine.instruction.IncompatibleTypesException; |
|
62 |
import com.hardcode.gdbms.engine.values.BooleanValue; |
|
63 |
import com.hardcode.gdbms.engine.values.DateValue; |
|
64 |
import com.hardcode.gdbms.engine.values.NullValue; |
|
65 |
import com.hardcode.gdbms.engine.values.StringValue; |
|
66 |
import com.hardcode.gdbms.engine.values.Value; |
|
67 | 62 |
import com.iver.andami.PluginServices; |
68 |
import com.iver.andami.messages.NotificationManager; |
|
69 | 63 |
import com.iver.andami.ui.mdiManager.IWindow; |
70 | 64 |
import com.iver.andami.ui.mdiManager.IWindowListener; |
71 | 65 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
... | ... | |
227 | 221 |
*/ |
228 | 222 |
public void mouseClicked(MouseEvent e) { |
229 | 223 |
if (e.getClickCount() == 2) { |
230 |
Value valor = (Value) valuesListModel.getElementAt(getValuesJList().getSelectedIndex());
|
|
224 |
Object valor = (Object) valuesListModel.getElementAt(getValuesJList().getSelectedIndex());
|
|
231 | 225 |
|
232 |
if (valor instanceof DateValue) {
|
|
226 |
if (valor instanceof Date) { |
|
233 | 227 |
putSymbol("date('" + valor + "')"); |
234 |
} else if (valor instanceof BooleanValue) {
|
|
228 |
} else if (valor instanceof Boolean) { |
|
235 | 229 |
putSymbol("boolean('" + valor.toString() + "')"); |
236 |
} else if (valor instanceof StringValue) {
|
|
230 |
} else if (valor instanceof String) { |
|
237 | 231 |
putSymbol("'" + valor + "'"); |
238 | 232 |
} else { |
239 | 233 |
putSymbol(valor.toString()); |
... | ... | |
254 | 248 |
TreeSet conjunto = new TreeSet(new Comparator() { |
255 | 249 |
public int compare(Object o1, Object o2) { |
256 | 250 |
if ((o1 != null) && (o2 != null)) { |
257 |
Value v2 = (Value) o2;
|
|
258 |
Value v1 = (Value) o1;
|
|
259 |
BooleanValue boolVal;
|
|
251 |
Object v2 = (Object) o2;
|
|
252 |
Object v1 = (Object) o1;
|
|
253 |
Boolean boolVal; |
|
260 | 254 |
|
261 |
try { |
|
262 |
boolVal = (BooleanValue) (v1.greater(v2)); |
|
263 |
|
|
264 |
if (boolVal.getValue()) { |
|
265 |
return 1; |
|
255 |
// try { |
|
256 |
if (v1!=null && v2!=null){ |
|
257 |
if (v1 instanceof Number && v2 instanceof Number){ |
|
258 |
if(((Number)v1).doubleValue()>((Number)v2).doubleValue()){ |
|
259 |
return 1; |
|
260 |
}else if (((Number)v1).doubleValue()<((Number)v2).doubleValue()){ |
|
261 |
return -1; |
|
262 |
} |
|
263 |
return 0; |
|
264 |
}else if (v1 instanceof Date && v2 instanceof Date){ |
|
265 |
return ((Date)v1).compareTo((Date)v2); |
|
266 |
}else if (v1 instanceof String && v2 instanceof String){ |
|
267 |
return ((String)v1).compareTo((String)v2); |
|
268 |
} |
|
266 | 269 |
} |
270 |
// boolVal = (Boolean) (v1.greater(v2)); |
|
267 | 271 |
|
268 |
boolVal = (BooleanValue) (v1.less(v2)); |
|
272 |
// if (boolVal.getValue()) { |
|
273 |
// return 1; |
|
274 |
// } |
|
269 | 275 |
|
270 |
if (boolVal.getValue()) { |
|
271 |
return -1; |
|
272 |
} |
|
273 |
} catch (IncompatibleTypesException e) { |
|
274 |
throw new RuntimeException(e); |
|
275 |
} |
|
276 |
// boolVal = (BooleanValue) (v1.less(v2)); |
|
277 |
// |
|
278 |
// if (boolVal.getValue()) { |
|
279 |
// return -1; |
|
280 |
// } |
|
281 |
// } catch (IncompatibleTypesException e) { |
|
282 |
// throw new RuntimeException(e); |
|
283 |
// } |
|
276 | 284 |
} |
277 | 285 |
|
278 | 286 |
return 0; |
... | ... | |
283 | 291 |
valuesListModel.clear(); |
284 | 292 |
try { |
285 | 293 |
for (int i = 0; i < model.getRowCount(); i++) { |
286 |
Value value = model.getFieldValue(i, row);
|
|
294 |
Object value = model.getFieldValue(i, row);
|
|
287 | 295 |
|
288 | 296 |
if (value instanceof NullValue) |
289 | 297 |
continue; |
... | ... | |
308 | 316 |
* @param t DOCUMENT ME! |
309 | 317 |
*/ |
310 | 318 |
public void setModel(ExpressionDataSource t) { |
311 |
try { |
|
319 |
// try {
|
|
312 | 320 |
model = t; |
313 |
model.start(); |
|
314 |
} catch (ReadDriverException e1) {
|
|
315 |
NotificationManager.addError(e1.getMessage(), e1); |
|
316 |
} |
|
321 |
// model.start();
|
|
322 |
// } catch (ReadException e1) {
|
|
323 |
// NotificationManager.addError(e1.getMessage(), e1);
|
|
324 |
// }
|
|
317 | 325 |
|
318 | 326 |
jtreeRoot.removeAllChildren(); |
319 | 327 |
|
... | ... | |
619 | 627 |
* @see com.iver.andami.ui.mdiManager.ViewListener#viewClosed() |
620 | 628 |
*/ |
621 | 629 |
public void windowClosed() { |
622 |
try { |
|
623 |
model.stop(); |
|
624 |
} catch (ReadDriverException e) { |
|
625 |
NotificationManager.addError(e.getMessage(), e); |
|
626 |
} |
|
630 |
// try {
|
|
631 |
// model.stop();
|
|
632 |
// } catch (ReadDriverException e) {
|
|
633 |
// NotificationManager.addError(e.getMessage(), e);
|
|
634 |
// }
|
|
627 | 635 |
} |
628 | 636 |
} |
Also available in: Unified diff