]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Sysdyn Ghost variable to not generate "No unit defined" issue (refs #4707).
authormiettinen <miettinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 20 Feb 2014 10:49:24 +0000 (10:49 +0000)
committermiettinen <miettinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 20 Feb 2014 10:49:24 +0000 (10:49 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@28903 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn/src/org/simantics/sysdyn/representation/utils/UnitUtils.java

index d74b59345a4434f61b1f54c13ae814ff4b18dd77..133dfb4b39b114cc51ba70fa64f099c79a1cd945 100644 (file)
@@ -32,6 +32,7 @@ import org.simantics.sysdyn.manager.SysdynModel;
 import org.simantics.sysdyn.representation.Configuration;\r
 import org.simantics.sysdyn.representation.IElement;\r
 import org.simantics.sysdyn.representation.Module;\r
+import org.simantics.sysdyn.representation.Shadow;\r
 import org.simantics.sysdyn.representation.Variable;\r
 import org.simantics.sysdyn.unitParser.ParseException;\r
 import org.simantics.sysdyn.unitParser.UnitCheckingException;\r
@@ -139,6 +140,8 @@ public class UnitUtils {
                 \r
                 // Support listening, if graph and mapping exists\r
                 if(graph != null && model != null) {\r
+                       if (var instanceof Shadow)\r
+                               var = ((Shadow)var).getOriginal();\r
                     Resource varResource = model.getMapping().inverseGet(var);\r
                     if(varResource != null) {\r
                         try {\r
@@ -187,8 +190,14 @@ public class UnitUtils {
         for(IElement e : configuration.getElements()) {\r
             if(e instanceof Variable) {\r
                 Variable var = (Variable)e;\r
-                if(var.getName().equals(element))\r
-                    return var;\r
+                try {\r
+                       if(var.getName().equals(element))\r
+                               return var;\r
+                } catch (NullPointerException npe) {\r
+                       npe.printStackTrace();\r
+                       System.out.println("See UnitUtils");\r
+                       return null;\r
+                }\r
             } else if(e instanceof Module && elements.length > 1) {\r
                 Module mod = (Module)e;\r
                 if(mod.getName().equals(element)) {\r