提交 e0d40e77 编写于 作者: S serge-rider

#6743 Object tooltips redesign

上级 c2775815
......@@ -19,7 +19,8 @@ Require-Bundle: org.eclipse.core.runtime,
org.jkiss.dbeaver.ui,
org.jkiss.dbeaver.ui.editors.base,
org.jkiss.dbeaver.ui.editors.data,
org.jkiss.bundle.gis
org.jkiss.bundle.gis,
com.google.gson
Bundle-ClassPath: .
Export-Package: org.jkiss.dbeaver.ui.gis
Automatic-Module-Name: org.jkiss.dbeaver.data.gis.view
......@@ -16,7 +16,11 @@
*/
package org.jkiss.dbeaver.ui.gis.panel;
import org.eclipse.jface.action.*;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.dnd.Clipboard;
......@@ -32,9 +36,7 @@ import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.DBUtils;
import org.jkiss.dbeaver.model.DBValueFormatting;
import org.jkiss.dbeaver.model.data.DBDAttributeBinding;
import org.jkiss.dbeaver.model.data.DBDDisplayFormat;
import org.jkiss.dbeaver.model.exec.DBCException;
import org.jkiss.dbeaver.model.gis.*;
import org.jkiss.dbeaver.model.runtime.VoidProgressMonitor;
......@@ -65,7 +67,6 @@ import org.locationtech.jts.geom.Geometry;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class GISLeafletViewer implements IGeometryValueEditor {
......@@ -78,6 +79,8 @@ public class GISLeafletViewer implements IGeometryValueEditor {
private static final String PROP_FLIP_COORDINATES = "gis.flipCoords";
private static final String PROP_SRID = "gis.srid";
private static final Gson gson = new GsonBuilder().create();
private final IValueController valueController;
private final Browser browser;
private DBGeometry[] lastValue;
......@@ -276,16 +279,7 @@ public class GISLeafletViewer implements IGeometryValueEditor {
if (CommonUtils.isEmpty(value.getProperties())) {
geomTipValues.add("null");
} else {
StringBuilder geomProps = new StringBuilder("{");
boolean first = true;
for (Map.Entry<String, Object> prop : value.getProperties().entrySet()) {
if (!first) geomProps.append(",");
first = false;
geomProps.append('"').append(prop.getKey().replace("\"", "\\\"")).append("\":\"")
.append(CommonUtils.escapeJavaString(DBValueFormatting.getDefaultValueDisplayString(prop.getValue(), DBDDisplayFormat.UI))).append("\"");
}
geomProps.append("}");
geomTipValues.add(geomProps.toString());
geomTipValues.add(gson.toJson(value.getProperties()));
}
}
if (actualSourceSRID == GisConstants.SRID_SIMPLE) {
......
......@@ -136,16 +136,19 @@ public class GeometryPresentation extends AbstractPresentation {
geomAttrs.geomAttr,
value);
if (geometry != null) {
if (geometry != null && !(geometry.getSRID() != 0 && geometry.isEmpty())) {
geometries.add(geometry);
// Now get description
Map<String, Object> properties = new LinkedHashMap<>();
properties.put("Column", DBUtils.getObjectFullName(geomAttrs.geomAttr, DBPEvaluationContext.UI));
properties.put("id", DBUtils.getObjectFullName(geomAttrs.geomAttr, DBPEvaluationContext.UI));
properties.put("color", "blue");
if (!geomAttrs.descAttrs.isEmpty()) {
Map<String, Object> infoMap = new LinkedHashMap<>();
properties.put("info", infoMap);
for (DBDAttributeBinding da : geomAttrs.descAttrs) {
Object descValue = model.getCellValue(da, row);
if (!DBUtils.isNullValue(descValue)) {
properties.put(da.getName(), descValue);
if (!DBUtils.isNullValue(descValue) && !(descValue instanceof String && ((String) descValue).isEmpty())) {
infoMap.put(da.getName(), descValue);
}
}
}
......
......@@ -65,10 +65,10 @@
weight: 3,
};
const popupOption = {
closeButton: false,
closeButton: true,
minWidth: 260,
maxWidth: 300,
maxHeight: 300,
maxWidth: 800,
maxHeight: 500,
};
var lastClickCoordinates = "";
......@@ -76,10 +76,20 @@
var tip = feature.tip;
if (tip != null) {
var tipText = "";
for (var propName in tip) {
tipText += propName + ": " + tip[propName] + "<br/>";
if (tip.id != null) {
var color = tip.color;
if (color == null) color = "black";
tipText += "<h3 style='color:" + color + "'>" + tip.id + "</h3>";
}
layer.bindPopup(tipText);
tipText += "<table>";
var objInfo = tip.info;
if (objInfo != null) {
for (var propName in objInfo) {
tipText += "<tr><td>" + propName + "</td><td>" + objInfo[propName] + "</td></tr>";
}
}
tipText += "</table>";
layer.bindPopup(tipText, popupOption);
}
}
......
......@@ -21,6 +21,7 @@ import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.data.gis.handlers.GeometryConverter;
import org.jkiss.dbeaver.model.data.DBDValue;
import org.jkiss.utils.CommonUtils;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.io.ParseException;
import org.locationtech.jts.io.WKTReader;
......@@ -128,4 +129,20 @@ public class DBGeometry implements DBDValue {
public DBGeometry copy() {
return new DBGeometry(this);
}
/**
* @return true if all geometry points set to zero
*/
public boolean isEmpty() {
Geometry geometry = getGeometry();
if (geometry == null) {
return false;
}
for (Coordinate coord : geometry.getCoordinates()) {
if (coord.getX() != 0 || coord.getY() != 0 || coord.getZ() != 0) {
return false;
}
}
return true;
}
}
......@@ -16,6 +16,7 @@
*/
package org.jkiss.dbeaver.model.gis;
import graphql.execution.nextgen.Common;
import org.jkiss.dbeaver.Log;
import org.jkiss.utils.CommonUtils;
......@@ -31,6 +32,15 @@ public class GisExpressionFunctions {
}
public static Object wktPoint(Object longitude, Object latitude, Object srid) {
if (longitude == null || latitude == null) {
return null;
}
if (longitude instanceof Number && ((Number) longitude).doubleValue() == 0.0 &&
latitude instanceof Number && ((Number) latitude).doubleValue() == 0.0)
{
// Zeroes
return null;
}
String strValue = "POINT(" + longitude + " " + latitude + ")";
return new DBGeometry(strValue, CommonUtils.toInt(srid, GisConstants.SRID_4326));
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册