Revision 2557
trunk/extensions/extDataLocator/src/com/iver/gvsig/datalocator/gui/DataSelectionPanel.java | ||
---|---|---|
44 | 44 |
package com.iver.gvsig.datalocator.gui; |
45 | 45 |
|
46 | 46 |
import java.awt.event.ItemListener; |
47 |
import java.io.IOException; |
|
47 | 48 |
|
48 | 49 |
import java.util.Comparator; |
49 | 50 |
import java.util.TreeSet; |
... | ... | |
52 | 53 |
|
53 | 54 |
import javax.swing.JPanel; |
54 | 55 |
|
56 |
import com.hardcode.driverManager.DriverLoadException; |
|
55 | 57 |
import com.hardcode.gdbms.engine.data.DataSource; |
58 |
import com.hardcode.gdbms.engine.data.DataSourceFactory; |
|
59 |
import com.hardcode.gdbms.engine.instruction.EvaluationException; |
|
56 | 60 |
import com.hardcode.gdbms.engine.instruction.IncompatibleTypesException; |
61 |
import com.hardcode.gdbms.engine.instruction.SemanticException; |
|
57 | 62 |
import com.hardcode.gdbms.engine.values.BooleanValue; |
63 |
import com.hardcode.gdbms.engine.values.NullValue; |
|
58 | 64 |
import com.hardcode.gdbms.engine.values.Value; |
65 |
import com.hardcode.gdbms.parser.ParseException; |
|
59 | 66 |
import com.iver.andami.PluginServices; |
60 | 67 |
import com.iver.andami.ui.mdiManager.SingletonView; |
61 | 68 |
import com.iver.andami.ui.mdiManager.View; |
... | ... | |
216 | 223 |
Value[] newValues = null; |
217 | 224 |
try { |
218 | 225 |
ds = lyr.getRecordset(); |
226 |
String sql = "select * from " + ds.getName() + " where " + ds.getFieldName(fieldToZoomIndex) + " is not null;"; |
|
227 |
ds = ds.getDataSourceFactory().executeSQL(sql, DataSourceFactory.CLOSING_AUTOMATIC_MODE); |
|
219 | 228 |
Value[] values = new Value[(int)ds.getRowCount()]; |
220 | 229 |
for (int i=0;i<ds.getRowCount();i++) { |
221 | 230 |
Value value = ds.getFieldValue(i, fieldToZoomIndex); |
... | ... | |
249 | 258 |
} catch (com.hardcode.gdbms.engine.data.driver.DriverException eee) { |
250 | 259 |
// TODO Auto-generated catch block |
251 | 260 |
eee.printStackTrace(); |
261 |
} catch (ParseException e) { |
|
262 |
// TODO Auto-generated catch block |
|
263 |
e.printStackTrace(); |
|
264 |
} catch (DriverLoadException e) { |
|
265 |
// TODO Auto-generated catch block |
|
266 |
e.printStackTrace(); |
|
267 |
} catch (SemanticException e) { |
|
268 |
// TODO Auto-generated catch block |
|
269 |
e.printStackTrace(); |
|
270 |
} catch (IOException e) { |
|
271 |
// TODO Auto-generated catch block |
|
272 |
e.printStackTrace(); |
|
273 |
} catch (EvaluationException e) { |
|
274 |
// TODO Auto-generated catch block |
|
275 |
e.printStackTrace(); |
|
252 | 276 |
} |
253 | 277 |
return newValues; |
254 | 278 |
} |
... | ... | |
421 | 445 |
private class ChangeFieldItemListener implements ItemListener { |
422 | 446 |
public ChangeFieldItemListener(Vector layers) { |
423 | 447 |
} |
424 |
public void itemStateChanged(java.awt.event.ItemEvent e) {
|
|
448 |
public void itemStateChanged(java.awt.event.ItemEvent itemEvent) {
|
|
425 | 449 |
String fieldToZoom = ((String)jComboBox1.getSelectedItem()); |
426 | 450 |
AlphanumericData lyr = (AlphanumericData)layerToZoom; |
427 | 451 |
DataSource ds; |
... | ... | |
434 | 458 |
prefUsuario.putInt("FIELDINDEX_FOR_DATA_LOCATION", i); |
435 | 459 |
} |
436 | 460 |
} |
461 |
String sql = "select * from " + ds.getName() + " where " + ds.getFieldName(fieldToZoomIndex) + " is not null;"; |
|
462 |
ds = ds.getDataSourceFactory().executeSQL(sql, DataSourceFactory.CLOSING_AUTOMATIC_MODE); |
|
437 | 463 |
Value[] values = new Value[(int)ds.getRowCount()]; |
438 | 464 |
for (int i=0;i<ds.getRowCount();i++) { |
439 | 465 |
Value value = ds.getFieldValue(i, fieldToZoomIndex); |
440 |
values[i] = value;
|
|
466 |
values[i] = value;
|
|
441 | 467 |
} |
442 | 468 |
//Quitar los nombres repetidos y ordenarlos |
443 | 469 |
TreeSet treeSet = new TreeSet(new Comparator() { |
... | ... | |
463 | 489 |
Value[] newValues = (Value[])treeSet.toArray(new Value[0]); |
464 | 490 |
DefaultComboBoxModel defaultModel = new DefaultComboBoxModel(newValues); |
465 | 491 |
jComboBox2.setModel(defaultModel); |
466 |
jComboBox2.setSelectedIndex(0); |
|
467 |
itemToZoom = newValues[0]; |
|
492 |
if (newValues.length>0) jComboBox2.setSelectedIndex(0); |
|
493 |
if (newValues.length>0) { |
|
494 |
itemToZoom = newValues[0]; |
|
495 |
} else { |
|
496 |
itemToZoom = null; |
|
497 |
} |
|
468 | 498 |
} catch (DriverException ee) { |
469 | 499 |
// TODO Auto-generated catch block |
470 | 500 |
ee.printStackTrace(); |
471 | 501 |
} catch (com.hardcode.gdbms.engine.data.driver.DriverException eee) { |
472 | 502 |
// TODO Auto-generated catch block |
473 | 503 |
eee.printStackTrace(); |
504 |
} catch (ParseException e) { |
|
505 |
// TODO Auto-generated catch block |
|
506 |
e.printStackTrace(); |
|
507 |
} catch (DriverLoadException e) { |
|
508 |
// TODO Auto-generated catch block |
|
509 |
e.printStackTrace(); |
|
510 |
} catch (SemanticException e) { |
|
511 |
// TODO Auto-generated catch block |
|
512 |
e.printStackTrace(); |
|
513 |
} catch (IOException e) { |
|
514 |
// TODO Auto-generated catch block |
|
515 |
e.printStackTrace(); |
|
516 |
} catch (EvaluationException e) { |
|
517 |
// TODO Auto-generated catch block |
|
518 |
e.printStackTrace(); |
|
474 | 519 |
} |
475 | 520 |
} |
476 | 521 |
} |
... | ... | |
556 | 601 |
} |
557 | 602 |
mapContext.getViewPort().setExtent(visitor.getSelectBound()); |
558 | 603 |
selectable.clearSelection(); |
559 |
} else { |
|
604 |
} else if (itemToZoom == null) { |
|
605 |
System.out.println("Localizador por atributo: El campo valor debe tener elementos no nulos para hacer el Zoom."); |
|
606 |
} else { |
|
560 | 607 |
System.out.println("Localizador por atributo: El campo valor debe estar inicializado antes de hacer Zoom."); |
561 | 608 |
} |
562 | 609 |
} |
Also available in: Unified diff