]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Variable-jööti. This can be dangerous.
authorvillberg <villberg@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 20 Mar 2012 12:52:19 +0000 (12:52 +0000)
committervillberg <villberg@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 20 Mar 2012 12:52:19 +0000 (12:52 +0000)
refs #3246

git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@24487 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ConfigurationVariable.java
org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/RunVariable.java

index a1013322f5dcab13810cfbe95b02a3b5d3807318..86d6dac98cd3cc64ce859a80f140616b5ede11f6 100644 (file)
@@ -11,8 +11,8 @@
  *******************************************************************************/\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
@@ -29,28 +29,19 @@ public class ConfigurationVariable extends StandardGraphChildVariable {
                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
index d3b817a88d624a5a92b5cc8e713c8321cf1e949a..fe81e47ff1912d86986161b2339474ebbb0dc84c 100644 (file)
@@ -13,6 +13,7 @@ package org.simantics.sysdyn.adapter;
 \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
@@ -44,12 +45,15 @@ public class RunVariable extends StandardGraphChildVariable {
 \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