Fixed another bug in DelegatingSubcomponentHighLevelStateHandler
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Sun, 11 Oct 2020 22:06:03 +0000 (00:06 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Sun, 11 Oct 2020 22:07:12 +0000 (00:07 +0200)
plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/snippets/highlevelstatehandlers/standard/subcomponent/DelegatingSubcomponentHighLevelStateHandler.java

index a7f2c81..295be02 100644 (file)
@@ -52,13 +52,13 @@ public class DelegatingSubcomponentHighLevelStateHandler implements Subcomponent
 
        public void setDelegateTarget(ModelComponent delegateTarget)
        {
-               if (delegateTarget == null)
+               if (delegateTarget == null || delegateTarget == parentComponent)
                        this.delegateTarget = parentComponent;
-               else if (delegateTarget != parentComponent
-                               && parentComponent.submodel.getComponentsByName().get(delegateTarget.getName()) != delegateTarget)
+               else if (parentComponent.submodel.getComponentsByName().get(delegateTarget.getName()) == delegateTarget)
+                       this.delegateTarget = delegateTarget;
+               else
                        throw new IllegalArgumentException(
                                        "Can only set components belonging to the submodel of the parent component of this handler or the parent component itself as the delegate target");
-               this.delegateTarget = delegateTarget;
        }
 
        public ModelComponent getDelegateTarget()