]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
RouteGraphUtils.readConnectionStyle returns default value if necessary 43/643/1
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Tue, 20 Jun 2017 06:29:08 +0000 (09:29 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Tue, 20 Jun 2017 06:29:08 +0000 (09:29 +0300)
Previously the code would crash with NPE if the ontology/model was not
created to contain STR.HasConnectionType information accordingly. Now it
will just return ExampleConnectionStyle if there is no modelled
information available.

refs #7323

Change-Id: I3d5b5ba6a4e615d7ae120e42aa003c787617b8d0

bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/RouteGraphUtils.java

index 3127b431c7ce7178c5e656d1a745b79e13539a86..1b7376f96e4301814ba70ac861635ff058806cce 100644 (file)
@@ -42,6 +42,7 @@ import org.simantics.diagram.connection.RouteTerminal;
 import org.simantics.diagram.connection.RouteTerminalPosition;
 import org.simantics.diagram.connection.rendering.BasicConnectionStyle;
 import org.simantics.diagram.connection.rendering.ConnectionStyle;
+import org.simantics.diagram.connection.rendering.ExampleConnectionStyle;
 import org.simantics.diagram.connection.rendering.StyledRouteGraphRenderer;
 import org.simantics.diagram.connection.rendering.arrows.ArrowLineEndStyle;
 import org.simantics.diagram.connection.rendering.arrows.ILineEndStyle;
@@ -523,6 +524,8 @@ public class RouteGraphUtils {
         }
     }
 
+    private static final ConnectionStyle DEFAULT_CONNECTION_STYLE = new ExampleConnectionStyle();
+
     /**
      * @param graph
      * @param canvas
@@ -537,7 +540,7 @@ public class RouteGraphUtils {
             connectionType = modelingRules.getConnectionType(graph, connection);
         if (connectionType == null)
             connectionType = graph.getPossibleObject(connection, STR.HasConnectionType);
-        return readConnectionStyleFromConnectionType(graph, connectionType);
+        return connectionType != null ? readConnectionStyleFromConnectionType(graph, connectionType) : DEFAULT_CONNECTION_STYLE;
     }
 
     protected static ConnectionStyle readConnectionStyleFromConnectionType(ReadGraph graph, Resource connectionType) throws DatabaseException {