]> gerrit.simantics Code Review - simantics/district.git/blobdiff - org.simantics.district.route.ui/src/org/simantics/district/route/ui/handlers/SelectRouteOnDiagram.java
Enable routing problem UI feedback for users
[simantics/district.git] / org.simantics.district.route.ui / src / org / simantics / district / route / ui / handlers / SelectRouteOnDiagram.java
index 36d14fc6427167b3c102469e4623f9a77e7af294..572c65bf0ecc15871431ca3e470e2ef23b4ecbb8 100644 (file)
@@ -1,5 +1,6 @@
 package org.simantics.district.route.ui.handlers;
 
+import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.CompletableFuture;
 
@@ -47,11 +48,15 @@ public class SelectRouteOnDiagram {
 
         Display display = activeShell.getDisplay();
         CompletableFuture<List<Resource>> result = new CompletableFuture<>();
-        result.thenAccept(dnElements -> {
-            try {
-                openDiagram(display, dnElements);
-            } catch (DatabaseException e) {
-                LOGGER.error("Failed to open district network diagram with selection {}", dnElements);
+        result
+        .exceptionally(e -> Collections.emptyList())
+        .thenAccept(dnElements -> {
+            if (!dnElements.isEmpty()) {
+                try {
+                    openDiagram(display, dnElements);
+                } catch (DatabaseException e) {
+                    LOGGER.error("Failed to open district network diagram with selection {}", dnElements); //$NON-NLS-1$
+                }
             }
         });