From: villberg Date: Tue, 20 Mar 2012 12:52:19 +0000 (+0000) Subject: Variable-jööti. This can be dangerous. X-Git-Tag: simantics-1.6~21 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=79f0e4ac45c041ae3740c52f14f3c897fa78186b;p=simantics%2Fsysdyn.git Variable-jööti. This can be dangerous. refs #3246 git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@24487 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ConfigurationVariable.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ConfigurationVariable.java index a1013322..86d6dac9 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ConfigurationVariable.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ConfigurationVariable.java @@ -11,8 +11,8 @@ *******************************************************************************/ package org.simantics.sysdyn.adapter; -import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.Map; import org.simantics.db.ReadGraph; @@ -29,28 +29,19 @@ public class ConfigurationVariable extends StandardGraphChildVariable { super(parent, resource); } -// @Override -// public Variable getPossibleChild(ReadGraph graph, String name) throws DatabaseException { -// Map children = graph.syncRequest(new UnescapedChildMapOfResource(resource)); -// Resource child = children.get(name); -// if(child == null) { -// return getPossibleSpecialChild(graph, name); -// } -// else return graph.adaptContextual(child, this, Variable.class, Variable.class); -// } - - @Override public Collection browseChildren(ReadGraph graph) throws DatabaseException { - ArrayList result = new ArrayList(); - for(Resource child : graph.syncRequest(new UnescapedChildMapOfResource(resource)).values()) { + Map result = new HashMap(); + for(Map.Entry entry : graph.syncRequest(new UnescapedChildMapOfResource(resource)).entrySet()) { + String name = entry.getKey(); + Resource child = entry.getValue(); try { - result.add(graph.adaptContextual(child, this, Variable.class, Variable.class)); + result.put(name, graph.adaptContextual(child, this, Variable.class, Variable.class)); } catch (AdaptionException e) { } } collectSpecialChildren(graph, result); - return result; + return result.values(); } } diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/RunVariable.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/RunVariable.java index d3b817a8..fe81e47f 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/RunVariable.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/RunVariable.java @@ -13,6 +13,7 @@ package org.simantics.sysdyn.adapter; import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.Map; import org.simantics.db.ReadGraph; @@ -44,12 +45,15 @@ public class RunVariable extends StandardGraphChildVariable { @Override public Collection browseChildren(ReadGraph graph) throws DatabaseException { - ArrayList result = new ArrayList(); + Map result = new HashMap(); Resource config = getConfiguration(graph); - for(Resource child : graph.syncRequest(new UnescapedChildMapOfResource(config)).values()) - result.add(new HistoryVariable(this, child)); + for(Map.Entry entry : graph.syncRequest(new UnescapedChildMapOfResource(config)).entrySet()) { + String name = entry.getKey(); + Resource child = entry.getValue(); + result.put(name, new HistoryVariable(this, child)); + } collectSpecialChildren(graph, result); - return result; + return result.values(); } Resource getConfiguration(ReadGraph graph) throws DatabaseException {