]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling/scl/Simantics/Model.scl
Fixed Simantics/Diagram/setElements to resolve attachment relations
[simantics/platform.git] / bundles / org.simantics.modeling / scl / Simantics / Model.scl
index a2531e3e07a7060e02d9e5cab2a505611e771b8d..e82975e67ad36cd80a9181803b2d00b752150e92 100644 (file)
@@ -1,5 +1,6 @@
 include "Simantics/Entity" hiding (nameOf)
 include "Simantics/Ontologies"
+import "Simantics/Misc"
 
 type Model = Resource
 type Configuration = Resource
@@ -11,7 +12,7 @@ Returns an existing model in the current project with the given `name`
 """
 model :: String -> <ReadGraph> Model
 model name = match possibleResourceChild (currentProject ()) name with
-    Just m -> fromResource m
+    Just m -> m
     Nothing -> fail $ "Didn't find a model " + name + "." 
 
 """
@@ -21,15 +22,13 @@ Returns the configuration of the given `model`
 and returns the `configuration` resource
 """
 configurationOf :: Model -> <ReadGraph> Configuration
-configurationOf m = do
-    conf = singleObject (toResource m) SIMU.HasConfiguration 
-    fromResource conf
+configurationOf m = singleObject m SIMU.HasConfiguration
 
 """
 Returns the list of all models in the current project.
 """
 allModels :: () -> <ReadGraph> [Model]
-allModels _ = map fromResource $ objectsWithType (currentProject ()) L0.ConsistsOf SIMU.Model
+allModels _ = objectsWithType (currentProject ()) L0.ConsistsOf SIMU.Model
 
 importJava "org.simantics.modeling.ModelingUtils" where
     """Removes the index associated with the model."""
@@ -52,6 +51,13 @@ importJava "org.simantics.modeling.ModelingUtils" where
     searchByTypeAndFilter :: Resource -> Resource -> (Resource -> <ReadGraph> Boolean) -> <ReadGraph> [Resource]
     
     listIndexEntries :: Resource -> String -> <ReadGraph> String
+
+    """
+    Activates the specified model but does not wait for any of the effects
+    caused by the activation to be completed. In most cases the blocking
+    version [syncActivateModel](#syncActivateModel) should be used instead
+    of this function.
+    """
     activateModel :: Resource -> <WriteGraph> Boolean
     
     @JavaName createModel
@@ -66,5 +72,21 @@ activateModelAction :: Resource -> <Proc> ()
 activateModelAction model = do
   syncWrite (\() -> activateModel model)
   ()
-    
-    
\ No newline at end of file
+
+"""
+Activates the specified model and blocks until all effects caused by the
+activation have been completed. This function is a synchronous version of
+the older [activateModel](#activateModel) function that does not wait for
+activation completion, i.e. works asynchronously. In most cases it is
+recommended to use this functions instead of 
+
+The effect completion waiting works based on the `org.simantics.db.service.ServiceActivityMonitor`
+service offered by the database client. Therefore implementation that want
+to support waiting for activation completion need to register/unregister
+activities with this service accordingly.
+"""
+syncActivateModel :: Resource -> <Proc> Boolean
+syncActivateModel model = do
+    result = syncWrite (\() -> activateModel model)
+    syncGraph ()
+    result
\ No newline at end of file