]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.structural2/src/org/simantics/structural2/variables/ConnectionBrowser.java
Variable optimizations for documents (Simupedia)
[simantics/platform.git] / bundles / org.simantics.structural2 / src / org / simantics / structural2 / variables / ConnectionBrowser.java
index 4a40723ef70110071c47447f57d952110738c02d..60fee19b20b9298aebe90b086d4788f445ad9b8a 100644 (file)
@@ -17,8 +17,8 @@ import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener;
 import org.simantics.db.common.request.BinaryRead;
 import org.simantics.db.common.request.ResourceRead;
 import org.simantics.db.common.request.TransientUnaryRead;
-import org.simantics.db.common.utils.CommonDBUtils;
 import org.simantics.db.common.utils.NameUtils;
+import org.simantics.db.common.utils.NearestOwnerFinder;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.exception.NoSingleResultException;
 import org.simantics.db.layer0.exception.MissingVariableException;
@@ -35,8 +35,6 @@ import org.simantics.structural2.Functions.InterfaceResolution;
 import org.simantics.structural2.queries.ConnectionSet;
 import org.simantics.structural2.utils.StructuralUtils;
 import org.simantics.structural2.utils.StructuralUtils.StructuralComponentClass;
-import org.simantics.structural2.variables.StandardProceduralChildVariable.FixedConnection;
-import org.simantics.utils.datastructures.Pair;
 
 import gnu.trove.map.hash.THashMap;
 import gnu.trove.set.hash.THashSet;
@@ -276,7 +274,7 @@ public class ConnectionBrowser {
                for (Resource composite : graph.getObjects(join, STR.JoinsComposite))
                        ancestorGenerators.add(composite);
             }
-            Resource ancestor = ancestorGenerators.size() == 1 ? ancestorGenerators.iterator().next() : CommonDBUtils.getNearestOwner(graph, ancestorGenerators);
+            Resource ancestor = ancestorGenerators.size() == 1 ? ancestorGenerators.iterator().next() : NearestOwnerFinder.getNearestOwnerFromDirectOwners(graph, ancestorGenerators);
             
             List<Resource> result = colls.createList();
             result.add(ancestor);
@@ -337,14 +335,9 @@ public class ConnectionBrowser {
                
                Variable conn = child.getPossibleProperty(graph, cp);
             FixedConnection fc = (FixedConnection)conn.getValue(graph);
-            Set<VariableConnectionPointDescriptor> result = new THashSet<VariableConnectionPointDescriptor>(1+fc.cps.size());
-            result.add(new ComponentConnectionDescriptor(child, cp));// (graph, STR, curConfiguration, "/" + c.name + "#" + conn.getName(graph)));
-            for(Pair<String,Resource> cpzz : fc.cps) {
-               if(cpzz.first == null) {
-                       throw new DatabaseException("Lifted connection was not resolved.");
-               }
-               result.add(new PairConnectionDescriptor(curConfiguration, cpzz));
-            }
+            Set<VariableConnectionPointDescriptor> result = new THashSet<VariableConnectionPointDescriptor>(1+fc.size());
+            result.add(new ComponentConnectionDescriptor(child, cp));
+            fc.addConnectionDescriptors(graph, curConfiguration, result);
             return result;
             
         } else {