List the unsatisfied dependencies in CanvasContext 30/230/1
authorjsimomaa <jani.simomaa@gmail.com>
Wed, 28 Dec 2016 14:01:24 +0000 (16:01 +0200)
committerjsimomaa <jani.simomaa@gmail.com>
Wed, 28 Dec 2016 14:01:24 +0000 (16:01 +0200)
refs #6898

Change-Id: I07de49394e871d27f6df172c02cfdff05cde44b1

bundles/org.simantics.g2d/src/org/simantics/g2d/canvas/impl/AbstractCanvasParticipant.java
bundles/org.simantics.g2d/src/org/simantics/g2d/canvas/impl/CanvasContext.java

index 4de85481281222fc2646c8960bd452f51dffb6f6..a7950d26d6cf268939661b4120abf2b37917ff0a 100644 (file)
@@ -12,6 +12,8 @@
 package org.simantics.g2d.canvas.impl;\r
 \r
 import java.lang.reflect.Field;\r
+import java.util.HashSet;\r
+import java.util.Set;\r
 \r
 import org.simantics.g2d.canvas.ICanvasContext;\r
 import org.simantics.g2d.canvas.ICanvasParticipant;\r
@@ -171,6 +173,9 @@ public abstract class AbstractCanvasParticipant implements ICanvasParticipant {
             AbstractCanvasParticipant.this.depsSatisfied = depsSatisfied;\r
         }\r
     };\r
+\r
+    Set<Field> missingDependencies = new HashSet<>();\r
+    \r
     @SuppressWarnings("unchecked")\r
     private void _itemAdded(IContext<ICanvasParticipant> sender, ICanvasParticipant item)\r
     {\r
@@ -532,8 +537,12 @@ public abstract class AbstractCanvasParticipant implements ICanvasParticipant {
                            continue;\r
                        Field f = rd.field;\r
                        Object o = f.get(this);\r
-                       if (o == null)\r
+                       if (o == null) {\r
+                           missingDependencies.add(f);\r
                            return false;\r
+                       } else {\r
+                           missingDependencies.remove(f);\r
+                       }\r
                    }\r
                } catch (Exception e) {\r
                    throw new RuntimeException(e);\r
index 035211c2c4e5aef4312aa18e36027e12a4d7feba..18e08f5739f317228d44bbc4eec90f44b4a172fc 100644 (file)
@@ -277,7 +277,7 @@ public class CanvasContext extends Context<ICanvasParticipant> implements ICanva
             if (ctx instanceof AbstractCanvasParticipant) {\r
                 AbstractCanvasParticipant acp = (AbstractCanvasParticipant) ctx;\r
                 if (!acp.depsSatisfied) {\r
-                    throw new AssertionError("Participant "+acp+" dependies unsatisfied");\r
+                    throw new AssertionError("Participant "+acp+" dependencies unsatisfied : " + acp.missingDependencies);\r
                 }\r
             }\r
     }\r