From 79f0e4ac45c041ae3740c52f14f3c897fa78186b Mon Sep 17 00:00:00 2001 From: villberg Date: Tue, 20 Mar 2012 12:52:19 +0000 Subject: [PATCH] =?utf8?q?Variable-j=C3=B6=C3=B6ti.=20This=20can=20be=20da?= =?utf8?q?ngerous.=20refs=20#3246?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@24487 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../sysdyn/adapter/ConfigurationVariable.java | 23 ++++++------------- .../simantics/sysdyn/adapter/RunVariable.java | 12 ++++++---- 2 files changed, 15 insertions(+), 20 deletions(-) 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 { -- 2.47.1