X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.district.network%2Fsrc%2Forg%2Fsimantics%2Fdistrict%2Fnetwork%2FDistrictNetworkUtil.java;h=fd72a67378b62609f3061284aca2528723a78512;hb=0f3520e48a9387d07b622ab5b0c20ec3bddbf2b1;hp=550553f1b88083249877ed8f20c41073adf3efc3;hpb=3803b2cf3450ba6e2ef59bc3c150057315f1e539;p=simantics%2Fdistrict.git diff --git a/org.simantics.district.network/src/org/simantics/district/network/DistrictNetworkUtil.java b/org.simantics.district.network/src/org/simantics/district/network/DistrictNetworkUtil.java index 550553f1..fd72a673 100644 --- a/org.simantics.district.network/src/org/simantics/district/network/DistrictNetworkUtil.java +++ b/org.simantics.district.network/src/org/simantics/district/network/DistrictNetworkUtil.java @@ -41,7 +41,7 @@ public class DistrictNetworkUtil { Resource edge = graph.newResource(); graph.claim(edge, L0.InstanceOf, DN.Edge); - graph.claim(edge, DN.HasMapping, mapping); + graph.claim(edge, DN.HasMapping, null, mapping); OrderedSetUtils.addFirst(graph, composite, edge); graph.claim(composite, L0.ConsistsOf, L0.PartOf, edge); @@ -74,7 +74,7 @@ public class DistrictNetworkUtil { graph.claim(vertex, L0.InstanceOf, DN.Vertex); graph.claimLiteral(vertex, DIA.HasLocation, coords); - graph.claim(vertex, DN.HasMapping, mapping); + graph.claim(vertex, DN.HasMapping, null, mapping); OrderedSetUtils.add(graph, composite, vertex); graph.claim(composite, L0.ConsistsOf, L0.PartOf, vertex); @@ -223,13 +223,23 @@ public class DistrictNetworkUtil { return current != null ? current : true; } - public static void changeMapBackgroundColor(WriteGraph graph, Resource resource, Integer integer) throws DatabaseException { + public static void changeMapBackgroundColor(WriteGraph graph, Resource diagram, Integer integer) throws DatabaseException { DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); - graph.claimLiteral(resource, DN.Diagram_backgroundColor, integer, Bindings.getBindingUnchecked(RGB.Integer.class)); + graph.claimLiteral(diagram, DN.Diagram_backgroundColor, integer, Bindings.getBindingUnchecked(RGB.Integer.class)); } public static Boolean trackChangesEnabled(ReadGraph graph, Resource diagram) throws DatabaseException { - return Boolean.TRUE.equals(graph.getPossibleRelatedValue(diagram, + if (diagram != null && graph.hasStatement(diagram)) { + return Boolean.TRUE.equals(graph.getPossibleRelatedValue(diagram, DistrictNetworkResource.getInstance(graph).Diagram_trackChangesEnabled)); + } else { + return false; + } + } + + public static RGB.Integer backgroundColor(ReadGraph graph, Resource diagram) throws DatabaseException { + return graph.getPossibleRelatedValue(diagram, + DistrictNetworkResource.getInstance(graph).Diagram_backgroundColor, + Bindings.getBindingUnchecked(RGB.Integer.class)); } }