Revision 37907 trunk/extensions/extDataLocator/src/com/iver/gvsig/datalocator/gui/DataSelectionPanel.java
DataSelectionPanel.java | ||
---|---|---|
67 | 67 |
import com.hardcode.gdbms.engine.instruction.IncompatibleTypesException; |
68 | 68 |
import com.hardcode.gdbms.engine.instruction.SemanticException; |
69 | 69 |
import com.hardcode.gdbms.engine.values.BooleanValue; |
70 |
import com.hardcode.gdbms.engine.values.NullValue; |
|
70 | 71 |
import com.hardcode.gdbms.engine.values.Value; |
71 | 72 |
import com.hardcode.gdbms.parser.ParseException; |
72 | 73 |
import com.iver.andami.PluginServices; |
... | ... | |
281 | 282 |
Value[] newValues = null; |
282 | 283 |
if (fieldToZoomIndex < 0) |
283 | 284 |
return null; |
284 |
try { |
|
285 |
try {
|
|
285 | 286 |
ds = lyr.getRecordset(); |
286 |
String sql = "select " + ds.getFieldName(fieldToZoomIndex) + " from " + ds.getName() + " where " + ds.getFieldName(fieldToZoomIndex) + " is not null;"; |
|
287 |
ds = ds.getDataSourceFactory().executeSQL(sql, DataSourceFactory.AUTOMATIC_OPENING); |
|
288 |
|
|
287 |
ds.start(); |
|
288 |
// String sql = "select " + ds.getFieldName(fieldToZoomIndex) + " from " + ds.getName() + " where " + ds.getFieldName(fieldToZoomIndex) + " is not null;"; |
|
289 |
// ds = ds.getDataSourceFactory().executeSQL(sql, DataSourceFactory.AUTOMATIC_OPENING); |
|
290 |
// |
|
289 | 291 |
//Quitar los nombres repetidos y ordenarlos |
290 | 292 |
TreeSet treeSet = new TreeSet(new Comparator() { |
291 | 293 |
public int compare(Object o1, Object o2) { |
... | ... | |
305 | 307 |
} |
306 | 308 |
}); |
307 | 309 |
for (int i=0;i<ds.getRowCount();i++) { |
308 |
Value value = ds.getFieldValue(i, 0); |
|
310 |
Value value = ds.getFieldValue(i, fieldToZoomIndex); |
|
311 |
if (value instanceof NullValue) |
|
312 |
continue; |
|
309 | 313 |
treeSet.add(value); |
310 | 314 |
} |
315 |
ds.stop(); |
|
311 | 316 |
newValues = (Value[])treeSet.toArray(new Value[0]); |
312 |
} catch (ParseException e) { |
|
313 |
// TODO Auto-generated catch block |
|
314 |
e.printStackTrace(); |
|
315 |
} catch (DriverLoadException e) { |
|
316 |
// TODO Auto-generated catch block |
|
317 |
e.printStackTrace(); |
|
318 |
} catch (SemanticException e) { |
|
319 |
// TODO Auto-generated catch block |
|
320 |
e.printStackTrace(); |
|
321 |
} catch (EvaluationException e) { |
|
322 |
// TODO Auto-generated catch block |
|
323 |
e.printStackTrace(); |
|
317 |
// } catch (ParseException e) { |
|
318 |
// // TODO Auto-generated catch block |
|
319 |
// e.printStackTrace(); |
|
320 |
// } catch (DriverLoadException e) { |
|
321 |
// // TODO Auto-generated catch block |
|
322 |
// e.printStackTrace(); |
|
323 |
// } catch (SemanticException e) { |
|
324 |
// // Seguramente hemos guardado una capa o un campo que no se encuentran. Ponemos el campo a -1 (la capa se queda la primera activa). |
|
325 |
// e.printStackTrace(); |
|
326 |
// this.fieldToZoomIndex = -1; |
|
327 |
// return null; |
|
328 |
// } catch (EvaluationException e) { |
|
329 |
// // TODO Auto-generated catch block |
|
330 |
// e.printStackTrace(); |
|
324 | 331 |
} catch (ReadDriverException e) { |
325 | 332 |
// TODO Auto-generated catch block |
326 | 333 |
e.printStackTrace(); |
... | ... | |
528 | 535 |
prefUsuario.putInt("FIELDINDEX_FOR_DATA_LOCATION", i); |
529 | 536 |
} |
530 | 537 |
} |
531 |
String sql = "select * from " + ds.getName() + " where " + ds.getFieldName(fieldToZoomIndex) + " is not null;"; |
|
532 |
ds = ds.getDataSourceFactory().executeSQL(sql, DataSourceFactory.AUTOMATIC_OPENING); |
|
533 |
Value[] values = new Value[(int)ds.getRowCount()]; |
|
534 |
for (int i=0;i<ds.getRowCount();i++) { |
|
535 |
Value value = ds.getFieldValue(i, fieldToZoomIndex); |
|
536 |
values[i] = value; |
|
537 |
} |
|
538 |
//Quitar los nombres repetidos y ordenarlos |
|
539 |
TreeSet treeSet = new TreeSet(new Comparator() { |
|
540 |
public int compare(Object o1, Object o2) { |
|
541 |
Value v1 = (Value) o1; |
|
542 |
Value v2 = (Value) o2; |
|
543 |
try { |
|
544 |
if (((BooleanValue)v1.less(v2)).getValue()){ |
|
545 |
return -1; |
|
546 |
}else if (((BooleanValue)v1.greater(v2)).getValue()){ |
|
547 |
return 1; |
|
548 |
}else{ |
|
549 |
return 0; |
|
550 |
} |
|
551 |
} catch (IncompatibleTypesException e) { |
|
552 |
throw new RuntimeException(e); |
|
553 |
} |
|
554 |
} |
|
555 |
}); |
|
556 |
for (int i=0;i<values.length;i++) { |
|
557 |
treeSet.add(values[i]); |
|
558 |
} |
|
559 |
Value[] newValues = (Value[])treeSet.toArray(new Value[0]); |
|
538 |
Value[] newValues = getNewValues(); |
|
560 | 539 |
DefaultComboBoxModel defaultModel = new DefaultComboBoxModel(newValues); |
561 | 540 |
jComboBox2.setModel(defaultModel); |
562 | 541 |
if (newValues.length>0) jComboBox2.setSelectedIndex(0); |
... | ... | |
565 | 544 |
} else { |
566 | 545 |
itemToZoom = null; |
567 | 546 |
} |
568 |
} catch (ParseException e) { |
|
569 |
// TODO Auto-generated catch block |
|
570 |
e.printStackTrace(); |
|
571 |
} catch (DriverLoadException e) { |
|
572 |
// TODO Auto-generated catch block |
|
573 |
e.printStackTrace(); |
|
574 |
} catch (SemanticException e) { |
|
575 |
// TODO Auto-generated catch block |
|
576 |
e.printStackTrace(); |
|
577 |
}catch (EvaluationException e) { |
|
578 |
// TODO Auto-generated catch block |
|
579 |
e.printStackTrace(); |
|
547 |
// } catch (ParseException e) {
|
|
548 |
// // TODO Auto-generated catch block
|
|
549 |
// e.printStackTrace();
|
|
550 |
// } catch (DriverLoadException e) {
|
|
551 |
// // TODO Auto-generated catch block
|
|
552 |
// e.printStackTrace();
|
|
553 |
// } catch (SemanticException e) {
|
|
554 |
// // TODO Auto-generated catch block
|
|
555 |
// e.printStackTrace();
|
|
556 |
// }catch (EvaluationException e) {
|
|
557 |
// // TODO Auto-generated catch block
|
|
558 |
// e.printStackTrace();
|
|
580 | 559 |
} catch (ReadDriverException e) { |
581 | 560 |
// TODO Auto-generated catch block |
582 | 561 |
e.printStackTrace(); |
Also available in: Unified diff