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;
*/
public class DiagramContentRequest extends BaseRequest<Resource, DiagramContents> {
+ private static final Logger LOGGER = LoggerFactory.getLogger(DiagramContentRequest.class);
+
int previousElementCount = 32;
ErrorHandler errorHandler;
// These help loading result.elements in the correct order.
final AtomicInteger index = new AtomicInteger();
final TIntArrayList unrecognizedElementIndices = new TIntArrayList();
-
+
+ if (!g.hasStatement(data)) {
+ LOGGER.warn("Most likely diagram is being removed and therefore ordered list can not be found for {}", data);
+ return new DiagramContents(); // or null, I don't know
+ }
Collection<Resource> components = OrderedSetUtils.toList(g, data);
DiagramContents res = g.syncRequest((AsyncRead<DiagramContents>)(graph, procedure) -> {
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<Resource> types;
private final String name;
// for (Resource t : types)
// System.out.println("\t" + NameUtils.getSafeName(graph, t, true));
- Collection<Resource> elements = graph.syncRequest(new OrderedSet(realDiagram));
- for (Resource element : elements) {
-// System.out.println("checking element " + NameUtils.getSafeName(graph, element, true));
- Collection<Resource> elementTypes = graph.getTypes(element);
- if (!Collections.disjoint(types, elementTypes))
- result.add(element);
+ if (graph.hasStatement(realDiagram)) {
+ Collection<Resource> elements = graph.syncRequest(new OrderedSet(realDiagram));
+ for (Resource element : elements) {
+ // System.out.println("checking element " + NameUtils.getSafeName(graph, element, true));
+ Collection<Resource> 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;
}