]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.structural2/src/org/simantics/structural2/variables/ConnectionBrowser.java
Non-constant external value configuration via procedural UCs.
[simantics/platform.git] / bundles / org.simantics.structural2 / src / org / simantics / structural2 / variables / ConnectionBrowser.java
index b2b92039f87f4f35870c31ed0564c624a89cec75..11a49f01705e002a73a44c7e1d2d36aa90d4fafc 100644 (file)
@@ -17,7 +17,6 @@ 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;
@@ -36,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;
@@ -338,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 {
@@ -632,47 +624,41 @@ public class ConnectionBrowser {
                                needDrill = new THashSet<VariableConnectionPointDescriptor>(climbed.size());
                        needDrill.add(desc);
                } else {
+                if(relationType != null) {
+                    if(!filterByRelationType(graph, desc, relationType))
+                        continue;
+                }
                        if(result == null)
                                result = new THashSet<VariableConnectionPointDescriptor>(climbed.size());
                        result.add(desc);
                }
         }
         
-        if(needDrill == null) {
-               /*
-                * All descriptors were already flat - just take case of filtering
-                */
-            if(relationType != null) {
-                ArrayList<VariableConnectionPointDescriptor> filtered = new ArrayList<VariableConnectionPointDescriptor>(climbed.size());
-                for(VariableConnectionPointDescriptor desc : climbed)
-                    if(filterByRelationType(graph, desc, relationType))
-                        filtered.add(desc);
-                return filtered;
-            } else {
-                return climbed;
+        if(needDrill != null) {
+            /*
+             * There were some descriptors that require drill
+             */
+            for(VariableConnectionPointDescriptor top : needDrill) {
+                Collection<VariableConnectionPointDescriptor> drilled = drill(graph, top);
+                if(drilled != null) {
+                    for(VariableConnectionPointDescriptor drill : drilled) {
+                        if(relationType != null) {
+                            if(!filterByRelationType(graph, drill, relationType))
+                                continue;
+                        }
+                        if(result == null)
+                            result = new THashSet<VariableConnectionPointDescriptor>(climbed.size());
+                        result.add(drill);
+                    }
+                }
             }
         }
-        
 
-        /*
-         * There were some descriptors that require drill
-         */
-        for(VariableConnectionPointDescriptor top : needDrill) {
-               Collection<VariableConnectionPointDescriptor> drilled = drill(graph, top);
-            if(drilled != null) {
-               for(VariableConnectionPointDescriptor drill : drilled) {
-                       if(relationType != null) {
-                               if(!filterByRelationType(graph, drill, relationType))
-                                       continue;
-                       }
-                       if(result == null)
-                               result = new THashSet<VariableConnectionPointDescriptor>(climbed.size());
-                       result.add(drill);
-               }
-            }
+        if (result != null) {
+            return result;
+        } else {
+            return Collections.emptySet();
         }
-        return result;
-        
     }
     
     private static boolean filterByRelationType(ReadGraph graph, VariableConnectionPointDescriptor desc, Resource relationType) throws DatabaseException {