]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.issues.common/src/org/simantics/issues/common/All.java
Allow overriding issue hidden-ness/hiding logic in inheriting ontologies
[simantics/platform.git] / bundles / org.simantics.issues.common / src / org / simantics / issues / common / All.java
index 6eccb1755f22c746f9f91666e57b097a543467a8..d39ee983745bed698ffa35c49342d3228999252b 100644 (file)
@@ -14,6 +14,7 @@ import org.simantics.db.layer0.variable.Variables;
 import org.simantics.issues.ontology.IssueResource;
 import org.simantics.layer0.Layer0;
 import org.simantics.scl.reflection.annotations.SCLValue;
+import org.simantics.scl.runtime.function.Function1;
 
 public class All {
        
@@ -96,4 +97,30 @@ public class All {
         throw new IllegalArgumentException("Unsupported property type: " + property);
     }
 
+    @SCLValue(type = "ReadGraph -> Resource -> a -> b")
+    public static Function1<Boolean, Boolean> standardIssueHider(ReadGraph graph, Resource converter, Object property) throws DatabaseException {
+        if (property instanceof Variable) {
+            Variable hider = (Variable) property;
+            Variable issue = hider.getParent(graph);
+            Resource r = issue.getPossibleRepresents(graph);
+            if (r != null)
+                return new HideFunction(r);
+        }
+        return null;
+    }
+
+    @SCLValue(type = "ReadGraph -> Resource -> a -> Boolean")
+    public static Boolean standardIssueHidden(ReadGraph graph, Resource converter, Object property) throws DatabaseException {
+        if (property instanceof Variable) {
+            Variable hidden = (Variable) property;
+            Variable issue = hidden.getParent(graph);
+            Resource r = issue.getPossibleRepresents(graph);
+            if (r != null) {
+                IssueResource ISSUE = IssueResource.getInstance(graph);
+                return graph.hasStatement(r, ISSUE.Hidden);
+            }
+        }
+        return false;
+    }
+
 }