/******************************************************************************* * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. * 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 * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * VTT Technical Research Centre of Finland - initial API and implementation *******************************************************************************/ package org.simantics.processeditor.monitors; import java.util.Collection; import java.util.List; import org.simantics.db.Resource; import org.simantics.layer0.utils.IEntity; import org.simantics.utils.datastructures.MapList; /** * Container for Paths * FIXME : singleton * TODO : removing paths * TODO : prevent adding same path multiple times * * * @author Marko Luukkainen * */ public class PathContainer { private static PathContainer instance = new PathContainer(); MapList> paths; private PathContainer() { paths = new MapList>(); } 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); } public void addPath(Resource type, List path) { paths.add(type, path); } public void clearPaths(Resource type) { paths.remove(type); } public static PathContainer getInstance() { return instance; } }