X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.modeling%2Fscl%2FSimantics%2FModel.scl;h=e82975e67ad36cd80a9181803b2d00b752150e92;hb=6d789e04560b01a1845d39f7e951230bb74d6470;hp=f360040d359dcef4d9b18659eefbd49259291758;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.modeling/scl/Simantics/Model.scl b/bundles/org.simantics.modeling/scl/Simantics/Model.scl index f360040d3..e82975e67 100644 --- a/bundles/org.simantics.modeling/scl/Simantics/Model.scl +++ b/bundles/org.simantics.modeling/scl/Simantics/Model.scl @@ -1,70 +1,92 @@ -include "Simantics/Entity" hiding (nameOf) -include "Simantics/Ontologies" - -type Model = Resource -type Configuration = Resource - -""" - model name - -Returns an existing model in the current project with the given `name` -""" -model :: String -> Model -model name = match possibleResourceChild (currentProject ()) name with - Just m -> fromResource m - Nothing -> fail $ "Didn't find a model " + name + "." - -""" - configurationOf model - -Returns the configuration of the given `model` -and returns the `configuration` resource -""" -configurationOf :: Model -> Configuration -configurationOf m = do - conf = singleObject (toResource m) SIMU.HasConfiguration - fromResource conf - -""" -Returns the list of all models in the current project. -""" -allModels :: () -> [Model] -allModels _ = map fromResource $ objectsWithType (currentProject ()) L0.ConsistsOf SIMU.Model - -importJava "org.simantics.modeling.ModelingUtils" where - """Removes the index associated with the model.""" - removeIndex :: Model -> () - - resetIssueSources :: Model -> () - - """Copies annotation types from one model to another.""" - copyAnnotationTypes :: Model -> Model -> () - - deleteIndex :: Resource -> () - releaseMemory :: () -> () - - searchByType :: Resource -> Resource -> [Resource] - searchByTypeShallow :: Resource -> Resource -> [Resource] - searchByTypeAndName :: Resource -> Resource -> String -> [Resource] - searchByTypeAndNameShallow :: Resource -> Resource -> String -> [Resource] - searchByQuery :: Resource -> String -> [Resource] - searchByQueryShallow :: Resource -> String -> [Resource] - searchByTypeAndFilter :: Resource -> Resource -> (Resource -> Boolean) -> [Resource] - - listIndexEntries :: Resource -> String -> String - activateModel :: Resource -> Boolean - - @JavaName createModel - createGenericModel :: Resource -> String -> Resource - -importJava "org.simantics.modeling.ModelingUtils" where - @JavaName getPossibleModel - getPossibleModel :: Resource -> Model - possibleIndexRoot :: Resource -> Maybe Resource - -activateModelAction :: Resource -> () -activateModelAction model = do - syncWrite (\() -> activateModel model) - () - - \ No newline at end of file +include "Simantics/Entity" hiding (nameOf) +include "Simantics/Ontologies" +import "Simantics/Misc" + +type Model = Resource +type Configuration = Resource + +""" + model name + +Returns an existing model in the current project with the given `name` +""" +model :: String -> Model +model name = match possibleResourceChild (currentProject ()) name with + Just m -> m + Nothing -> fail $ "Didn't find a model " + name + "." + +""" + configurationOf model + +Returns the configuration of the given `model` +and returns the `configuration` resource +""" +configurationOf :: Model -> Configuration +configurationOf m = singleObject m SIMU.HasConfiguration + +""" +Returns the list of all models in the current project. +""" +allModels :: () -> [Model] +allModels _ = objectsWithType (currentProject ()) L0.ConsistsOf SIMU.Model + +importJava "org.simantics.modeling.ModelingUtils" where + """Removes the index associated with the model.""" + removeIndex :: Model -> () + + resetIssueSources :: Model -> () + + """Copies annotation types from one model to another.""" + copyAnnotationTypes :: Model -> Model -> () + + deleteIndex :: Resource -> () + releaseMemory :: () -> () + + searchByType :: Resource -> Resource -> [Resource] + searchByTypeShallow :: Resource -> Resource -> [Resource] + searchByTypeAndName :: Resource -> Resource -> String -> [Resource] + searchByTypeAndNameShallow :: Resource -> Resource -> String -> [Resource] + searchByQuery :: Resource -> String -> [Resource] + searchByQueryShallow :: Resource -> String -> [Resource] + searchByTypeAndFilter :: Resource -> Resource -> (Resource -> Boolean) -> [Resource] + + listIndexEntries :: Resource -> String -> 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 -> Boolean + + @JavaName createModel + createGenericModel :: Resource -> String -> Resource + +importJava "org.simantics.modeling.ModelingUtils" where + @JavaName getPossibleModel + getPossibleModel :: Resource -> Model + possibleIndexRoot :: Resource -> Maybe Resource + +activateModelAction :: Resource -> () +activateModelAction model = do + syncWrite (\() -> activateModel model) + () + +""" +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 -> Boolean +syncActivateModel model = do + result = syncWrite (\() -> activateModel model) + syncGraph () + result \ No newline at end of file