List the unsatisfied dependencies in CanvasContext
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / canvas / impl / AbstractCanvasParticipant.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