From: Marko Luukkainen Date: Fri, 25 Oct 2019 14:32:58 +0000 (+0300) Subject: Equipment/Component library customization requires proper preloading. X-Git-Tag: v1.43.0~165^2 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F13%2F3413%2F1;p=simantics%2F3d.git Equipment/Component library customization requires proper preloading. Without preloaded components/control points, ObjMap is not able load the data (causes nested read transaction) Change-Id: I07b7a0f3500cc9b2a843441f10779316be6a4b70 --- diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java b/org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java index 51e03ad3..f80d3be8 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java @@ -140,7 +140,7 @@ public class Plant3DEditor extends ResourceEditorPart { panel.setPickType(4); try { - ControlPointFactory.preloadCache(); + ControlPointFactory.preloadCache(getLibraryUri()); ComponentUtils.preloadCache(); } catch (Exception e) { ExceptionUtils.logAndShowError("Cannot open Plant3D editor",e); diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/ControlPointFactory.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/ControlPointFactory.java index ae71b7af..6b92e447 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/ControlPointFactory.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/ControlPointFactory.java @@ -20,11 +20,11 @@ public class ControlPointFactory { private static Map cache = new HashMap(); - public static void preloadCache() throws Exception { - List items = P3DUtil.getEnds(Plant3D.URIs.Builtin); - items.addAll(P3DUtil.getInlines(Plant3D.URIs.Builtin)); - items.addAll(P3DUtil.getNozzles(Plant3D.URIs.Builtin)); - items.addAll(P3DUtil.getTurns(Plant3D.URIs.Builtin)); + public static void preloadCache(String libUri) throws Exception { + List items = P3DUtil.getEnds(libUri); + items.addAll(P3DUtil.getInlines(libUri)); + items.addAll(P3DUtil.getNozzles(libUri)); + items.addAll(P3DUtil.getTurns(libUri)); for (Item item : items) { Instruction inst = createInstruction(item.getUri()); diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scl/SCLUtil.java b/org.simantics.plant3d/src/org/simantics/plant3d/scl/SCLUtil.java index ae6bac4b..8418ae4d 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scl/SCLUtil.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scl/SCLUtil.java @@ -9,6 +9,7 @@ import org.simantics.db.request.Read; import org.simantics.objmap.graph.IMapping; import org.simantics.objmap.graph.Mappings; import org.simantics.objmap.graph.schema.IMappingSchema; +import org.simantics.plant3d.ontology.Plant3D; import org.simantics.plant3d.scenegraph.P3DRootNode; import org.simantics.plant3d.scenegraph.SchemaBuilder; import org.simantics.plant3d.scenegraph.controlpoint.ControlPointFactory; @@ -20,7 +21,7 @@ public class SCLUtil { public static P3DScriptNodeMap load(final Resource root) throws DatabaseException { try { - ControlPointFactory.preloadCache(); + ControlPointFactory.preloadCache(Plant3D.URIs.Builtin); ComponentUtils.preloadCache(); } catch (Exception e) { throw new DatabaseException(e); @@ -47,7 +48,7 @@ public class SCLUtil { public static P3DRootNode loadReadOnly(final Resource root) throws DatabaseException { try { - ControlPointFactory.preloadCache(); + ControlPointFactory.preloadCache(Plant3D.URIs.Builtin); ComponentUtils.preloadCache(); } catch (Exception e) { throw new DatabaseException(e);