From eaacbec0a17e8576b7502680de298fc14c51eef9 Mon Sep 17 00:00:00 2001 From: jsimomaa Date: Wed, 28 Dec 2016 16:01:24 +0200 Subject: [PATCH] List the unsatisfied dependencies in CanvasContext refs #6898 Change-Id: I07de49394e871d27f6df172c02cfdff05cde44b1 --- .../g2d/canvas/impl/AbstractCanvasParticipant.java | 11 ++++++++++- .../org/simantics/g2d/canvas/impl/CanvasContext.java | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) 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); } } } -- 2.47.1