From 02b839782670538923022aaa790cbc6b43ee5bdf Mon Sep 17 00:00:00 2001 From: Antti Villberg Date: Sun, 7 May 2017 09:41:46 +0300 Subject: [PATCH] InstanceOf tester (VP.Test) refs #7192 Change-Id: Ife996f7b8dfa7d302877aef7dfad7f4bc711211d --- .../graph/ModelingViewpoint.pgraph | 11 ++++++++++- .../scl/Simantics/Testing/BrowseContext.scl | 6 +++++- bundles/org.simantics.modeling/scl/Simantics/All.scl | 3 ++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/bundles/org.simantics.modeling.ontology/graph/ModelingViewpoint.pgraph b/bundles/org.simantics.modeling.ontology/graph/ModelingViewpoint.pgraph index 7e572df9f..e71c13997 100644 --- a/bundles/org.simantics.modeling.ontology/graph/ModelingViewpoint.pgraph +++ b/bundles/org.simantics.modeling.ontology/graph/ModelingViewpoint.pgraph @@ -29,7 +29,7 @@ MOD.SCLAction MOD.SCLDropAction.action ==> "Resource -> Dynamic -> Integer -> ()" MOD.SCLTest.test ==> "Resource -> Boolean" -- MOD.InstanceOfTest.HasType --> L0.Type Boolean" + +MOD.instanceOfTest : L0.Template + @template %test %type + %test : MOD.InstanceOfTest + MOD.InstanceOfTest.HasType %type + TESTS = MAC.Tests : L0.Library TESTS.IsNotPublished @MOD.sclTest "isNotPublished" diff --git a/bundles/org.simantics.modeling.ui/scl/Simantics/Testing/BrowseContext.scl b/bundles/org.simantics.modeling.ui/scl/Simantics/Testing/BrowseContext.scl index 3edb179fc..cd4e9755d 100644 --- a/bundles/org.simantics.modeling.ui/scl/Simantics/Testing/BrowseContext.scl +++ b/bundles/org.simantics.modeling.ui/scl/Simantics/Testing/BrowseContext.scl @@ -1,4 +1,4 @@ -import "Simantics/DB" +import "Simantics/Variables" import "Map" as Map import "Simantics/Testing/BuiltinKeys" @@ -126,3 +126,7 @@ createBrowseContext resource = do importJava "org.simantics.browsing.ui.common.NodeContextBuilder" where buildWithInput :: a -> NodeContext +instanceOfTest :: Variable -> (Resource -> Boolean) +instanceOfTest self = do + typeResource = singleObject (represents $ parent self) MOD.InstanceOfTest.HasType + (\r -> isInstanceOf r typeResource) diff --git a/bundles/org.simantics.modeling/scl/Simantics/All.scl b/bundles/org.simantics.modeling/scl/Simantics/All.scl index 07f8a0464..00d6980cf 100644 --- a/bundles/org.simantics.modeling/scl/Simantics/All.scl +++ b/bundles/org.simantics.modeling/scl/Simantics/All.scl @@ -31,4 +31,5 @@ include "SWT/All" include "Simantics/UI" include "Simantics/SelectionView" include "Simantics/Formatting" -include "Simantics/Action" \ No newline at end of file +include "Simantics/Action" +include "Simantics/Testing/BrowseContext" \ No newline at end of file -- 2.47.1