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
{
{
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;
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