use of org.jkiss.dbeaver.ui.data.IDataController in project dbeaver by serge-rider.
the class GISBrowserViewer method primeEditorValue.
@Override
public void primeEditorValue(@Nullable Object value) throws DBException {
List<DBGeometry> geometries = new ArrayList<>();
IDataController dataController = valueController.getDataController();
if (dataController instanceof IResultSetController) {
IResultSetController resultSetController = (IResultSetController) dataController;
DBSTypedObject valueType = valueController.getValueType();
List<GeometryDataUtils.GeomAttrs> geomAttrs = null;
if (valueType instanceof DBSAttributeBase) {
geomAttrs = GeometryDataUtils.extractGeometryAttributes(resultSetController);
}
IResultSetSelection selection = resultSetController.getSelection();
Object[] selectedValues = selection.toArray();
if (ArrayUtils.isEmpty(selectedValues)) {
selectedValues = new Object[] { value };
}
for (Object cell : selectedValues) {
DBGeometry geometry;
DBDAttributeBinding attr;
ResultSetRow row;
if (cell instanceof DBGeometry) {
attr = resultSetController.getActivePresentation().getCurrentAttribute();
row = resultSetController.getCurrentRow();
geometry = (DBGeometry) cell;
} else {
attr = selection.getElementAttribute(cell);
row = selection.getElementRow(cell);
Object cellValue = resultSetController.getModel().getCellValue(attr, row);
geometry = GisTransformUtils.getGeometryValueFromObject(valueController.getDataController().getDataContainer(), valueController.getValueHandler(), valueController.getValueType(), cellValue);
}
if (geometry != null) {
geometries.add(geometry);
// Set properties
if (valueType instanceof DBSAttributeBase) {
for (GeometryDataUtils.GeomAttrs ga : geomAttrs) {
if (ga.geomAttr.matches(attr, false)) {
GeometryDataUtils.setGeometryProperties(resultSetController, ga, geometry, row);
break;
}
}
}
if (geometry.getProperties() == null) {
geometry.setProperties(Collections.singletonMap("Object", geometry.getSRID()));
}
}
}
}
leafletViewer.setGeometryData(geometries.toArray(new DBGeometry[0]));
}
Aggregations