X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.structural2%2Fsrc%2Forg%2Fsimantics%2Fstructural2%2Fvariables%2FConnectionBrowser.java;fp=bundles%2Forg.simantics.structural2%2Fsrc%2Forg%2Fsimantics%2Fstructural2%2Fvariables%2FConnectionBrowser.java;h=11a49f01705e002a73a44c7e1d2d36aa90d4fafc;hp=60fee19b20b9298aebe90b086d4788f445ad9b8a;hb=047ff1c43c7bf58acad5098d020434586ddfcbe0;hpb=bd27aa4cd3ca0ce7d6e7d28bc3d86c381478ef63 diff --git a/bundles/org.simantics.structural2/src/org/simantics/structural2/variables/ConnectionBrowser.java b/bundles/org.simantics.structural2/src/org/simantics/structural2/variables/ConnectionBrowser.java index 60fee19b2..11a49f017 100644 --- a/bundles/org.simantics.structural2/src/org/simantics/structural2/variables/ConnectionBrowser.java +++ b/bundles/org.simantics.structural2/src/org/simantics/structural2/variables/ConnectionBrowser.java @@ -624,47 +624,41 @@ public class ConnectionBrowser { needDrill = new THashSet(climbed.size()); needDrill.add(desc); } else { + if(relationType != null) { + if(!filterByRelationType(graph, desc, relationType)) + continue; + } if(result == null) result = new THashSet(climbed.size()); result.add(desc); } } - if(needDrill == null) { - /* - * All descriptors were already flat - just take case of filtering - */ - if(relationType != null) { - ArrayList filtered = new ArrayList(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 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(climbed.size()); + result.add(drill); + } + } } } - - /* - * There were some descriptors that require drill - */ - for(VariableConnectionPointDescriptor top : needDrill) { - Collection 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(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 {