From: jsimomaa Date: Wed, 28 Dec 2016 14:01:24 +0000 (+0200) Subject: List the unsatisfied dependencies in CanvasContext X-Git-Tag: v1.26.0~9^2 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=eaacbec0a17e8576b7502680de298fc14c51eef9;p=simantics%2Fplatform.git List the unsatisfied dependencies in CanvasContext refs #6898 Change-Id: I07de49394e871d27f6df172c02cfdff05cde44b1 --- diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/canvas/impl/AbstractCanvasParticipant.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/canvas/impl/AbstractCanvasParticipant.java index 4de854812..a7950d26d 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/canvas/impl/AbstractCanvasParticipant.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/canvas/impl/AbstractCanvasParticipant.java @@ -12,6 +12,8 @@ package org.simantics.g2d.canvas.impl; import java.lang.reflect.Field; +import java.util.HashSet; +import java.util.Set; import org.simantics.g2d.canvas.ICanvasContext; import org.simantics.g2d.canvas.ICanvasParticipant; @@ -171,6 +173,9 @@ public abstract class AbstractCanvasParticipant implements ICanvasParticipant { AbstractCanvasParticipant.this.depsSatisfied = depsSatisfied; } }; + + Set missingDependencies = new HashSet<>(); + @SuppressWarnings("unchecked") private void _itemAdded(IContext sender, ICanvasParticipant item) { @@ -532,8 +537,12 @@ public abstract class AbstractCanvasParticipant implements ICanvasParticipant { continue; Field f = rd.field; Object o = f.get(this); - if (o == null) + if (o == null) { + missingDependencies.add(f); return false; + } else { + missingDependencies.remove(f); + } } } catch (Exception e) { throw new RuntimeException(e); diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/canvas/impl/CanvasContext.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/canvas/impl/CanvasContext.java index 035211c2c..18e08f573 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/canvas/impl/CanvasContext.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/canvas/impl/CanvasContext.java @@ -277,7 +277,7 @@ public class CanvasContext extends Context implements ICanva if (ctx instanceof AbstractCanvasParticipant) { AbstractCanvasParticipant acp = (AbstractCanvasParticipant) ctx; if (!acp.depsSatisfied) { - throw new AssertionError("Participant "+acp+" dependies unsatisfied"); + throw new AssertionError("Participant "+acp+" dependencies unsatisfied : " + acp.missingDependencies); } } }