]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Equipment/Component library customization requires proper preloading. 13/3413/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Fri, 25 Oct 2019 14:32:58 +0000 (17:32 +0300)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Fri, 25 Oct 2019 14:32:58 +0000 (17:32 +0300)
Without preloaded components/control points, ObjMap is not able load the
data (causes nested read transaction)

Change-Id: I07b7a0f3500cc9b2a843441f10779316be6a4b70

org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java
org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/ControlPointFactory.java
org.simantics.plant3d/src/org/simantics/plant3d/scl/SCLUtil.java

index 51e03ad36530828b74ebad223bd29af5e1f41e94..f80d3be8d63086c436116f8973e1cceea506697f 100644 (file)
@@ -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);
index ae71b7afa9e5da1734a382e93903e40a8fc31938..6b92e4479aa1a8fe34cb7681bcd94255a83055d7 100644 (file)
@@ -20,11 +20,11 @@ public class ControlPointFactory {
        private static Map<String,Instruction> cache = new HashMap<String, Instruction>();
        
        
-       public static void preloadCache() throws Exception {
-               List<Item> 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<Item> 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());
index ae6bac4baeff7716b0795d16ceb8b780b2e6a88c..8418ae4d2c19d3f198e56e3e743cb76dde1a4b2b 100644 (file)
@@ -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);