]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.tests.modelled.ui/src/org/simantics/tests/modelled/ui/adapters/IsTestIgnored.java
Enhancements to modelled STS-tests
[simantics/platform.git] / bundles / org.simantics.tests.modelled.ui / src / org / simantics / tests / modelled / ui / adapters / IsTestIgnored.java
diff --git a/bundles/org.simantics.tests.modelled.ui/src/org/simantics/tests/modelled/ui/adapters/IsTestIgnored.java b/bundles/org.simantics.tests.modelled.ui/src/org/simantics/tests/modelled/ui/adapters/IsTestIgnored.java
new file mode 100644 (file)
index 0000000..a58f3b3
--- /dev/null
@@ -0,0 +1,44 @@
+package org.simantics.tests.modelled.ui.adapters;
+
+import java.util.Map;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.simantics.browsing.ui.model.images.ImageRule;
+import org.simantics.browsing.ui.model.tests.Test;
+import org.simantics.browsing.ui.model.visuals.VisualsRule;
+import org.simantics.databoard.Bindings;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.tests.modelled.ontology.TestsResource;
+
+public enum IsTestIgnored implements Test, VisualsRule, ImageRule {
+
+    INSTANCE;
+
+    public static IsTestIgnored get() {
+        return INSTANCE;
+    }
+
+    @Override
+    public boolean isCompatible(Class<?> contentType) {
+        return Resource.class.equals(contentType);
+    }
+
+    @Override
+    public boolean test(ReadGraph graph, Object content) throws DatabaseException {
+        if (content instanceof Resource) {
+            Resource resource = (Resource) content;
+            TestsResource TESTS = TestsResource.getInstance(graph);
+            return graph.getPossibleRelatedValue2(resource, TESTS.ignore, Bindings.BOOLEAN);
+        }
+        return false;
+    }
+
+    @Override
+    public Map<String, ImageDescriptor> getImage(ReadGraph graph, Object content) throws DatabaseException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}