]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling/src/org/simantics/modeling/adapters/SCLChildRule.java
Fixed problems in shared libraries view
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / adapters / SCLChildRule.java
index 52349e5821acec2f1a8d476b9c31cd901c8b2ad1..a04b9315f544d698913c655ce084e485ec05224a 100644 (file)
@@ -28,21 +28,27 @@ public class SCLChildRule implements ChildRule {
     }
 
     @Override
-    public Collection<?> getChildren(ReadGraph graph, Object parent) throws DatabaseException {
+    public Collection<Resource> getChildren(ReadGraph graph, Object parent) throws DatabaseException {
+        Resource parentResource;
+        
+        if (parent instanceof Variable) {
+            parentResource = ((Variable)parent).getRepresents(graph);
+        } else {
+            parentResource = (Resource)parent;
+        }
         
         ModelingResources MOD = ModelingResources.getInstance(graph);
         
         Variable ruleVariable = Variables.getVariable(graph, rule);
 
-        Function1<Object,List<?>> getChildren = ruleVariable.getPossiblePropertyValue(graph, MOD.SCLChildRule_getChildren);
+        Function1<Resource,List<Resource>> getChildren = ruleVariable.getPossiblePropertyValue(graph, MOD.SCLChildRule_getChildren);
         if(getChildren == null) return Collections.emptyList();
 
         SCLContext sclContext = SCLContext.getCurrent();
         Object oldGraph = sclContext.get("graph");
         try {
             sclContext.put("graph", graph);
-            Object value = getChildren.apply(parent);
-            return (Collection<?>)value;
+            return getChildren.apply(parentResource);
         } catch (Throwable t) {
                throw new DatabaseException(t);
         } finally {