]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling/scl/Simantics/Model.scl
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.modeling / scl / Simantics / Model.scl
1 include "Simantics/Entity" hiding (nameOf)
2 include "Simantics/Ontologies"
3
4 type Model = Resource
5 type Configuration = Resource
6
7 """
8     model name
9     
10 Returns an existing model in the current project with the given `name`
11 """
12 model :: String -> <ReadGraph> Model
13 model name = match possibleResourceChild (currentProject ()) name with
14     Just m -> fromResource m
15     Nothing -> fail $ "Didn't find a model " + name + "." 
16
17 """
18     configurationOf model
19     
20 Returns the configuration of the given `model`
21 and returns the `configuration` resource
22 """
23 configurationOf :: Model -> <ReadGraph> Configuration
24 configurationOf m = do
25     conf = singleObject (toResource m) SIMU.HasConfiguration 
26     fromResource conf
27
28 """
29 Returns the list of all models in the current project.
30 """
31 allModels :: () -> <ReadGraph> [Model]
32 allModels _ = map fromResource $ objectsWithType (currentProject ()) L0.ConsistsOf SIMU.Model
33
34 importJava "org.simantics.modeling.ModelingUtils" where
35     """Removes the index associated with the model."""
36     removeIndex :: Model -> <WriteGraph> ()
37     
38     resetIssueSources :: Model -> <WriteGraph> ()
39     
40     """Copies annotation types from one model to another."""
41     copyAnnotationTypes :: Model -> Model -> <WriteGraph> ()
42     
43     deleteIndex :: Resource -> <WriteGraph> ()
44     releaseMemory :: () -> <WriteGraph> ()
45     
46     searchByType :: Resource -> Resource -> <ReadGraph> [Resource]
47     searchByTypeShallow :: Resource -> Resource -> <ReadGraph> [Resource]
48     searchByTypeAndName :: Resource -> Resource -> String -> <ReadGraph> [Resource]
49     searchByTypeAndNameShallow :: Resource -> Resource -> String -> <ReadGraph> [Resource]
50     searchByQuery :: Resource -> String -> <ReadGraph> [Resource]
51     searchByQueryShallow :: Resource -> String -> <ReadGraph> [Resource]
52     searchByTypeAndFilter :: Resource -> Resource -> (Resource -> <ReadGraph> Boolean) -> <ReadGraph> [Resource]
53     
54     listIndexEntries :: Resource -> String -> <ReadGraph> String
55     activateModel :: Resource -> <WriteGraph> Boolean
56     
57     @JavaName createModel
58     createGenericModel :: Resource -> String -> <WriteGraph> Resource
59
60 importJava "org.simantics.modeling.ModelingUtils" where
61     @JavaName getPossibleModel
62     getPossibleModel :: Resource -> <ReadGraph> Model
63     possibleIndexRoot :: Resource -> <ReadGraph> Maybe Resource
64
65 activateModelAction :: Resource -> <Proc> ()
66 activateModelAction model = do
67   syncWrite (\() -> activateModel model)
68   ()
69     
70