--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.modeling.ui.modelBrowser2.contributions;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.Map;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.Queries;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.structural.ui.modelBrowser.nodes.AbstractNode;\r
+\r
+/**\r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class DependenciesViewContributor implements RelationViewContributor {\r
+\r
+ public Collection<?> getContribution(ReadGraph graph, Collection<Map<String, Object>> indexedResults) throws DatabaseException {\r
+ ArrayList<Object> result = new ArrayList<Object>();\r
+\r
+ for(Map<String, Object> entry : indexedResults) {\r
+ Object resource = entry.get("Resource");\r
+ if (resource != null) {\r
+ AbstractNode node = graph.syncRequest(Queries.adapt((Resource) resource, AbstractNode.class, true));\r
+ if (node != null) {\r
+ result.add(node);\r
+ } else {\r
+ result.add(resource);\r
+ }\r
+ } else {\r
+ Object name = entry.get("Name");\r
+ if (name != null) {\r
+ result.add(name);\r
+ } else {\r
+ StringBuilder b = new StringBuilder();\r
+ for (Map.Entry<String, Object> e : entry.entrySet()) {\r
+ b.append(e.getValue().toString());\r
+ }\r
+ result.add(b.toString());\r
+ }\r
+ }\r
+ }\r
+\r
+ return result;\r
+ }\r
+}\r