]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
refs #5106
authorjsimomaa <jsimomaa@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 16 Jul 2014 05:01:23 +0000 (05:01 +0000)
committerjsimomaa <jsimomaa@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 16 Jul 2014 05:01:23 +0000 (05:01 +0000)
Adding SelectionUtils class
Adding canEdit() method to determine if a selected resource is editable or not (based on immutability)

git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@29900 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn/src/org/simantics/sysdyn/utils/SelectionUtils.java [new file with mode: 0644]

diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/SelectionUtils.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/SelectionUtils.java
new file mode 100644 (file)
index 0000000..bb9272c
--- /dev/null
@@ -0,0 +1,24 @@
+package org.simantics.sysdyn.utils;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+\r
+/**\r
+ * @author Jani Simomaa\r
+ *\r
+ */\r
+public class SelectionUtils {\r
+\r
+    /**\r
+     * Checks whether <strong>resource</strong> can be edited\r
+     * \r
+     * @param graph\r
+     * @param resource\r
+     * @return\r
+     * @throws DatabaseException\r
+     */\r
+    public static boolean canEdit(ReadGraph graph, Resource resource) throws DatabaseException {\r
+        return !graph.isImmutable(resource);\r
+    }\r
+}\r