X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.proconf.processeditor%2Fsrc%2Forg%2Fsimantics%2Fprocesseditor%2Fmonitors%2FPathContainer.java;h=f41b4b1f498c81bb5562f7ca6cd410e6c5d3372e;hb=b3c3be84d629d56b355fc6bb8cee8ae16990d783;hp=b0205f521aa800d115c38fe7ac2b88c2f9b0b3fc;hpb=b553dad9a38b0fa9a91926f3a4ff89b9cb8efa91;p=simantics%2F3d.git diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/monitors/PathContainer.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/monitors/PathContainer.java index b0205f52..f41b4b1f 100644 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/monitors/PathContainer.java +++ b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/monitors/PathContainer.java @@ -23,6 +23,7 @@ import org.simantics.utils.datastructures.MapList; * FIXME : singleton * TODO : removing paths * TODO : prevent adding same path multiple times + * TODO : how to handle multi-instances? * * * @author Marko Luukkainen @@ -33,17 +34,29 @@ public class PathContainer { private static PathContainer instance = new PathContainer(); MapList> paths; + //List,List>> multiInstancePaths; private PathContainer() { paths = new MapList>(); + //multiInstancePaths = new ArrayList,List>>(); } public List> getPaths(IEntity instance) { Collection types = instance.getTypes(); - if (types.size() != 1) - throw new UnsupportedOperationException("Multi-instances not supported!"); - Resource type = types.iterator().next().getResource(); - return paths.getValues(type); + if (types.size() != 1) { + // for multi-instances we check if any of the types have paths + // no we return paths for a single type (it is possible to combine paths for all types) + for (IEntity type : types) { + Resource r = type.getResource(); + List> path = paths.getValues(r); + if (path != null) + return path; + } + return null; + } else { + Resource type = types.iterator().next().getResource(); + return paths.getValues(type); + } } public void addPath(Resource type, List path) {