X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.model%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Fsnippets%2Fhighlevelstatehandlers%2Fstandard%2Fsubcomponent%2FDelegatingSubcomponentHighLevelStateHandler.java;h=3347377e432125f03098ff17ef29fa16e98dc587;hb=a25f554756e1bc9a1f842293aefe60a220d8b950;hp=79ec244d58ea7a92692f33f498d2b97cd2498deb;hpb=c310e267d7c8a1003d21c9bbae02b9186a95cd10;p=Mograsim.git diff --git a/net.mograsim.logic.model/src/net/mograsim/logic/model/snippets/highlevelstatehandlers/standard/subcomponent/DelegatingSubcomponentHighLevelStateHandler.java b/net.mograsim.logic.model/src/net/mograsim/logic/model/snippets/highlevelstatehandlers/standard/subcomponent/DelegatingSubcomponentHighLevelStateHandler.java index 79ec244d..3347377e 100644 --- a/net.mograsim.logic.model/src/net/mograsim/logic/model/snippets/highlevelstatehandlers/standard/subcomponent/DelegatingSubcomponentHighLevelStateHandler.java +++ b/net.mograsim.logic.model/src/net/mograsim/logic/model/snippets/highlevelstatehandlers/standard/subcomponent/DelegatingSubcomponentHighLevelStateHandler.java @@ -2,7 +2,10 @@ package net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.subcom import net.mograsim.logic.model.model.components.GUIComponent; import net.mograsim.logic.model.model.components.submodels.SubmodelComponent; +import net.mograsim.logic.model.serializing.IdentifierGetter; +import net.mograsim.logic.model.snippets.SnippetDefinintion; import net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.HighLevelStateHandlerContext; +import net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.StandardHighLevelStateHandlerSnippetSuppliers; public class DelegatingSubcomponentHighLevelStateHandler implements SubcomponentHighLevelStateHandler { @@ -40,7 +43,7 @@ public class DelegatingSubcomponentHighLevelStateHandler implements Subcomponent { if (delegateTarget == null) this.delegateTarget = parentComponent; - else if (!parentComponent.submodel.getComponentsByName().containsValue(delegateTarget)) + else if (parentComponent.submodel.getComponentsByName().get(delegateTarget.name) != delegateTarget) throw new IllegalArgumentException( "Can only set components belonging to the submodel of the parent component of this handler as the delegate target"); this.delegateTarget = delegateTarget; @@ -68,9 +71,25 @@ public class DelegatingSubcomponentHighLevelStateHandler implements Subcomponent return prefix == null ? subStateID : prefix + '.' + subStateID; } + @Override + public DelegatingSubcomponentHighLevelStateHandlerParams getParamsForSerializing(IdentifierGetter idGetter) + { + DelegatingSubcomponentHighLevelStateHandlerParams params = new DelegatingSubcomponentHighLevelStateHandlerParams(); + params.delegateTarget = delegateTarget.name; + params.prefix = prefix; + return params; + } + public static class DelegatingSubcomponentHighLevelStateHandlerParams { public String delegateTarget; public String prefix; } + + static + { + StandardHighLevelStateHandlerSnippetSuppliers.subcomponentHandlerSupplier + .setSnippetSupplier(DelegatingSubcomponentHighLevelStateHandler.class.getCanonicalName(), SnippetDefinintion + .create(DelegatingSubcomponentHighLevelStateHandlerParams.class, DelegatingSubcomponentHighLevelStateHandler::new)); + } } \ No newline at end of file