X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.model%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Fsnippets%2Fhighlevelstatehandlers%2Fstandard%2Fatomic%2FDelegatingAtomicHighLevelStateHandler.java;h=de9bc4ada058a58d54603f853799e2ff365dbaf5;hb=a25f554756e1bc9a1f842293aefe60a220d8b950;hp=0ed207f4fd9c98d4cd0a08aa127dec31b9d4c022;hpb=2d27647cad85202abbd4bd3cdf7023083c17013c;p=Mograsim.git diff --git a/net.mograsim.logic.model/src/net/mograsim/logic/model/snippets/highlevelstatehandlers/standard/atomic/DelegatingAtomicHighLevelStateHandler.java b/net.mograsim.logic.model/src/net/mograsim/logic/model/snippets/highlevelstatehandlers/standard/atomic/DelegatingAtomicHighLevelStateHandler.java index 0ed207f4..de9bc4ad 100644 --- a/net.mograsim.logic.model/src/net/mograsim/logic/model/snippets/highlevelstatehandlers/standard/atomic/DelegatingAtomicHighLevelStateHandler.java +++ b/net.mograsim.logic.model/src/net/mograsim/logic/model/snippets/highlevelstatehandlers/standard/atomic/DelegatingAtomicHighLevelStateHandler.java @@ -2,7 +2,10 @@ package net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.atomic 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 DelegatingAtomicHighLevelStateHandler implements AtomicHighLevelStateHandler { @@ -39,7 +42,7 @@ public class DelegatingAtomicHighLevelStateHandler implements AtomicHighLevelSta { 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; @@ -62,9 +65,25 @@ public class DelegatingAtomicHighLevelStateHandler implements AtomicHighLevelSta delegateTarget.setHighLevelState(subStateID, newState); } + @Override + public DelegatingAtomicHighLevelStateHandlerParams getParamsForSerializing(IdentifierGetter idGetter) + { + DelegatingAtomicHighLevelStateHandlerParams params = new DelegatingAtomicHighLevelStateHandlerParams(); + params.delegateTarget = delegateTarget.name; + params.subStateID = subStateID; + return params; + } + public static class DelegatingAtomicHighLevelStateHandlerParams { public String delegateTarget; public String subStateID; } + + static + { + StandardHighLevelStateHandlerSnippetSuppliers.atomicHandlerSupplier.setSnippetSupplier( + DelegatingAtomicHighLevelStateHandler.class.getCanonicalName(), + SnippetDefinintion.create(DelegatingAtomicHighLevelStateHandlerParams.class, DelegatingAtomicHighLevelStateHandler::new)); + } } \ No newline at end of file