1 /*******************************************************************************
\r
2 * Copyright (c) 2007 VTT Technical Research Centre of Finland and others.
\r
3 * All rights reserved. This program and the accompanying materials
\r
4 * are made available under the terms of the Eclipse Public License v1.0
\r
5 * which accompanies this distribution, and is available at
\r
6 * http://www.eclipse.org/legal/epl-v10.html
\r
9 * VTT Technical Research Centre of Finland - initial API and implementation
\r
10 *******************************************************************************/
\r
11 package fi.vtt.simantics.processeditor.monitors;
\r
13 import java.util.Collection;
\r
14 import java.util.List;
\r
16 import org.simantics.db.Resource;
\r
17 import org.simantics.layer0.utils.IEntity;
\r
18 import org.simantics.utils.datastructures.MapList;
\r
22 * Container for Paths
\r
24 * TODO : removing paths
\r
25 * TODO : prevent adding same path multiple times
\r
28 * @author Marko Luukkainen
\r
31 public class PathContainer {
\r
33 private static PathContainer instance = new PathContainer();
\r
35 MapList<Resource, List<Resource>> paths;
\r
37 private PathContainer() {
\r
38 paths = new MapList<Resource, List<Resource>>();
\r
41 public List<List<Resource>> getPaths(IEntity instance) {
\r
42 Collection<IEntity> types = instance.getTypes();
\r
43 if (types.size() != 1)
\r
44 throw new UnsupportedOperationException("Multi-instances not supported!");
\r
45 Resource type = types.iterator().next().getResource();
\r
46 return paths.getValues(type);
\r
49 public void addPath(Resource type, List<Resource> path) {
\r
50 paths.add(type, path);
\r
53 public void clearPaths(Resource type) {
\r
57 public static PathContainer getInstance() {
\r