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