From acb2ceac4ac946941beae7547783ec76edceb733 Mon Sep 17 00:00:00 2001 From: jsimomaa Date: Mon, 25 Feb 2019 11:21:06 +0200 Subject: [PATCH] No point computing ordered set if resource does not have any statements gitlab #263 Change-Id: I92dbe0ea64bb8d7969124c27a37614abc724a8e1 --- .../adapter/DiagramContentRequest.java | 10 ++++++++- .../simantics/diagram/adapter/TypeGroup.java | 21 ++++++++++++------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/DiagramContentRequest.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/DiagramContentRequest.java index 9be72d29f..8f5afab1a 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/DiagramContentRequest.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/DiagramContentRequest.java @@ -31,6 +31,8 @@ import org.simantics.diagram.content.RouteGraphConnectionPartRequest; import org.simantics.diagram.stubs.DiagramResource; import org.simantics.diagram.synchronization.ErrorHandler; import org.simantics.g2d.canvas.ICanvasContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import gnu.trove.list.array.TIntArrayList; import gnu.trove.map.hash.THashMap; @@ -42,6 +44,8 @@ import gnu.trove.set.hash.THashSet; */ public class DiagramContentRequest extends BaseRequest { + private static final Logger LOGGER = LoggerFactory.getLogger(DiagramContentRequest.class); + int previousElementCount = 32; ErrorHandler errorHandler; @@ -58,7 +62,11 @@ public class DiagramContentRequest extends BaseRequest components = OrderedSetUtils.toList(g, data); DiagramContents res = g.syncRequest((AsyncRead)(graph, procedure) -> { diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/TypeGroup.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/TypeGroup.java index b7b4ba2ff..7e4cb0e37 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/TypeGroup.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/TypeGroup.java @@ -29,12 +29,16 @@ import org.simantics.db.procedure.SetListener; import org.simantics.diagram.stubs.DiagramResource; import org.simantics.layer0.Layer0; import org.simantics.scenegraph.profile.Group; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author Tuukka Lehtonen */ public class TypeGroup implements Group { + private static final Logger LOGGER = LoggerFactory.getLogger(TypeGroup.class); + private final Collection types; private final String name; @@ -103,14 +107,17 @@ public class TypeGroup implements Group { // for (Resource t : types) // System.out.println("\t" + NameUtils.getSafeName(graph, t, true)); - Collection elements = graph.syncRequest(new OrderedSet(realDiagram)); - for (Resource element : elements) { -// System.out.println("checking element " + NameUtils.getSafeName(graph, element, true)); - Collection elementTypes = graph.getTypes(element); - if (!Collections.disjoint(types, elementTypes)) - result.add(element); + if (graph.hasStatement(realDiagram)) { + Collection elements = graph.syncRequest(new OrderedSet(realDiagram)); + for (Resource element : elements) { + // System.out.println("checking element " + NameUtils.getSafeName(graph, element, true)); + Collection elementTypes = graph.getTypes(element); + if (!Collections.disjoint(types, elementTypes)) + result.add(element); + } + } else { + LOGGER.warn("Most likely after deleting a diagram or something therefore no ordered set can be found for {}", realDiagram); } - return result; } -- 2.47.1