]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling/scl/Simantics/Misc.scl
setSystemProperty function to Simantics/Misc SCL-module
[simantics/platform.git] / bundles / org.simantics.modeling / scl / Simantics / Misc.scl
1 import "Simantics/Entity" hiding (nameOf)
2 include "File"
3 import "StandardLibrary" hiding (group)
4
5 /*
6 importJava "java.io.File" where
7     data File
8     
9     @JavaName "<init>"
10     file :: String -> File
11     
12 */
13
14 importJava "java.util.Scanner" where
15     data Scanner
16     
17     @JavaName "<init>"
18     scanner :: File -> <Proc> Scanner
19     
20     @JavaName "hasNext"
21     hasNext :: Scanner -> Boolean
22     
23     @JavaName "nextLine"
24     nextLine :: Scanner -> String
25     
26     @JavaName "next"
27     scanNext :: Scanner -> String
28     
29     @JavaName "nextLine"
30     scanNextLine :: Scanner -> String
31
32 importJava "java.util.regex.Pattern" where
33     data Pattern
34     
35     @JavaName "compile"
36     compile :: String -> <Proc> Pattern
37     
38     @JavaName "matcher"
39     matcher :: Pattern -> String -> Matcher
40
41 importJava "java.util.regex.Matcher" where
42     data Matcher
43     
44     @JavaName "matches"
45     matches :: Matcher -> Boolean
46     
47     group :: Matcher -> String
48
49 importJava "org.simantics.utils.ui.BundleUtils" where
50     @JavaName "findFile"
51     bundleFile :: String -> String -> File
52
53 importJava "org.simantics.modeling.SCL" where
54
55     killPlatformWrite :: () -> <WriteGraph> ()
56     killPlatformRead :: () -> <ReadGraph> ()
57     killPlatform :: () -> ()
58     shutdownPlatform :: () -> ()
59     reconnectPlatform :: () -> ()
60     sleep :: Integer -> <Proc> ()
61     synchronizeOntologies :: () -> <Proc> ()
62     
63     syncGraph :: () -> <Proc> ()
64     
65     deleteMBNode :: [Resource] -> Boolean
66     
67     hasSomethingToPaste :: Resource -> <ReadGraph> Boolean
68     canDelete :: Resource -> <ReadGraph> Boolean
69     canRename :: Resource -> <ReadGraph> Boolean
70     
71     currentDate :: String -> String
72
73     workspaceDirectory :: () -> File
74     
75     queryPreference :: String -> String -> <ReadGraph> String
76
77 importJava "java.lang.Math" where
78     @JavaName random
79     javaRandom :: () -> Double
80     
81 loop :: Scanner -> String -> Pattern -> [String] -> <Proc> [String]    
82 loop testScan testName testPattern testList = do
83     if (hasNext testScan) == True
84     then do
85         testName = nextLine testScan
86         show "asd"
87         testMatcher = matcher testPattern testName
88         if (matches testMatcher) == True
89         then loop testScan testName testPattern (testList + [(scanNext testScan)])
90         else loop testScan testName testPattern testList
91     else testList
92     
93 loop1 :: Scanner -> [String] -> <Proc> [String]
94 loop1 testScan testList = do
95     if (hasNext testScan) == True
96     then do
97         newList = testList + [trim (scanNextLine testScan)]
98         loop1 testScan newList
99     else testList
100
101 loop2 :: Scanner -> [String] -> Boolean -> <Proc> [String]
102 loop2 testScan testList found = do
103     if hasNext testScan
104     then do
105         nextline = (scanNextLine testScan)
106         if found
107         then do
108             nextString1 = replaceString nextline "M7: " ""
109             newList = testList + [replaceString nextString1 "_CM1" ""]
110             found = (contains nextline "omposition ")
111             loop2 testScan newList found
112         else do
113             found = (contains nextline "omposition ")
114             loop2 testScan testList found
115     else testList
116     
117 loop3 ::  Scanner -> [String] -> <Proc> [String]
118 loop3 testScan testList = do
119     if hasNext testScan
120     then do
121         nextString = scanNext testScan
122         found = (contains nextString "_NO1")
123         if found
124         then do
125             nextString1 = (replaceString nextString "M6: " "")
126             newList = testList + [replaceString nextString1 "_NO1" ""]
127             loop3 testScan newList
128         else do
129             loop3 testScan testList
130     else testList
131     
132 loop4 ::  Scanner -> [String] -> Boolean -> <Proc> [String]
133 loop4 testScan testList found = do
134     if (hasNext testScan) == True
135     then do
136         nextString = (scanNext testScan)
137         newList = testList + [nextString]
138         loop4 testScan newList found
139     else testList
140
141 importJava "java.lang.System" where
142     @JavaName "getProperty"
143     getSystemProperty :: String -> Maybe String
144     @JavaName setProperty
145     setSystemProperty :: String -> String -> <Proc> String
146
147 importJava "org.simantics.modeling.LifeCycleContext" where
148     data LifeCycleContext
149
150 importJava "org.simantics.modeling.ModelingUtils" where
151     trackDependencies :: <Proc> ()
152     untrackDependencies :: <Proc> ()
153     trackOntologicalRequirements :: <Proc> ()
154     untrackOntologicalRequirements :: <Proc> ()
155
156 importJava "org.simantics.modeling.scl.SCLDependencyChangeListener" where
157     @JavaName "create"
158     createDependencyChangeListener :: (<Proc> Boolean) -> (MetadataI -> DependencyChanges -> <ReadGraph,Proc> ()) -> ChangeListener
159