- if (backend instanceof Resource)
- return new WaypointImpl((Resource) backend, "Point 1");
+ if (backend instanceof Resource) {
+ Resource waypoint = (Resource) backend;
+ WaypointImpl wp = new WaypointImpl(waypoint, "");
+
+ // Read real label in background
+ ThreadUtils.getBlockingWorkExecutor().submit(() -> {
+ try {
+ Waypoint p = Simantics.getSession().syncRequest(
+ (Read<Waypoint>) graph -> RoutePersistence.toWaypoint(graph, waypoint));
+ if (p != null) {
+ wp.setLabel(p.getLabel());
+ rs.fireEvent(RouteEvent.TYPE_ROUTE_MODIFIED, RouteImpl.this);
+ }
+ } catch (DatabaseException e) {
+ LOGGER.error("Failed to read waypoint {} label", backend, e);
+ }
+ });
+
+ return wp;
+ }