From e571f79968d4f002505f3ea11e50ac7075d492c0 Mon Sep 17 00:00:00 2001 From: Tuukka Lehtonen Date: Tue, 20 Jun 2017 09:29:08 +0300 Subject: [PATCH] RouteGraphUtils.readConnectionStyle returns default value if necessary 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 --- .../src/org/simantics/diagram/adapter/RouteGraphUtils.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/RouteGraphUtils.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/RouteGraphUtils.java index 3127b431c..1b7376f96 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/RouteGraphUtils.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/RouteGraphUtils.java @@ -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 { -- 2.47.1