*******************************************************************************/\r
package org.simantics.sysdyn.adapter;\r
\r
-import java.util.ArrayList;\r
import java.util.Collection;\r
+import java.util.HashMap;\r
import java.util.Map;\r
\r
import org.simantics.db.ReadGraph;\r
super(parent, resource);\r
}\r
\r
-// @Override\r
-// public Variable getPossibleChild(ReadGraph graph, String name) throws DatabaseException {\r
-// Map<String, Resource> children = graph.syncRequest(new UnescapedChildMapOfResource(resource));\r
-// Resource child = children.get(name);\r
-// if(child == null) {\r
-// return getPossibleSpecialChild(graph, name);\r
-// }\r
-// else return graph.adaptContextual(child, this, Variable.class, Variable.class);\r
-// }\r
-\r
-\r
@Override\r
public Collection<Variable> browseChildren(ReadGraph graph) throws DatabaseException {\r
- ArrayList<Variable> result = new ArrayList<Variable>();\r
- for(Resource child : graph.syncRequest(new UnescapedChildMapOfResource(resource)).values()) {\r
+ Map<String, Variable> result = new HashMap<String, Variable>();\r
+ for(Map.Entry<String, Resource> entry : graph.syncRequest(new UnescapedChildMapOfResource(resource)).entrySet()) {\r
+ String name = entry.getKey();\r
+ Resource child = entry.getValue();\r
try {\r
- result.add(graph.adaptContextual(child, this, Variable.class, Variable.class));\r
+ result.put(name, graph.adaptContextual(child, this, Variable.class, Variable.class));\r
} catch (AdaptionException e) {\r
}\r
}\r
collectSpecialChildren(graph, result);\r
- return result;\r
+ return result.values();\r
}\r
\r
}\r
\r
import java.util.ArrayList;\r
import java.util.Collection;\r
+import java.util.HashMap;\r
import java.util.Map;\r
\r
import org.simantics.db.ReadGraph;\r
\r
@Override\r
public Collection<Variable> browseChildren(ReadGraph graph) throws DatabaseException {\r
- ArrayList<Variable> result = new ArrayList<Variable>();\r
+ Map<String, Variable> result = new HashMap<String, Variable>();\r
Resource config = getConfiguration(graph);\r
- for(Resource child : graph.syncRequest(new UnescapedChildMapOfResource(config)).values())\r
- result.add(new HistoryVariable(this, child));\r
+ for(Map.Entry<String, Resource> entry : graph.syncRequest(new UnescapedChildMapOfResource(config)).entrySet()) {\r
+ String name = entry.getKey();\r
+ Resource child = entry.getValue();\r
+ result.put(name, new HistoryVariable(this, child));\r
+ }\r
collectSpecialChildren(graph, result);\r
- return result;\r
+ return result.values();\r
}\r
\r
Resource getConfiguration(ReadGraph graph) throws DatabaseException {\r