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=7a7998047abfa174b456a2e757df827b4f74b6b7;hb=refs%2Fheads%2Fdev;hp=b0205f521aa800d115c38fe7ac2b88c2f9b0b3fc;hpb=b4fddf5cd72860d3f99f4b3d2e1a52b7c6f948d2;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..7a799804 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. + * Copyright (c) 2007- VTT Technical Research Centre of Finland. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -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) {