From 498ad557cd7d405d65897d35423764a35da8dc92 Mon Sep 17 00:00:00 2001 From: miettinen Date: Thu, 20 Feb 2014 10:49:24 +0000 Subject: [PATCH] Sysdyn Ghost variable to not generate "No unit defined" issue (refs #4707). git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@28903 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../sysdyn/representation/utils/UnitUtils.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/utils/UnitUtils.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/utils/UnitUtils.java index d74b5934..133dfb4b 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/utils/UnitUtils.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/utils/UnitUtils.java @@ -32,6 +32,7 @@ import org.simantics.sysdyn.manager.SysdynModel; import org.simantics.sysdyn.representation.Configuration; import org.simantics.sysdyn.representation.IElement; import org.simantics.sysdyn.representation.Module; +import org.simantics.sysdyn.representation.Shadow; import org.simantics.sysdyn.representation.Variable; import org.simantics.sysdyn.unitParser.ParseException; import org.simantics.sysdyn.unitParser.UnitCheckingException; @@ -139,6 +140,8 @@ public class UnitUtils { // Support listening, if graph and mapping exists if(graph != null && model != null) { + if (var instanceof Shadow) + var = ((Shadow)var).getOriginal(); Resource varResource = model.getMapping().inverseGet(var); if(varResource != null) { try { @@ -187,8 +190,14 @@ public class UnitUtils { for(IElement e : configuration.getElements()) { if(e instanceof Variable) { Variable var = (Variable)e; - if(var.getName().equals(element)) - return var; + try { + if(var.getName().equals(element)) + return var; + } catch (NullPointerException npe) { + npe.printStackTrace(); + System.out.println("See UnitUtils"); + return null; + } } else if(e instanceof Module && elements.length > 1) { Module mod = (Module)e; if(mod.getName().equals(element)) { -- 2.47.1