From: miettinen Date: Thu, 20 Feb 2014 10:49:24 +0000 (+0000) Subject: Sysdyn Ghost variable to not generate "No unit defined" issue (refs #4707). X-Git-Tag: 1.8.1~131 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=498ad557cd7d405d65897d35423764a35da8dc92;p=simantics%2Fsysdyn.git 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 --- 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)) {