]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling/scl/Simantics/Rename.scl
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.modeling / scl / Simantics / Rename.scl
diff --git a/bundles/org.simantics.modeling/scl/Simantics/Rename.scl b/bundles/org.simantics.modeling/scl/Simantics/Rename.scl
new file mode 100644 (file)
index 0000000..a7d2a3c
--- /dev/null
@@ -0,0 +1,61 @@
+import "Simantics/Entity" hiding (findFreshName)\r
+\r
+importJava "org.simantics.modeling.Rename" where\r
+    @JavaName renameNode\r
+    """\r
+        renameNode resource newName\r
+        \r
+    Renames the given `resource` with the given `newName` and returns\r
+    `string`\r
+    \r
+    Example:\r
+    \r
+        > renameNode resource "NewName"\r
+        "Succesfully renamed oldName to NewName"\r
+        \r
+    or error if failed\r
+    """\r
+    renameNode :: Resource -> String -> <WriteGraph> String\r
+\r
+"""\r
+    renameMBNode entity newName\r
+    \r
+Renames the given `entity` with the given `newName` and returns\r
+`string`\r
+\r
+Example:\r
+\r
+    > renameMBNode entity "NewName"\r
+    "Succesfully renamed oldName to NewName"\r
+    \r
+or error if failed\r
+"""\r
+renameMBNode :: Resource -> String -> <WriteGraph> String\r
+renameMBNode entity newname = do\r
+    renameNode (toResource entity) newname\r
+\r
+importJava "org.simantics.db.common.utils.NameUtils" where\r
+    @JavaName findFreshName\r
+    """\r
+        findFreshName name container\r
+        \r
+    Finds fresh and unused name with proposition `name` under the given `container`\r
+    and returns the freshName\r
+    \r
+    Example:\r
+    \r
+        freshName = findFreshName "Model" currentProject ()\r
+    """\r
+    findFreshName :: String -> Resource -> <ReadGraph> String\r
+    \r
+    @JavaName getSafeName\r
+    """\r
+        getSafeName resource\r
+        \r
+    Gets safe name for the given `resource` and returns the name\r
+    \r
+    Example:\r
+    \r
+        name = getSafeName (toResource model)\r
+    """\r
+    getSafeName :: Resource -> <ReadGraph> String
\ No newline at end of file